| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1903 人关注过本帖
标题:来个大佬帮忙看看CRT初始化哪里出了问题
只看楼主 加入收藏
APLUSVABLE
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2020-1-8
收藏
 问题点数:0 回复次数:1 
来个大佬帮忙看看CRT初始化哪里出了问题
CRT(C++运行库)初始化遇到了问题,我手动将我的dll动态数据库映射到另外一个dll的内存中,我将一个IAT hook到“CloseHandle”函数,所以游戏会调用我的mainCRTStartup(C++初始化函数,这是程序的入口点,然后会调用我的main()函数),如果禁用CRT,入口点会直接跳到main()函数,编译后,注入时良好,但是一旦到crt初始化目标进程将在此处(见下图)崩溃,我解析了dll导入,hook没问题,但是crt初始化,直接崩溃,偶尔甚至无法执行
我需要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 );```
到底哪里出了问题?
搜索更多相关主题的帖子: auto CRT 初始化 sleep hook 
2020-01-08 14:26
zzz3265
Rank: 2
等 级:论坛游民
威 望:1
帖 子:14
专家分:10
注 册:2022-2-6
收藏
得分:0 
截图上看是一个函数的调用, 这个函数用的是导入表
"我手动将我的dll动态数据库映射到另外一个dll的内存中", 这个导入表要重新定位, 不能直接复制, 另外还有其他问题的(重定位之类的)
2022-02-06 01:24
快速回复:来个大佬帮忙看看CRT初始化哪里出了问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.015056 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved