Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


[c++] Program wont open...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Sat Sep 06, 2008 9:29 am    Post subject: [c++] Program wont open... Reply with quote

#include <windows.h>
#include "stdafx.h"

#define IDC_BUTTON_hButton 43
DWORD myval;

LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);

static char gszClassName[] = "db Tutorial";
static HINSTANCE ghInstance = NULL;

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
WNDCLASSEX WndClass;
HWND hwnd;
MSG Msg;

ghInstance = hInstance;

WndClass.cbSize = sizeof(WNDCLASSEX);
WndClass.style = NULL;
WndClass.lpfnWndProc = WndProc;
WndClass.cbClsExtra = 0;
WndClass.cbWndExtra = 0;
WndClass.hInstance = ghInstance;
WndClass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
WndClass.hCursor = LoadCursor(NULL, IDC_ARROW);
WndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
WndClass.lpszMenuName = NULL;
WndClass.lpszClassName = gszClassName;
WndClass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

if(!RegisterClassEx(&WndClass)) {
MessageBox(0, "Error Registering Window!", "Error!", MB_ICONSTOP | MB_OK);
return 0;
}

hwnd = CreateWindowEx(
WS_EX_STATICEDGE,
gszClassName,
"FBiT",
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT,
320, 240,
NULL, NULL,
ghInstance,
NULL);

if(hwnd == NULL) {
MessageBox(0, "Window Creation Failed!", "OH SHIT-", MB_ICONSTOP | MB_OK);
return 0;
}

ShowWindow(hwnd, nCmdShow);
UpdateWindow(hwnd);

while(GetMessage(&Msg, NULL, 0, 0)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
}
return Msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
HWND hButton, hStatic;

switch(Message) {
case WM_CREATE:
hButton = CreateWindowEx(
NULL,
"Button",
"Button Example",
WS_BORDER | WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON,
0, 0,
110, 30,
hwnd, (HMENU)IDC_BUTTON_hButton,
ghInstance,
NULL);
//hCombo = CreateWindowEx(
// NULL,
// "ComboBox",
// "darkblue",
// WS_BORDER | WS_CHILD | WS_VISIBLE | CBS_DROPDOWNLIST,
// 0, 30,
//100, 100,
//hwnd, NULL,
//ghInstance,
//NULL);


// hEdit = CreateWindowEx(
// NULL,
// "Edit",
// "edit box example",
// WS_BORDER | WS_CHILD | WS_VISIBLE,
// 0, 60,
// 100, 30,
// hwnd, NULL,
// ghInstance,
// NULL);


// / hList = CreateWindowEx(
// NULL,
/// "ListBox",
// "db db db",
// WS_BORDER | WS_CHILD | WS_VISIBLE,
// 100, 0,
/// 100, 200,
// hwnd, NULL,
/// ghInstance,
// NULL);
// hScroll = CreateWindowEx(
// NULL,
// "ScrollBar",
// "",

hStatic = CreateWindowEx(
NULL,
"Static",
"hi",
WS_CHILD | WS_VISIBLE,
0, 31,
100, 30,
hwnd, NULL,
ghInstance,
NULL);

case WM_COMMAND:

switch(LOWORD(wParam))
{
case IDC_BUTTON_hButton:
{
// MessageBox(hwnd, "hi", "hi", MB_OK);
}
break;
}

case WM_CLOSE:
DestroyWindow(hwnd);
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
default:
return DefWindowProc(hwnd, Message, wParam, lParam);
}
return 0;
}

int poke_window(char wname[50], DWORD addr, BYTE newbyte[12],int nbyte)
{
HWND Wnd=0;
LPDWORD PID;
DWORD Proc=0;
HANDLE Hproc;

DWORD MWritte;



Wnd = FindWindow(NULL, wname); // see if it exist

if ( Wnd )
{
Proc = GetWindowThreadProcessId(Wnd,(LPDWORD) &PID); //get a PROCESS number
if (Proc)
{
Hproc= OpenProcess(PROCESS_ALL_ACCESS,NULL,(DWORD)PID);
if(Hproc)
WriteProcessMemory (Hproc, (LPVOID)addr, newbyte, nbyte,&MWritte);
}
}

return(0);
}

int poke_read(char wname[50], DWORD addr, BYTE newbyte[12],int nbyte)
{
HWND Wnd=0;
LPDWORD PID;
DWORD Proc=0;
HANDLE Hproc;




Wnd = FindWindow(NULL, wname); // see if it exist

if ( Wnd )
{
Proc = GetWindowThreadProcessId(Wnd,(LPDWORD) &PID); //get a PROCESS number
if (Proc)
{
Hproc= OpenProcess(PROCESS_ALL_ACCESS,NULL,(DWORD)PID);
if(Hproc)
ReadProcessMemory (Hproc, (LPVOID)addr, &myval, nbyte, NULL);
}
}

return(0);
}


No errors. Why does it fail to open?[/b]

_________________
Back to top
View user's profile Send private message AIM Address
kitterz
Grandmaster Cheater Supreme
Reputation: 0

Joined: 24 Dec 2007
Posts: 1268

PostPosted: Sat Sep 06, 2008 10:52 am    Post subject: Reply with quote

what do you mean by "failed to open" Please be more specific.
_________________
Back to top
View user's profile Send private message Send e-mail
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Sat Sep 06, 2008 11:24 am    Post subject: Reply with quote

You forgot to break after handling WM_CREATE.
Back to top
View user's profile Send private message
Fuzz
Grandmaster Cheater
Reputation: 0

Joined: 12 Nov 2006
Posts: 531

PostPosted: Sat Sep 06, 2008 11:54 am    Post subject: Reply with quote

Thanks Zand.
_________________
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites