// dllmain.cpp : 定义 DLL 应用程序的入口点。
#include "pch.h"
#include "HookUi.hpp"
#include "Hook.hpp"




//初始化入口
void Init() {




    //是否加载百级UI
    FILE* file = fopen("ImagePacks2/!HUD_Yosin百级UI.NPK", "rb");
    if (file)
    {
        HookHudUi();
        fclose(file);
    }

    //是否开启控制台
    FILE* file2 = fopen("ip.txt", "rb");
    if (file2)
    {
        AllocConsole();
        SetConsoleTitle(L"Rindro_Console");
        SetConsoleOutputCP(65001);
        freopen(("CONOUT$"), ("w"), stdout);
        freopen(("CONOUT$"), ("w"), stderr);
        freopen(("CONIN$"), ("r"), stdin);

        *(BYTE*)0x006FCC7D = 0xEB;//双开jmp
        *(BYTE*)0x006FCC7E = 0x09;
        *(BYTE*)0x006FCC7F = 0x90;//双开nop
        *(BYTE*)0x01122DA1 = 0xEB;//双开jmp
        *(BYTE*)0x01162ACC = 0xEB;//双开jmp
        fclose(file2);
    }


    ////是否是入梦登录器
    //FILE* mengyiqufile = fopen("mengyiqukey.dll", "rb");
    //if (mengyiqufile)
    //{
    //    *(int*)0x400f00 = 11;
    //    fclose(mengyiqufile);

    //    std::stringstream Ip;
    //    Ip << static_cast<int>(*(BYTE*)0x400F50) << "."
    //        << static_cast<int>(*(BYTE*)0x400F51) << "."
    //        << static_cast<int>(*(BYTE*)0x400F52) << "."
    //        << static_cast<int>(*(BYTE*)0x400F53);

    //    std::cout << *(int*)0x400F50 << std::endl;
    //    std::cout << Ip.str() << std::endl;
    //}


    //注册HOOK
    RegisterHook();
}


__declspec(dllexport) void _cdecl Lenheart()
{

}


BOOL APIENTRY DllMain( HMODULE hModule,
                       DWORD  ul_reason_for_call,
                       LPVOID lpReserved
                     )
{
    switch (ul_reason_for_call)
    {
    case DLL_PROCESS_ATTACH:
        Init();
    case DLL_THREAD_ATTACH:
    case DLL_THREAD_DETACH:
    case DLL_PROCESS_DETACH:
        break;
    }
    return TRUE;
}

