What's new

Welcome to HvH Forum!

SignUp Now! Download Free HvH CS2/CS:GO Cheats, CFG, LUA/JS Scripts, And More!


SignUp Now!

Request Pls help.Chams does not work

Newbie HvHer
User ID
29749
Messages
1
Reactions
0
Level
1
I highlighted the model I want to unveal and disable z-buffer ,even rasterizer state but it still does not show through the wall.I am using usual trapoline hook.I will appreciate any help.Sorry for my English.I am not native speaker.Below the source.(D3D11 chams).I spent few days to get this work ,but no result.Can not find a mistake.
C++:
#include "includes.h"
#include <iostream>
#include <mutex>
#define SAFE_RELEASE(p)      { if(p) { (p)->Release(); (p)=NULL; } }
#define DEPTH_BIAS_D32_FLOAT(d) (d/(1/pow(2,23)))
//vertex
UINT veStartSlot;
UINT veNumBuffers;
UINT Stride;
UINT veBufferOffset;
bool wallhack = false;
UINT pStencilRef;
//index
DXGI_FORMAT inFormat;
UINT        inOffset;


//psgetConstantbuffers
UINT pscStartSlot;
UINT pscNumBuffers;
ID3D11Buffer* pscBuffer;
struct propertiesModel
{
    UINT stride;
    UINT vedesc_ByteWidth;
    UINT indesc_ByteWidth;
    UINT pscdesc_ByteWidth;
};
bool firsttime = true;

bool operator==(const propertiesModel& lhs, const propertiesModel& rhs)
{
    if (lhs.indesc_ByteWidth != rhs.indesc_ByteWidth ||
        lhs.pscdesc_ByteWidth != rhs.pscdesc_ByteWidth ||
        lhs.stride != rhs.stride ||
        lhs.vedesc_ByteWidth != rhs.vedesc_ByteWidth)
    {
        return false;
    }
    else
    {
        return true;
    }
}
namespace std {
    template<>
    struct hash<propertiesModel>
    {
        std::size_t operator()(const propertiesModel& obj) const noexcept
        {
            std::size_t h1 = std::hash<int>{}(obj.stride);
            std::size_t h2 = std::hash<int>{}(obj.vedesc_ByteWidth);
            std::size_t h3 = std::hash<int>{}(obj.indesc_ByteWidth);
            std::size_t h4 = std::hash<int>{}(obj.pscdesc_ByteWidth);
            return (h1 + h3 + h4) ^ (h2 << 1);
        }
    };
}
propertiesModel currentParam;
std::unordered_set<propertiesModel>models;
std::mutex g_propertiesModels;



