VC驿站

 找回密码
 加入驿站

QQ登录

只需一步,快速开始

搜索
查看: 2164|回复: 0

D3D9_TS 走到VirtualProtect函数出问题了

[复制链接]
19_avatar_middle
最佳答案
12 
在线会员 发表于 2019-12-1 16:35:38 | 显示全部楼层 |阅读模式
本帖最后由 236a 于 2019-12-1 17:06 编辑



__declspec(naked) HRESULT WINAPI Orginal_DrawIndexedPrimitive(LPDIRECT3DDEVICE9 m_pDevice, D3DPRIMITIVETYPE type, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
{

        _asm
        {
                mov  edi, edi
                push ebp
                mov  ebp, esp
                mov eax, jmpto
                jmp eax
        }
}


//原669C1E50 DrawIndexedPrimitive地址669C1E50 - 66960000 = 61E50(DrawIndexedPrimitivex偏移地址)

//D3D9.DLL 0x66960000(模块地址) - 0x18E000(模块大小)


HRESULT WINAPI MyDrawIndexedPrimitive(LPDIRECT3DDEVICE9 m_pDevice,D3DPRIMITIVETYPE type, INT BaseVertexIndex, UINT MinVertexIndex, UINT NumVertices, UINT startIndex, UINT primCount)
{

        return Orginal_DrawIndexedPrimitive(m_pDevice,type,BaseVertexIndex,MinVertexIndex,NumVertices,startIndex,primCount);

}

ULONG_PTR Cheat::GetDrawIndexedPrimitveAddress()
{
        HANDLE handle = GetModuleHandle(L"d3d9.dll");
        if (handle == INVALID_HANDLE_VALUE)
        {
                return NULL;
        }
        else
        {
                return (ULONG_PTR)handle + 61E50;
        }
}

bool Cheat::HookDrawIndexedPrimitive()
{
        ULONG_PTR address = GetDrawIndexedPrimitveAddress();
        jmpto = address + 5;
        DWORD oldProtect = 0;

        if (VirtualProtect((LPVOID)address, 5, PAGE_EXECUTE_READWRITE, &oldProtect))      //这里             <-------------------------------------------
        {
               
                DWORD value = (DWORD)MyDrawIndexedPrimitive - address - 5;

                _asm
                {
                        mov eax, address
                        mov byte ptr[eax], 0xe9
                        add eax, 1
                        mov ebx, value
                        mov dword ptr[eax], ebx
                }

               
               
                VirtualProtect((LPVOID)address, 5, oldProtect, &oldProtect);
        }

        return true;
}

////////////////////////////////////////////////////////
用SetWindwsHook注入不到CS进程去、但是能hook其他进程..

用工具注入到CS直接调用的  HookDrawIndexedPrimitive();

但是走到    VirtualProtect()      这里出错了用messagebox和GetLastError查看程序会崩,






上一篇:MFC
下一篇:求一个实现思路,不需要具体代码
您需要登录后才可以回帖 登录 | 加入驿站 qq_login

本版积分规则

×【发帖 友情提示】
1、请回复有意义的内容,请勿恶意灌水;
2、纯数字、字母、表情等无意义的内容系统将自动删除;
3、若正常回复后帖子被自动删除,为系统误删的情况,请重新回复其他正常内容或等待管理员审核通过后会自动发布;
4、感谢您对VC驿站一如既往的支持,谢谢合作!

关闭

站长提醒上一条 /2 下一条

QQ|小黑屋|手机版|VC驿站 ( 辽ICP备09019393号-4 )|网站地图wx_jqr

GMT+8, 2023-9-29 14:24

Powered by CcTry.CoM

© 2009-2021 cctry.com

快速回复 返回顶部 返回列表