Jump to content

Binary functions: "GetSlotLocalPosition" & "GetSlotGlobalPosition"


Go to solution Solved by xP3NG3Rx,

Recommended Posts

Hey guys, im searching for someone who is able to "Reverse" these 2 functions for me.
why i need? because i've started to reverse Mini-Game-Rumi and these 2 functions set the position of cards.
but i wasn table to create it, so if someone is able, let me know, code and i will pay very very very good (high-price) for it!.

here is the IDA code:

GetSlotLocalPosition

int __cdecl sub_6DA930(int a1, int a2)
{
  int v3; // eax
  void *v4; // esi
  void *v5; // [esp+4h] [ebp-10h]
  int v6; // [esp+8h] [ebp-Ch]
  int v7; // [esp+Ch] [ebp-8h]
  int v8; // [esp+10h] [ebp-4h]

  if ( !(unsigned __int8)sub_6D8ED0(a2, 0, &v5) )
    return sub_6C29B0(0);
  if ( !(unsigned __int8)sub_6C28D0(a2, 1, &v6) )
    return sub_6C29B0(0);
  v3 = sub_6E07A0();
  v4 = v5;
  if ( !sub_6CBBC0(v5, v3) )
    return sub_6C29B0(0);
  sub_6E2A50(v4, v6, &v8, &v7);
  return Py_BuildValue(&unk_1BB7EA8);
}

int __thiscall sub_6E2A50(void *this, int a1, _DWORD *a2, _DWORD *a3)
{
  int result; // eax
  int v5; // eax

  result = sub_6E1CE0((int)this, a1, a1, &a1);
  if ( result )
  {
    v5 = a1;
    *a2 = *(_DWORD *)(a1 + 48);
    result = *(_DWORD *)(v5 + 52);
    *a3 = result;
  }
  return result;
}

 

GetSlotGlobalPosition
 

int __cdecl sub_6DA8A0(int a1, int a2)
{
  int v3; // eax
  int v4; // esi
  int v5; // [esp+4h] [ebp-10h]
  int v6; // [esp+8h] [ebp-Ch]
  int v7; // [esp+Ch] [ebp-8h]
  int v8; // [esp+10h] [ebp-4h]

  if ( !(unsigned __int8)sub_6D8ED0(a2, 0, &v5) )
    return sub_6C29B0(0);
  if ( !(unsigned __int8)sub_6C28D0(a2, 1, &v6) )
    return sub_6C29B0(0);
  v3 = sub_6E07A0();
  v4 = v5;
  if ( !sub_6CBBC0(v5, v3) )
    return sub_6C29B0(0);
  sub_6E2A10(v4, (int)&v7, v6, &v8, &v7);
  return Py_BuildValue(&unk_1BB7EA8);
}

int *__fastcall sub_6E2A10(int a1, int a2, int a3, _DWORD *a4, int *a5)
{
  int v5; // esi
  int *result; // eax
  int v7; // eax
  int v8; // edx

  v5 = a1;
  result = (int *)sub_6E1CE0(a1, a2, a3, &a3);
  if ( result )
  {
    v7 = a3;
    *a4 = *(_DWORD *)(v5 + 56) + *(_DWORD *)(a3 + 48);
    v8 = *(_DWORD *)(v5 + 60) + *(_DWORD *)(v7 + 52);
    result = a5;
    *a5 = v8;
  }
  return result;
}

 

 

i did myself like that:
7c1b03481d99cf5d70a1571b97b1da86.png

PyObject* wndMgrGetSlotLocalPosition(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();

	int iIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iIndex))
		return Py_BuildException();

	long lx, ly;
	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;
	pSlotWin->GetMiniGamePosition(&lx, &ly);

	return Py_BuildValue("ii", lx, ly);
}

void CWindow::GetMiniGamePosition(int index, long * plx, long * ply)
{
	*plx = mini_x[iIndex] + 48;
	*ply = mini_y[iIndex] + 52;
}




PyObject* wndMgrGetSlotGlobalPosition(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWindow;
	if (!PyTuple_GetWindow(poArgs, 0, &pWindow))
		return Py_BuildException();

	int iIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iIndex))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWindow;
	RECT& rRect = pSlotWin->GetMiniRect();
	return Py_BuildValue("ii", rRect.left, rRect.top);
}

RECT& GetMiniRect(int index)
{
	mini_rect[index].top += 48 + 56;
	mini_rect[index].left += 52 + 60;
	return mini_rect[index];
}

I know its wrong, but anyone is able? so please let me know!

Edited by Metin2 Dev
Core X - External 2 Internal
Link to comment
Share on other sites


PyObject* wndMgrGetSlotLocalPosition(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();
	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;

	RECT& rRect = pSlotWin->GetRect();

	return Py_BuildValue("ii", rRect.left, rRect.top);
}

PyObject* wndMgrGetSlotGlobalPosition(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();
	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;

	int ix, iy;

	pSlotWin->GetSlotGlobalPosition(iSlotIndex, &ix, &iy);
	return Py_BuildValue("ii", ix, iy);
}

That's what you need ?

Link to comment
Share on other sites

8 hours ago, PetePeter said:

PyObject* wndMgrGetSlotLocalPosition(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();
	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;

	RECT& rRect = pSlotWin->GetRect();

	return Py_BuildValue("ii", rRect.left, rRect.top);
}

PyObject* wndMgrGetSlotGlobalPosition(PyObject* poSelf, PyObject* poArgs)
{
	UI::CWindow* pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();
	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
		return Py_BuildException();

	UI::CSlotWindow* pSlotWin = (UI::CSlotWindow*)pWin;

	int ix, iy;

	pSlotWin->GetSlotGlobalPosition(iSlotIndex, &ix, &iy);
	return Py_BuildValue("ii", ix, iy);
}

That's what you need ?

yeah.

Link to comment
Share on other sites

  • Honorable Member
  • Solution

Firts of all I think the section is wrong where you opened the topic.
Secondly Pete's code for LocalPos is also wrong.

Here is the right one:

Spoiler
// PythonWindowManagerModule.cpp
PyObject * wndMgrGetSlotLocalPosition(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();

	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
	{
#ifdef _DEBUG
		TraceError("wndMgr.GetSlotLocalPosition : not a slot window");
#endif
		return Py_BuildException();
	}

	int iX = 0, iY = 0;
	UI::CSlotWindow * pSlotWin = (UI::CSlotWindow *)pWin;
	pSlotWin->GetSlotLocalPosition((DWORD)iSlotIndex, &iX, &iY);
	return Py_BuildValue("ii", iX, iY);
}

PyObject * wndMgrGetSlotGlobalPosition(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();

	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
	{
#ifdef _DEBUG
		TraceError("wndMgr.GetSlotGlobalPosition : not a slot window");
#endif
		return Py_BuildException();
	}

	int iX = 0, iY = 0;
	UI::CSlotWindow * pSlotWin = (UI::CSlotWindow *)pWin;
	pSlotWin->GetSlotGlobalPosition((DWORD)iSlotIndex, &iX, &iY);
	return Py_BuildValue("ii", iX, iY);
}


// PythonSlotWindow.h
		public:
			bool GetSlotLocalPosition(DWORD dwIndex, int * iX, int * iY);
			bool GetSlotGlobalPosition(DWORD dwIndex, int * iX, int * iY);

// PythonSlotWindow.cpp
bool CSlotWindow::GetSlotLocalPosition(DWORD dwIndex, int * iX, int * iY)
{
	TSlot * pSlot;
	if (!GetSlotPointer(dwIndex, &pSlot))
		return false;

	*iX = pSlot->ixPosition;
	*iY = pSlot->iyPosition;
	return true;
}

bool CSlotWindow::GetSlotGlobalPosition(DWORD dwIndex, int * iX, int * iY)
{
	TSlot * pSlot;
	if (!GetSlotPointer(dwIndex, &pSlot))
		return false;

	*iX = m_rect.left + pSlot->ixPosition;
	*iY = m_rect.top + pSlot->iyPosition;
	return true;
}

 

 

Edited by xP3NG3Rx
  • Metin2 Dev 1
  • Love 3
Link to comment
Share on other sites

47 minutes ago, xP3NG3Rx said:

Firts of all I think the section is wrong where you opened the topic.
Secondly Pete's code for LocalPos is also wrong.

Here is the right one:

  Hide contents
// PythonWindowManagerModule.cpp
PyObject * wndMgrGetSlotLocalPosition(PyObject * poSelf, PyObject * poArgs)
{
	UI::CWindow * pWin;
	if (!PyTuple_GetWindow(poArgs, 0, &pWin))
		return Py_BuildException();

	int iSlotIndex;
	if (!PyTuple_GetInteger(poArgs, 1, &iSlotIndex))
		return Py_BuildException();

	if (!pWin->IsType(UI::CSlotWindow::Type()))
	{
#ifdef _DEBUG
		TraceError("wndMgr.GetSlotLocalPosition : not a slot window");
#endif
		return Py_BuildException();
	}

	int iX = 0, iY = 0;
	UI::CSlotWindow * pSlotWin = (UI::CSlotWindow *)pWin;
	pSlotWin->GetSlotLocalPosition((DWORD)iSlotIndex, &iX, &iY);
	return Py_BuildValue("ii", iX, iY);
}

// PythonSlotWindow.h
		public:
			bool GetSlotLocalPosition(DWORD dwIndex, int * iX, int * iY);

// PythonSlotWindow.cpp
bool CSlotWindow::GetSlotLocalPosition(DWORD dwIndex, int * iX, int * iY)
{
	TSlot * pSlot;
	if (!GetSlotPointer(dwIndex, &pSlot))
		return false;

	*iX = pSlot->ixPosition;
	*iY = pSlot->iyPosition;
	return true;
}

 

 

Very nice, ty very much! 🙂

do you maybe know something about "GetSlotGlobalPosition" ?

I think this function is more difficult :S

i just use it because of the minigame Rumi - i've started to reverse, its almost done, but i dont know the function (to reverse) as well...

 

thanks for you help:)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.