 |
Cheat Engine The Official Site of Cheat Engine
|
| View previous topic :: View next topic |
| Author |
Message |
Snootae Grandmaster Cheater
Reputation: 0
Joined: 16 Dec 2006 Posts: 969 Location: --->
|
Posted: Wed Mar 26, 2008 2:50 am Post subject: C++ dll form problem |
|
|
hey guys, im trying to make a win32 gui in a dll, but i've hit a little snag
my code so far is: | Code: | #include "Includes.h"
#include "process.h"
void ShowForm( void *dummy );
void ShowForm( void *dummy ) //Thread ShowForm
{
{
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
HWND hwnd;
MSG messages;
WNDCLASSEX wincl;
/* The Window structure */
wincl.hInstance = hThisInstance;
wincl.lpszClassName = szClassName;
wincl.lpfnWndProc = WindowProcedure;
wincl.style = CS_DBLCLKS;
wincl.cbSize = sizeof (WNDCLASSEX);
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
wincl.lpszMenuName = NULL;
wincl.cbClsExtra = 0;
wincl.cbWndExtra = 0;
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
if (!RegisterClassEx (&wincl))
return 0;
hwnd = CreateWindowEx (
0,
szClassName,
"Windows App",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
544,
375,
HWND_DESKTOP,
NULL,
hThisInstance,
NULL
);
ShowWindow (hwnd, nFunsterStil);
while (GetMessage (&messages, NULL, 0, 0))
{
TranslateMessage(&messages);
DispatchMessage(&messages);
}
return messages.wParam;
}
}
_endthread();//End Thread ShowForm
} |
that doesn't work only because you cant define a function inside another, but i need to be able to call it on a thread, i need this bit:
| Code: | | ShowWindow (hwnd, nFunsterStil); |
but it needs to be able to access the values in the other function, and i cant figure out how to do that
does anyone know how i could share the nFunsterStil value/properties or another way to make this work??
bwt, im trying to just get the form to show when the dllmain process attach function is reached, so if anyone has any other ideas on how to show this form when the dll loads, please tell
_________________
|
|
| Back to top |
|
 |
Symbol I'm a spammer
Reputation: 0
Joined: 18 Apr 2007 Posts: 5094 Location: Israel.
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8585 Location: 127.0.0.1
|
Posted: Wed Mar 26, 2008 3:17 pm Post subject: |
|
|
Why are you trying to declare things inside another function? Create your message loop as its own function like normal and just pass it as a param to anyting that requires it..
| Code: | void ShowForm( void *dummy ) //Thread ShowForm
{
{
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
char szClassName[ ] = "WindowsApp";
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{ |
There is just so much wtf going on in that chunk of code lol..
Firstly:
| Code: | | LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM); |
Your function prototypes should be at the top of your source file, under the includes and any needed variable defines.
Next:
| Code: | int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil) |
This should not be in there.. You are making an injected dll, you do not need WinMain. Create a thread that calls your ShowForm function with the code thats in it.
You can obtain the hInstance of the current module using:
| Code: | | GetModuleHandle( NULL ); |
_________________
- Retired. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You can download files in this forum
|
|