読者です 読者をやめる 読者になる 読者になる

めいくりぷとのブログ

技術的なことやゲームのことやら・・・

ThemidaCRC

某ブログの方のCEスクリプトC++で書いただけです

// CLogin.hpp

#pragma once

#include "MapleStory.hpp"

#ifndef Padding
#define Padding(x) struct { unsigned char __padding##x[(x)]; };
#endif

struct CLogin
{
	union
	{
		struct
		{
			Padding(OFFSET_m_bEnterMarket);
			BOOL m_bEnterMarket;
		};
	};

public:
	static CLogin * GetInstance();
};


// CLogin.cpp

#include "stdafx.h"

#include "CLogin.hpp"

CLogin * CLogin::GetInstance()
{
	static CLogin **ppInstance = reinterpret_cast<CLogin**>(GLOBAL_CLogin);
	return *ppInstance;
}


// CUIFreeMarket.hpp

#pragma once

#include "MapleStory.hpp"

#ifndef Padding
#define Padding(x) struct { unsigned char __padding##x[(x)]; };
#endif

enum UI_FreeMarket
{
	UI_ChangeRoom = 0x00000464,
};

struct CUIFreeMarkect
{
public:
	static CUIFreeMarkect * GetInstance();

public:
	void CreateUI(UI_FreeMarket nObjectID, int Unknown1, int Unknown2, int Unknown3);
	void DeleteUI(UI_FreeMarket nObjectID);

};


//CUIFreeMarket.cpp

#include "stdafx.h"

#include "CUIFreeMarket.hpp"

CUIFreeMarkect * CUIFreeMarkect::GetInstance()
{
	static CUIFreeMarkect **ppInstance = reinterpret_cast<CUIFreeMarkect**>(GLOBAL_CUIFreeMarket);
	return *ppInstance;
}

void CUIFreeMarkect::CreateUI(UI_FreeMarket nObjectID, int Unknown1, int Unknown2, int Unknown3)
{
	typedef void(__thiscall * CreateUI_t)(CUIFreeMarkect *, int, int, int, int);
	CreateUI_t _CreateUI = reinterpret_cast<CreateUI_t>(ADDRESS_CUIFreeMarket_CreateUI);
	_CreateUI(this, nObjectID, Unknown1, Unknown2, Unknown3);
}

void CUIFreeMarkect::DeleteUI(UI_FreeMarket nObjectID)
{
	typedef void(__thiscall *DeleteUI_t)(CUIFreeMarkect *, int);
	DeleteUI_t _DeleteUI = reinterpret_cast<DeleteUI_t>(ADDRESS_CUIFreeMarket_DeleteUI);
	_DeleteUI(this, nObjectID);
}


// bypass.cpp

VOID Detour_ThemidaCrc()
{
	typedef void(__stdcall *ThemidaCrcT)(void* lpv4);
	static ThemidaCrcT _ThemidaCrc = reinterpret_cast<ThemidaCrcT>(ADDRESS_ThemidaCRC);

	ThemidaCrcT ThemidaCrc_Hook = [](
		void* lpv4) -> void
	{
		CUIFreeMarkect *pUIFreeMarket = CUIFreeMarkect::GetInstance();

		if (CLogin::GetInstance()->m_bEnterMarket)
			return pUIFreeMarket->CreateUI(UI_ChangeRoom, -1, NULL, NULL);

		return pUIFreeMarket->DeleteUI(UI_ChangeRoom);
	};

	DetourFunction(TRUE, reinterpret_cast<LPVOID*>(&_ThemidaCrc), ThemidaCrc_Hook);
}