Jump to content
View in the app

A better way to browse. Learn more.

Tuts 4 You

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Function Pointer Member?

Featured Replies

Posted

I am trying to emulate this assembly in C++ (to make it more readable then a hacky inline assembly).

MOV EAX,DWORD PTR DS:[5D91B4]
PUSH ESI
LEA ECX,DWORD PTR DS:[EAX+89C08]
CALL 0047F3F8

So I have this psuedo code

	class MAIN
{
public:
class FUNCLIST
{
public:
bool (* FuncListContains)(int idx,bool) = (bool (*)(int,bool))0x0047EE03;
int FuncListGetItem(int idx)
{
return idx*2;
}
};
FUNCLIST* FuncList = (FUNCLIST*)(this+0x00089C08);
};
MAIN* Main = (MAIN*)0x005D91B4;

Of course this doesn't work because the function pointer isn't static.

Is there anyway to set the function pointer as a constant but keeping it as a member?

Summary:

I am injecting a dll and I want to have that assembly above as C++ so I can easily call it from my dll without a hacky inline assembly segment.

If I understood you correctly, this should work:

	class FUNCLIST
{
public:
bool (* FuncListContains)(int idx,bool);
// ....
};
FUNCLIST::FuncListContains = (bool (*)(int,bool))0x0047EE03;

Why can't you set it to static anyway?

I'm not sure if the above actually works, I think it only does with statics.

However, you can init vars in the constructor:

		class FUNCLIST
{
public:
bool (* FuncListContains)(int idx,bool)= (bool (*)(int,bool))0x0047EE03;
int FuncListGetItem(int idx)
{
return idx*2;
}
FUNCLIST() : FuncListContains((bool (*)(int,bool))0x0047EE03) {};
};
  • Author

"Why can't you set it to static anyway?"

Because, I need it to set "ECX" ("this" in C++) to the address of the classes data.

Is there any way to not use contructors? And ya the top snippet only works if it is static.

  • Author

Still not satisfied with this way but I think it will work.

static const int FuncListContainsAddr = 0x0047EE03;
bool FuncListContains(int a, int B)
{
return ((bool (*)(int,bool))FuncListContainsAddr)(a,B);
}

Edited by high6

  • Author

I guess I will have to do it like that unless I can declare a constant function pointer in a class. Forgot that a function pointer stores the destination so changing the location of "this" would break it.

  • Author

Almost works, just need to figure out how to set FuncListContains to 0x0047EE03.

	class MAIN
{
public:
char bump1[0x00089C08];
class FUNCLIST
{
public:
bool FuncListContains(int idx,bool b)
{
return ((bool (*)(int,bool))0x0047EE03)(idx,b);
}
int FuncListGetItem(int idx)
{
return idx*2;
}
};
FUNCLIST* FuncList;
};
static MAIN* Main = (MAIN*)0x005D91B4;

Would making "FuncListContains" virtual allow me to set it's address?

  • Author

why does this work

bool FuncListContains(int idx,bool b)
{
return ((bool (*)(int,bool))0x0047EE03)(idx,b);
}

But not this

bool FuncListContains(int idx,bool b)
{
return ((bool (FUNCLIST::*)(int,bool))0x0047EE03)(idx,b);
}

?

It says that it cannot typecast an int to "bool (FUNCLIST::*)(int,bool)".

Basically I want to call an address as a member without having a function pointer stored that takes up space in the classes memory.

Create an account or sign in to comment

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.