Skip to content

ResumeThread causes crash when unfreezing, possibly due to unhandled SuspendThread error #52

@ethanporcaro

Description

@ethanporcaro

Sorry if this isn't enough information, threading is not my strong suit. Please let me know.

I'll occasionally get access violation errors when using a midhook for an x64 program. This is happening when the threads are resumed.

 	ntdll.dll!NtQueryInformationThread()	Unknown
 	KernelBase.dll!GetThreadId()	Unknown
	BF2VR.dll!safetyhook::execute_while_frozen(const std::function<void __cdecl(void)> & run_fn, const std::function<void __cdecl(unsigned int,void *,_CONTEXT &)> & visit_fn) Line 139	C++
 	BF2VR.dll!safetyhook::InlineHook::e9_hook(const std::shared_ptr<safetyhook::Allocator> & allocator) Line 323	C++
 	BF2VR.dll!safetyhook::InlineHook::setup(const std::shared_ptr<safetyhook::Allocator> & allocator, unsigned char * target, unsigned char * destination) Line 191	C++
 	BF2VR.dll!safetyhook::InlineHook::create(const std::shared_ptr<safetyhook::Allocator> & allocator, void * target, void * destination) Line 147	C++
 	BF2VR.dll!safetyhook::InlineHook::create<unsigned char *,unsigned char *>(const std::shared_ptr<safetyhook::Allocator> & allocator, unsigned char * target, unsigned char * destination) Line 108	C++
 	BF2VR.dll!safetyhook::MidHook::setup(const std::shared_ptr<safetyhook::Allocator> & allocator, unsigned char * target, void(*)(safetyhook::Context64 &) destination) Line 110	C++
 	BF2VR.dll!safetyhook::MidHook::create(const std::shared_ptr<safetyhook::Allocator> & allocator, void * target, void(*)(safetyhook::Context64 &) destination) Line 56	C++
 	BF2VR.dll!safetyhook::MidHook::create(void * target, void(*)(safetyhook::Context64 &) destination) Line 48	C++
 	BF2VR.dll!safetyhook::create_mid(void * target, void(*)(safetyhook::Context64 &) destination) Line 13	C++
 	BF2VR.dll!BF2VR::BF2Service::Initialize() Line 209	C++
 	BF2VR.dll!BF2VR::MainThread(HINSTANCE__ * hModule) Line 108	C++
 	kernel32.dll!BaseThreadInitThunk()	Unknown
 	ntdll.dll!RtlUserThreadStart()	Unknown

I read up on GetThreadId and from what I understand, it shouldn't be possible to crash the program. It's showing an access violation at 0x0.

Please let me know what I need to send to help with this. Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions