[Source] Creating Items in your Inventory

04/13/2016 20:15 RingleRangleRob#1
Important

You can't start a game with these items | it's just the part how you could create items !

[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
Code:
#include <Windows.h>
#include <process.h>
#include <stdio.h>
#include "xmlParser.h"
#include <string>
#include <sstream>

template <typename T>
bool getValueFromString(const std::string & value, T & result)  // ~ Credits to xxxx... dont remember his name
{
	std::istringstream iss(value);
	return !(iss >> result).fail();
}

DWORD dwBaseAddr = (DWORD)GetModuleHandle(0);

void *DetourFunction(BYTE *src, const BYTE *dst, const int len)
{
	BYTE *jmp = (BYTE*)malloc(len + 5);
	DWORD dwBack;

	VirtualProtect(src, len, PAGE_EXECUTE_READWRITE, &dwBack);
	memcpy(jmp, src, len);
	jmp += len;
	jmp[0] = 0xE9;
	*(DWORD*)(jmp + 1) = (DWORD)(src + len - jmp) - 5;
	src[0] = 0xE9;
	*(DWORD*)(src + 1) = (DWORD)(dst - src) - 5;
	for (int i = 5; i<len; i++)  src[i] = 0x90;
	VirtualProtect(src, len, dwBack, &dwBack);
	return (jmp - len);
}
void WriteASM(DWORD dwAddy, DWORD dwASM, int len)
{
	unsigned long Protection;
	VirtualProtect((void*)dwAddy, len, PAGE_EXECUTE_READWRITE, &Protection);
	memcpy((void*)dwAddy, (const void*)dwASM, len);
	VirtualProtect((void*)dwAddy, len, Protection, NULL);
}

DWORD Item_Create_Loop = dwBaseAddr + 0xB4B7F8;
DWORD Item_Create_Loop_End = Item_Create_Loop + 0x5C;

DWORD Call_01	= dwBaseAddr + 0xB6EEF0;
DWORD Call_02	= dwBaseAddr + 0x6535B0;

unsigned int Item_Looper = 0;
unsigned int Item_Looper_end = 0;

unsigned int ItemList	[1000][10];
unsigned int EffectList	[1000][100];

XMLNode xMainNode;
XMLNode xEffect_Node;

struct S4_Effect
{
	unsigned int effect_id;
	unsigned int unknown_1;
	unsigned int unknown_2;
	unsigned int unknown_3;
	unsigned int unknown_4;
	unsigned int unknown_5;
};
struct S4_Item
{
	unsigned long Unique_Id;
	unsigned long Position;
	unsigned long Item_Id;
	unsigned long unknown_1;
	unsigned long Perm_Type;
	unsigned long unknown_2;
	unsigned long Color_Id;
	unsigned long unknown_3;
	unsigned long unknown_4;
	unsigned long unknown_5;
	unsigned long Count_Time;
	S4_Effect	*Effect_Begin;
	S4_Effect	*Effect_End;
	unsigned long unknown_6;
	unsigned long MP_Value;
	unsigned long Entchant_Lvl;
	unsigned long unknown_7;
	unsigned long unknown_8;
};

S4_Item * Item;
S4_Item* Get_Item(int i);


__declspec(naked) void Item_Create_Detour(void)
{
	_asm
	{
		mov [Item_Looper], 00
		mov [Item_Looper_end], 00
		Reloop:
		inc [Item_Looper]
		pushad
	}
	Item_Looper_end = ItemList[0][0];
	_asm
	{
		popad
		mov eax,[Item_Looper_end]
		cmp[Item_Looper], eax
		ja Ende
		pushad
	}
	Item = Get_Item(Item_Looper);
	_asm
	{
		popad
		lea edx, [ebp-0x40]
		mov [ebp-0x20], edx
		mov eax, [ebp-0x20]
		mov [eax], 00000000
		mov ecx, [ebp-0x20]
		mov[ecx+0x04], 00000000
		mov edx, [ebp-0x20]
		mov[edx+0x08], 00000000
		mov[ebp-0x04], 00000000
		mov edx, [Item]
		lea edx, [edx]
		push edx
		mov ecx, [ebp+0x0C]
		call Call_01
		mov[ebp-0x04],0xFFFFFFFF
		lea ecx,[ebp-0x40]
		call Call_02
		jmp Reloop
		Ende:
		jmp Item_Create_Loop_End

	}
}

S4_Item* Get_Item(int i)
{
	Item = new S4_Item;
	DWORD END;

	Item->Unique_Id	= ItemList[i][0];
	Item->Position		= ItemList[i][1];
	Item->Item_Id		= ItemList[i][2];
	Item->Perm_Type	= ItemList[i][3];
	Item->Count_Time	= ItemList[i][4];
	Item->Color_Id		= ItemList[i][5];
	Item->MP_Value		= ItemList[i][6];
	Item->Entchant_Lvl = ItemList[i][7];

	int Effect_Count = EffectList[i][0];

	if (Effect_Count != 0)
	{
		S4_Effect * Effect = new S4_Effect[Effect_Count];
		END						= (DWORD)&Effect[Effect_Count];

		for (int _i = 0; _i != Effect_Count; _i++)
		{
			Effect[_i].effect_id = EffectList[i][_i+1];
		}

		Item->Effect_Begin = &Effect[0];
		Item->Effect_End	= &Effect[Effect_Count];
	}
	else
	{
		S4_Effect * Effect = new S4_Effect[0];
		END						= (DWORD)&Effect[0];

		Item->Effect_Begin	= &Effect[0];
		Item->Effect_End	= &Effect[0];
	}

	Item->unknown_1 = 0;
	Item->unknown_2 = 4;
	Item->unknown_3 = 0;
	Item->unknown_4 = 0;
	Item->unknown_5 = 0;
	Item->unknown_6 = END;
	Item->unknown_7 = 0;
	Item->unknown_8 = 0;

return Item;
}


std::string ReplaceAll(std::string str, const std::string& from, const std::string& to) // ~ Credits to xxxx... dont remember his name
{
	size_t start_pos = 0;

	while ((start_pos = str.find(from, start_pos)) != std::string::npos)
	{
		str.replace(start_pos, from.length(), to);
		start_pos += to.length(); // Handles case where 'to' is a substring of 'from'
	}
	return str;
}

void Init(void* item)
{
	TCHAR Path[255];
	GetCurrentDirectory(255, Path);

	strcat(Path, "\\FapperDev\\Item_Creator\\ItemBubble.AP");
	std::string Path_ = ReplaceAll(Path, "\\","\\\\");

	xMainNode = XMLNode::openFileHelper(Path_.c_str(), "Bubble_Struct");

	ItemList[0][0] = xMainNode.nChildNode("Item");
	int end = ItemList[0][0] + 1;

	for (int i = 1; i != end; i++)
	{
		ItemList[i][0]		= i;
		ItemList[i][1]		= 1;
		ItemList[i][2]		= atoi(xMainNode.getChildNode("Item", i-1).getAttribute("Item_ID"));
		ItemList[i][3]		= atoi(xMainNode.getChildNode("Item", i-1).getAttribute("Perm_Type"));
		ItemList[i][4]		= atoi(xMainNode.getChildNode("Item", i-1).getAttribute("Count_Time"));
		ItemList[i][5]		= atoi(xMainNode.getChildNode("Item", i-1).getAttribute("Color_ID"));
		ItemList[i][6]		= atoi(xMainNode.getChildNode("Item", i-1).getAttribute("MP"));
		ItemList[i][7]		= atoi(xMainNode.getChildNode("Item", i-1).getAttribute("Entchant_Lvl"));

		XMLNode xEffect_Node	= xMainNode.getChildNode("Item", i-1);
		int Effect_Count		= xEffect_Node.nChildNode("Effect");

		EffectList[i][0] = Effect_Count;

		if (Effect_Count != 0)
		{
			for (int _i = 0; _i != Effect_Count; _i++)
			{
				getValueFromString((char*)xEffect_Node.getChildNode("Effect", _i).getAttribute("ID"), EffectList[i][_i + 1]);
			}
		}
	}

	DetourFunction((BYTE*)Item_Create_Loop, (BYTE*)Item_Create_Detour, 0x05);
	_endthread();
}

BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpReserved)
{
	switch (fdwReason)
	{
	case DLL_PROCESS_ATTACH:
		DisableThreadLibraryCalls(hinstDLL);
		_beginthread(&Init, 0, 0);
		break;

	case DLL_THREAD_ATTACH:
		break;

	case DLL_THREAD_DETACH:
		break;

	case DLL_PROCESS_DETACH:
		break;
	}
	return TRUE;
}
XML Parser by Frank Vanden Berghen

