So what I had before was this;
And it was called like so;Code:int WINAPI __stdcall Func1(); int WINAPI __stdcall Func2(); int WINAPI __stdcall Func3();
This all worked fine and dandy until I added it into a class, now when I run it I get this error;Code:*(PDWORD)&Func_1= Something((DWORD)GetProcAddress(GetModuleHandleA("somedll.dll"), "function"), (DWORD)Func1, (DWORD)SomeFunc1); *(PDWORD)&Func_2= Something((DWORD)GetProcAddress(GetModuleHandleA("somedll.dll"), "function"), (DWORD)Func2, (DWORD)SomeFunc2); *(PDWORD)&Func_3= Something((DWORD)GetProcAddress(GetModuleHandleA("somedll.dll"), "function"), (DWORD)Func3, (DWORD)SomeFunc3);
I am adding them to the class header like so;Code:error C2440: 'type cast' : cannot convert from 'int (__stdcall MyClass::* )()' to 'DWORD'
Does anyone know what's wrong?Code:class MyClass { protected: private: public: int WINAPI __stdcall Func1(); int WINAPI __stdcall Func2(); int WINAPI __stdcall Func3(; };
Results 1 to 3 of 3
- 04 Mar. 2011 06:35am #1
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 0.00
[Problem] Can't seem to get this conversion working! [C++]
- 10 Mar. 2011 02:42am #2
Did you solve this? Using DLLs can be tricky some times. It's pretty obvious it's having problems casting from int to DWORD. Maybe searching in google could help, or post an example DLL and code that gives the error.
- 10 Mar. 2011 07:48am #3
- Age
- 30
- Join Date
- Nov. 2009
- Location
- Anaheim, California
- Posts
- 1,065
- Reputation
- 99
- LCash
- 0.00
I actually ended up figuring this out after studying C++ much more throughly. I was attempting to build a packet editor using a C reference (meaning the code I was looking at was in C) and it only very vaguely did what I needed, so I was really poking around in the dark. The issue was this;
i was calling the pointer of the other function (Func1) into the new function function (Something) (aka The pointer for the function) but because of the fact that the function was part of the same class it actually ends up calling the pointer for the function this->Func1 which returns the current classes pointer and the offset of the function which does not lead to the actual pointer of the function, causing problems when it attempts to recast. I am pretty sure this was the issue, I believe I ended up making a few class variables public and removing the functions from the actual class.