Jump to content

About MSHookFunction


Dababababa7777

1 post in this topic

Recommended Posts

Posted

I want to put the scope and address information of a class and a function in the symbol of MSHookFunction at the same time.

 

Of course, if you leave it like this, you will get an error, but like this: 

 

Tweak.xm

#include "Item.h"
#include "ItemInstance.h"
#include "Recipes.h"

void (*Recipes_init)(Recipes*);
void _Recipes_init(Recipes* res) {
	Recipes_init(res);
	
	const std::vector<Recipes::Type, std::allocator<Recipes::Type>>& def = definition<Item*, Item*>('#', Item::mItems[296], 'S', Item::mItems[368]);

	res->addShapedRecipe(ItemInstance(Item::mItems[432], 0), "###", "#S#", "###", def);
}

%ctor {
	MSHookFunction(Recipes::_init + (0x100774f40 + _dyld_get_image_vmaddr_slide(0)), (void*)&_Recipes_init, (void**)&_Recipes_init);
	MSHookFunction(Recipes::addShapedRecipe + (0x100781d74 + _dyld_get_image_vmaddr_slide(0)), NULL, NULL);
	MSHookFunction(Item::mItems + (0x10074689c + _dyld_get_image_vmaddr_slide(0)), NULL, NULL);
	MSHookFunction(ItemInstance::ItemInstance + (0x1007569a4 + _dyld_get_image_vmaddr_slide(0)), NULL, NULL);
}

 

Recipes.h

#pragma once

#include <memory>
#include <string>
#include <vector>
#include <stdint.h>

#include "ItemInstance.h"

class Recipes {
public:
	class Type {
	public:
		Item* item;
		uintptr_t* block;
		ItemInstance inst;
		char c;
	};
public:
	void _init();
	void addShapedRecipe(const ItemInstance&, const std::string&, const std::string&, const std::string&, const std::vector<Recipes::Type, std::allocator<Recipes::Type>>&);
};

template <class A, class B>
std::vector<Recipes::Type, std::allocator<Recipes::Type>> 
definition(char, A, char, B);

 

ItemInstance.h

#pragma once

#include <memory>

#include "Item.h"

class ItemInstance {
public:
	ItemInstance(Item const*, int);
};

 

Item.h

#pragma once

#include <string>
#include <memory>
#include <vector>
#include <unordered_map>

class Item {
public:
	char filler[200];
public:
	static Item* mItems[512];
};

 

Archived

This topic is now archived and is closed to further replies.

×
  • Create New...

Important Information

We would like to place cookies on your device to help make this website better. The website cannot give you the best user experience without cookies. You can accept or decline our cookies. You may also adjust your cookie settings. Privacy Policy - Guidelines