JustPaste.it

 it goes in utilities template <typename T>
static bool HookFunction(DWORD dwAddress, void* pHookFunction, T* pTrampoline, bool addToIntegrity = false) {
    if (dwAddress) {
        HookContext cxt;
        cxt.dwAddress = dwAddress;
        memcpy(cxt.szAsm, (void)dwAddress, 0x10);

        vHookContext.push_back(cxt);

        DWORD startStub = (DWORD*)&szHookSection[dwHookCount * 0x20];
        dwHookCount++;

        for (int i = 0; i < 7; i++)
            startStub[i] = 0x60000000;
        startStub[7] = 0x4E800020;

        xbox::utilities::HookFunctionStart((DWORD*)dwAddress, startStub, (DWORD)pHookFunction);

        pTrampoline = (T)startStub;

        /if (addToIntegrity) {
            IntegrityManager::Push(dwAddress, 16, IntegrityRegisterSettings(IntegrityRebootNoMetric, 0x362ed31 + dwAddress));
        }*/
        DbgPrint("Hooked: Address=0x%X Stub=0x%X %s", dwAddress, *pTrampoline, addToIntegrity ? "- Added to integrity manager!" : "");
        return true;
    }

    return false;
}

HANDLE SIlent;
//Add this functio to _kernelext.h found in xkelibs 
    NTSYSAPI
    EXPORTNUM(305)
    DWORD
    NTAPI
    RtlSprintf(
        IN        CHAR* Buffer, 
        IN        const CHAR* Format, 
        ...
        );

 

        PWCHAR vaS(const char* Text, ...) {
            CHAR Buffer[0x1000];
            CHAR MessageBuffer[0x100];
            static WCHAR Message[0x100];
            va_list pArgList;
            va_start(pArgList, Text);
            RtlVsprintf(Buffer, Text, pArgList);
            va_end(pArgList);
            RtlSprintf(MessageBuffer, Buffer);
            mbstowcs(Message, MessageBuffer, strlen(MessageBuffer) + 1);
            ZeroMemory(Buffer, sizeof(Buffer));
            ZeroMemory(MessageBuffer, sizeof(MessageBuffer));
            return Message;
        }


//Dash Functions put above titlehooks
//Below function hooks image & offline dash xml 
typedef DWORD(*tFunctionFromDashThatLoadsImages)(PWCHAR r3, CONST PWCHAR r4, DWORD Size);
tFunctionFromDashThatLoadsImages OriginalFunctionFromDashThatLoadsImages;
DWORD FunctionFromDashThatLoadsImagesHook(PWCHAR r3, CONST PWCHAR r4, DWORD Size) {
    bool customSize = false;
        if (wcscmp(r3, L"epix://dashhome-offline.xml") == 0) {
            customSize = true;
            r3 = vaS(Str("section://%X,silent#dashhome-offline.xml"), SIlent);
        }
        if (wcscmp(r3, L"epix://Offline_Slot_Home.jpg") == 0) {
            customSize = true;
            r3 = vaS(Str("section://%X,silent#Offline_Slot_Home.jpg"), SIlent);
        }

        if (wcscmp(r3, L"common://ico_32x_alert.png") == 0) {
            customSize = true;
            r3 = vaS(Str("section://%X,silent#ico_32x_alert.png"), SIlent);
        }

        if (wcscmp(r3, L"common://ico_32x_check.png") == 0) {
            customSize = true;
            r3 = vaS(Str("section://%X,silent#ico_32x_check.png"), SIlent);
        }
        return OriginalFunctionFromDashThatLoadsImages(r3, r4, customSize ? lstrlenW(r3) : Size);
}

struct ManifestData {
    const wchar_t* pCommand;
    char _0x0004[0x18];
    const wchar_t* pParam;
};
//havent been able to get this to work yet. But basically it when a person selects a dash button it performs that action. 
typedef DWORD(*tManifestOnPressHandler)(ManifestData* r3, DWORD r4, DWORD r5);
tManifestOnPressHandler OriginalManifestOnPressHandler;
DWORD ManifestOnPressHandlerHook(ManifestData* r3, DWORD r4, DWORD r5) {
    DWORD dwLR = 0;
    __asm mflr dwLR

    
        if (dwLR == DashXmls::DashPressHook) {
            if (r3) {
                if (r3->pParam && (DWORD)r3->pParam > 0x30000000) {
                    wstring ws(r3->pParam);
                    string s(ws.begin(), ws.end());
                    auto hash = xbox::utilities::Joaat(s.c_str());

                    switch (hash) {
                    case 0x20085702: xbox::utilities::XNotifyUI2(L"Success!"); break;
                    case 0x20fbe9b5: xbox::utilities::XNotifyUI2(L"Success!"); break;
                    case 0x4e1e3fd9: xbox::utilities::XNotifyUI2(L"Success!"); break;
                    case 0xc4663e41: xbox::utilities::XNotifyUI2(L"Success!"); break;
                    case 0x50bf74c8: xbox::utilities::XNotifyUI2(L"Success!"); break;
                    }
                }
            }
        }
    

    return OriginalManifestOnPressHandler(r3, r4, r5);
}


//put this under dash.xex in titlehooks
HookFunction(0x92200360, FunctionFromDashThatLoadsImagesHook, &OriginalFunctionFromDashThatLoadsImages);//DashBuildHook
//HookFunction(0x92324B88, ManifestOnPressHandlerHook, &OriginalManifestOnPressHandler);//DashPressNotify