void MyFunc(ID3D11DeviceContext* pContext, UINT IndexCount, UINT StartIndexLocation, INT BaseVertexLocation)
{

    pContext->IAGetVertexBuffers(0, 1, &vertexBuffer, &Stride, &veBufferOffset);
    if (vertexBuffer)
        vertexBuffer->GetDesc(&vedesc);
    if (vertexBuffer)
    {
        vertexBuffer->Release();
        vertexBuffer = nullptr;
    }
    
    pContext->IAGetIndexBuffer(&inBuffer, &inFormat, &inOffset);
    if (inBuffer)
        inBuffer->GetDesc(&indesc);

    if (inBuffer)
    {
        inBuffer->Release();
        inBuffer = nullptr;
    }

    pContext->PSGetConstantBuffers(pscStartSlot, 1, &cBuffer);
    if (cBuffer)
        cBuffer->GetDesc(&pscdesc);
    if (cBuffer)
    {
        cBuffer->Release();
        cBuffer = nullptr;
    }
    propertiesModel paramsModel;
    paramsModel.stride = Stride;
    paramsModel.vedesc_ByteWidth = vedesc.ByteWidth;
    paramsModel.indesc_ByteWidth = indesc.ByteWidth;
    paramsModel.pscdesc_ByteWidth = pscdesc.ByteWidth;
    models.insert(paramsModel);
    
    if (firsttime)
    {
        currentParam = paramsModel;
        firsttime = false;
    }

    auto current = models.find(currentParam);

    if (GetAsyncKeyState(VK_NUMPAD1) & 1)
    {
        if (current == models.begin())
        {
            current = --(models.end());

        }
        else
        {
            current--;
        }
        currentParam = *current;
    }
    if (GetAsyncKeyState(VK_NUMPAD2) & 1)
    {
        
         if (current == --(models.end()))
        {
             current = models.begin();
                    
        }         
        else
        {
            current++;
            
        }
         currentParam = *current;
    }
    if (GetAsyncKeyState(VK_NUMPAD3) & 1)
    {
        wallhack = !wallhack;
    }
    UINT stencilValue = 0;
    pContext->OMGetDepthStencilState(&m_origDepthStencilState, &stencilValue);
    pContext->RSGetState(&DEPTHBIASState_TRUE);
    if (paramsModel == currentParam)
    {   

        pContext->PSSetShader(pShaderRed, NULL, NULL);   
        if (wallhack)
        {
            UINT ref = 0;
            pContext->OMSetDepthStencilState(m_DepthStencilState, ref);
            pContext->RSSetState(DEPTHBIASState_FALSE);
            fnID3D11DrawIndexed(pContext, IndexCount, StartIndexLocation, BaseVertexLocation);//I think the problem that I use trampolinehook?
        }
    }
    
    
    pContext->OMSetDepthStencilState(m_origDepthStencilState, stencilValue);
    pContext->RSSetState(DEPTHBIASState_TRUE);
    SAFE_RELEASE(m_origDepthStencilState);
    SAFE_RELEASE(DEPTHBIASState_TRUE);
    fnID3D11DrawIndexed(pContext, IndexCount, StartIndexLocation, BaseVertexLocation);
    
}
void Myfucnpr(IDXGISwapChain* pthis, UINT param1, UINT param2)
{
    if(!pDevice)
    {
    HRESULT hr = pthis->GetDevice(__uuidof(ID3D11Device),(void**)&pDevice);

    if (FAILED(hr))return;

     pDevice->GetImmediateContext(&devcon);

     GenerateShader(pDevice, &pShaderRed, 1.0f, 0.0f, 1.0f);
    
     D3D11_DEPTH_STENCIL_DESC depthStencilDesc;
     depthStencilDesc.DepthEnable = FALSE;
     depthStencilDesc.DepthWriteMask = D3D11_DEPTH_WRITE_MASK_ALL;
     depthStencilDesc.DepthFunc = D3D11_COMPARISON_ALWAYS;
     depthStencilDesc.StencilEnable = FALSE;
     depthStencilDesc.StencilReadMask = 0xFF;
     depthStencilDesc.StencilWriteMask = 0xFF;

     // Stencil operations if pixel is front-facing
     depthStencilDesc.FrontFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
     depthStencilDesc.FrontFace.StencilDepthFailOp = D3D11_STENCIL_OP_INCR;
     depthStencilDesc.FrontFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
     depthStencilDesc.FrontFace.StencilFunc = D3D11_COMPARISON_ALWAYS;

     // Stencil operations if pixel is back-facing
     depthStencilDesc.BackFace.StencilFailOp = D3D11_STENCIL_OP_KEEP;
     depthStencilDesc.BackFace.StencilDepthFailOp = D3D11_STENCIL_OP_DECR;
     depthStencilDesc.BackFace.StencilPassOp = D3D11_STENCIL_OP_KEEP;
     depthStencilDesc.BackFace.StencilFunc = D3D11_COMPARISON_ALWAYS;


     pDevice->CreateDepthStencilState(&depthStencilDesc, &m_DepthStencilState);


     D3D11_RASTERIZER_DESC rasterizer_desc;
     ZeroMemory(&rasterizer_desc, sizeof(rasterizer_desc));
     rasterizer_desc.FillMode = D3D11_FILL_SOLID;
     rasterizer_desc.CullMode = D3D11_CULL_NONE; //D3D11_CULL_FRONT;
     rasterizer_desc.FrontCounterClockwise = false;
     float bias = 1000.0f;
     float bias_float = static_cast<float>(-bias);
     bias_float /= 10000.0f;
     rasterizer_desc.DepthBias = DEPTH_BIAS_D32_FLOAT(*(DWORD*)&bias_float);
     rasterizer_desc.SlopeScaledDepthBias = 0.0f;
     rasterizer_desc.DepthBiasClamp = 0.0f;
     rasterizer_desc.DepthClipEnable = true;
     rasterizer_desc.ScissorEnable = false;
     rasterizer_desc.MultisampleEnable = false;
     rasterizer_desc.AntialiasedLineEnable = false;
     pDevice->CreateRasterizerState(&rasterizer_desc, &DEPTHBIASState_FALSE);
    }

    hkPresent(pthis, param1, param2);
}
int MainThread(HMODULE hModule)
{
    
    if (Get3DDevice())
    {
        
        memcpy(originalBytPr, ogPresent, 14);
        hkPresent = (__hkPresent)TrapHook(ogPresent, Myfucnpr, 14);
        Sleep(1000);
        memcpy(originalBytes, ogDrawIndexed, 18);
        fnID3D11DrawIndexed = (ID3D11DrawIndexed)TrapHook(ogDrawIndexed, MyFunc, 18);
        
    }
    else
        FreeLibraryAndExitThread(hModule, 0);
    
    while (!GetAsyncKeyState(VK_END) & 1){
        Sleep(20);
    }

    Patch(ogDrawIndexed, originalBytes, 18);
    Patch(ogPresent, originalBytPr, 14);
    Sleep(1000);
    FreeLibraryAndExitThread(hModule, 0);
    return 0;
}

BOOL WINAPI DllMain(HMODULE hModule, DWORD reason, LPVOID lParam)
{
    if (reason == DLL_PROCESS_ATTACH)
    {
        CreateThread(0, 0, (LPTHREAD_START_ROUTINE)MainThread, hModule, 0, 0);
    }
    return TRUE;
}
 

Create an account or login to comment

You must be a member in order to leave a comment

Create account

Create an account on our community. It's easy!

Log in

Already have an account? Log in here.

Top