#2
zzz32652022-02-06 01:24
|
我需要hook的代码:(全部在内核中运行)
只有本站会员才能查看附件,请 登录
只有本站会员才能查看附件,请 登录
```c
constexpr wchar_t s_RustClientModule[] = L"uplay_r164.dll";
UNICODE_STRING u_RustClientModule = { 0 };
funcs::RtlInitUnicodeString( &u_RustClientModule, s_RustClientModule );
const auto rust_client_exe = game.get_module( &u_RustClientModule, nullptr );
if ( !rust_client_exe )
{
game.detach( );
return STATUS_UNSUCCESSFUL;
}
funcs::DbgPrint( "rust_client_exe: %p\n", rust_client_exe );
utils::sleep( 2000 );
auto import_address = utils::get_imported_function( rust_client_exe, "CloseHandle" );
if ( !import_address )
{
game.detach( );
return STATUS_UNSUCCESSFUL;
}
funcs::DbgPrint( "import_address: %p\n", import_address );
utils::sleep( 2000 );
auto import_ptr_protect = reinterpret_cast< PVOID >( import_address );
auto import_ptr = reinterpret_cast< uintptr_t* >( import_address );
const auto original_import_ptr = *import_ptr;
funcs::DbgPrint( "import_ptr: %p\n", import_ptr );
funcs::DbgPrint( "import_ptr deref: %p\n", *import_ptr );
funcs::DbgPrint( "import_ptr address of: %p\n", &import_ptr );
utils::sleep( 2000 );
SIZE_T size = sizeof( uintptr_t );
ULONG old_access;
ULONG old_access2;
if ( !NT_SUCCESS( funcs::ZwProtectVirtualMemory( NtCurrentProcess( ), &import_ptr_protect, &size, PAGE_READWRITE, &old_access ) ) )
{
funcs::DbgPrint( "failed protect 1" );
utils::sleep( 2000 );
game.detach( );
return STATUS_UNSUCCESSFUL;
}
RtlCopyMemory( import_ptr, &entry_point, sizeof( entry_point ) );
utils::sleep( 50 );
if ( !NT_SUCCESS( funcs::ZwProtectVirtualMemory( NtCurrentProcess( ), &import_ptr_protect, &size, old_access, &old_access2 ) ) )
{
funcs::DbgPrint( "failed protect 2" );
utils::sleep( 2000 );
game.detach( );
return STATUS_UNSUCCESSFUL;
}
funcs::DbgPrint( "finished hook" );
utils::sleep( 2000 );```
到底哪里出了问题?