Comments (11)
from polyhook_2_0.
I assume you are trying to do an IAT hook. Import by ordinal is nor supported because i don't need it. If you want to look at the source and send a PR to improve the interface please do so. If you just want an inline hook just get the address of the recv and pass it to the constructor like any of the other examples
PolyHook_2_0/UnitTests/TestDetourx86.cpp
Line 181 in 1a4f551
from polyhook_2_0.
I am testing hook by x86 detour:
Unhandled exception thrown: read access violation.
this->m_disasm. was nullptr.
Code:
uint64_t g_hook_recv_tramp = NULL;
void hkRecv(SOCKET s, char* buf, int len, int flags)
{
PLH::FnCast(g_hook_recv_tramp, &hkRecv)(s, buf, len, flags);
}
auto recv_addr = reinterpret_cast<uint64_t>(GetProcAddress(GetModuleHandleA("ws2_32.dll"), "recv"));
PLH::CapstoneDisassembler dis(PLH::Mode::x86);
PLH::x86Detour detour(recv_addr, (uint64_t)&hkRecv, &g_hook_recv_tramp, dis);
detour.hook();
from polyhook_2_0.
you need to keep the disassembler in scope for as long as the detour object exists. The disassembler is captured by referenced so if it's destroyed before the detour the detour will attempt to use a destroyed object.
from polyhook_2_0.
you need to keep the disassembler in scope for as long as the detour object exists. The disassembler is captured by referenced so if it's destroyed before the detour the detour will attempt to use a destroyed object.
I make disassembler in global scope:
Unhandled exception thrown: read access violation.
_Ptr_user was 0xF000000.
from polyhook_2_0.
Verify the address returned by getprocaddress is valid. Otherwise you need to debug this yourself
from polyhook_2_0.
Verify the address returned by getprocaddress is valid. Otherwise you need to debug this yourself
Address is valid (0x0000000076e11460). Crash in polyhook code (PLH::CapstoneDisassembler::disassemble)
from polyhook_2_0.
Can you please debug the routine and determine where exactly inside that routine the crash occurs.
from polyhook_2_0.
Value by crash. Crash in capstone:
PLH::insts_t
PLH::CapstoneDisassembler::disassemble(uint64_t firstInstruction, uint64_t start, uint64_t End, const MemAccessor& accessor) {
cs_insn* insInfo = cs_malloc(m_capHandle);
insts_t insVec;
m_branchMap.clear();
uint64_t size = End - start;
assert(size > 0);
if (size <= 0)
return insVec;
// copy potentially remote memory to local buffer
uint8_t* buf = new uint8_t[(uint32_t)size];
// bufAddr updated by cs_disasm_iter
uint64_t bufAddr = (uint64_t)buf;
accessor.mem_copy((uint64_t)buf, firstInstruction, size);
bool endHit = false;
while (cs_disasm_iter(m_capHandle, (const uint8_t**)&bufAddr, (size_t*)&size, &start, insInfo)) {
// Set later by 'SetDisplacementFields'
Instruction::Displacement displacement = {};
displacement.Absolute = 0;
Instruction inst(insInfo->address,
displacement,
0,
false,
false,
insInfo->bytes,
insInfo->size,
insInfo->mnemonic,
insInfo->op_str,
m_mode);
setDisplacementFields(inst, insInfo);
if (endHit && !isPadBytes(inst))
break;
insVec.push_back(inst); // crash on push value in vector
// searches instruction vector and updates references
addToBranchMap(insVec, inst);
if (isFuncEnd(inst))
endHit = true;
}
delete[] buf;
cs_free(insInfo, 1);
return insVec;
}
from polyhook_2_0.
I cannot reproduce this
from polyhook_2_0.
I am use struct member alignment 1 byte. Is it possible that this is because of this?
from polyhook_2_0.
Related Issues (20)
- Disassembler may go out of bounds into unmapped region HOT 1
- Detours getting automatically removed HOT 9
- Crash on VFuncSwapHook/VTableSwapHook Constructor HOT 1
- A windows app that uses std::stringstream crashes when PolyHook_2.lib is included in the link. HOT 8
- MessageBoxW & EatHook
- Cannot compile polyhook on linux using cmake HOT 4
- VEH Hook function HOT 1
- Stack overflow in PLH::ErrorLog::log HOT 3
- fail on link when use vcpkg with x64-windows-static HOT 17
- Does x86Detour seem not to work for external DLL calls? HOT 6
- A question about how to hook into external libraries. HOT 1
- When I tried to hook some functions, it caused the program to crash HOT 4
- Link issue with x86-windows-static HOT 1
- Calling the original function fails after hooking the same function twice or more HOT 2
- Crashes when hooking e.g. QueryPerformanceCounter in x64 but works with x86 HOT 1
- Design issues with bool hook() and bool unHook() HOT 1
- Hooking function fails with "Warn: Couldn't decompile instructions at followed jmp" and "Error: Prologue jmp resolution failed" HOT 9
- Improper hooks when RSP instructions are in the prologue HOT 1
- Crash caused by unsafe read HOT 4
- Implement detour unit tests with emulator HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from polyhook_2_0.