Example XML File ->


#CE Equip File | Credits xFuRiOuS and Nociif


Credits ->
Sycode'
Nociif
xFuRiOuS
04/13/2016 20:17 Cyrex'#2
nice but the code alignment is disgusting.
and you should name your variables in a more useful manner xD
04/13/2016 20:42 lastpushed#3
Can you do a Tuto pls :)
04/13/2016 20:43 RingleRangleRob#4
Quote:
Originally Posted by lastpushed View Post
Can you do a Tuto pls :)
no.
04/13/2016 22:14 K1ramoX#5
Das hat ja echt lange gedauert bis das mal public wird :rolleyes:

PS. Für den coding stil wirst du eines Tages in der Hölle landen, das tut ja weh.

PPS: std::vector, std::shared_ptr, std::stringstream
04/13/2016 23:26 maroc2426#6
Errr!! Error 404 xD can anyone do the tutorial please ? i didn't undrestand anything :/
04/14/2016 07:16 guykild15#7
lol item creator ?
04/14/2016 10:18 Sanandreas299#8
perm?
04/14/2016 14:14 ChrisPozer#9
Work? Plz,tutorial
04/14/2016 14:39 bidjus#10
Quote:
Originally Posted by ChrisPozer View Post
Work? Plz,tutorial
It's just the source, not the programm
Btw thanks for this release
04/14/2016 15:27 devid995#11
Quote:
Originally Posted by Sycode' View Post
no.
Then you can keep your stupid source shit.
04/14/2016 15:30 정강이#12
For the people who still don't get it
[Only registered and activated users can see links. Click Here To Register...]
04/14/2016 15:48 tuaprimadd#13
Quote:
Originally Posted by devid995 View Post
Then you can keep your stupid source shit.
The ammount of pure stupidity of your comment is humongous.
04/14/2016 16:11 RingleRangleRob#14
Quote:
Originally Posted by devid995 View Post
Then you can keep your stupid source shit.
If i want to share a code i dont need to do a tutorial ...and if i create a tutorial you don't understand it :pimp:

#added CE Equip File | Credits xFuRiOuS and Nociif
04/14/2016 16:39 GohstMask#15
Tutoriel pls