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++ memory editing

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

Joined: 26 Nov 2006
Posts: 404

PostPosted: Fri Nov 14, 2008 6:31 pm    Post subject: C++ memory editing Reply with quote

So then I'm using VC++ express edition 2008 edition and when i do FindWindow, it gives me some weird error shit. Also, I want to find the process with its process name so then Minesweeper would be "winmine.exe" or something.
The section is
Code:

      HWND mine;
   private: System::Void Form1_Load(System::Object^  sender, System::EventArgs^  e) {
             mine = FindWindow(NULL,LPCWSTR("Minesweeper"));
          }

The error i'm getting is
Code:

1>wtf.obj : error LNK2028: unresolved token (0A00000F) "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "private: void __clrcall wtf::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@wtf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)
1>wtf.obj : error LNK2019: unresolved external symbol "extern "C" struct HWND__ * __stdcall FindWindowW(wchar_t const *,wchar_t const *)" (?FindWindowW@@$$J18YGPAUHWND__@@PB_W0@Z) referenced in function "private: void __clrcall wtf::Form1::Form1_Load(class System::Object ^,class System::EventArgs ^)" (?Form1_Load@Form1@wtf@@$$FA$AAMXP$AAVObject@System@@P$AAVEventArgs@4@@Z)


It compiles the code but doesn't link. thanks

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

Joined: 08 Aug 2006
Posts: 929

PostPosted: Fri Nov 14, 2008 6:41 pm    Post subject: Reply with quote

you dont need the LPCWSTR . Just have it as FindWindow( NULL, "MineSweeper" );

Also, for te process part, look into hProcessSnap etc.
Back to top
View user's profile Send private message AIM Address MSN Messenger
hacksign23
Master Cheater
Reputation: 0

Joined: 26 Nov 2006
Posts: 404

PostPosted: Fri Nov 14, 2008 7:15 pm    Post subject: Reply with quote

lol for the LPCWSTR part, it gives me an error if i don't soo... yea
_________________
Back to top
View user's profile Send private message AIM Address
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Nov 14, 2008 7:59 pm    Post subject: Reply with quote

I don't know how pinvokeing works in managed C++.

It's nasty.
Back to top
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Fri Nov 14, 2008 10:23 pm    Post subject: Reply with quote

Code:
[DllImport("user32.dll")]
extern IntPtr FindWindow(String^ lpClassName, String^ lpWindowName);

Code:
IntPtr hWnd = FindWindow(nullptr, "MineSweeper");


That should work, but why bother with interop when you can just as easily use the process class?

Code:
using namespace System::Diagnostics;

Code:
array<Process^>^ Processes = Process::GetProcessesByName("winmine");

for each(Process^ p in Processes)
{
   MessageBox::Show(p->MainWindowTitle->ToString());
}

If you are just starting out with .net, do yourself a favour and switch to c#. Managed c++ is a pain in the ass.
Back to top
View user's profile Send private message
hcavolsdsadgadsg
I'm a spammer
Reputation: 26

Joined: 11 Jun 2007
Posts: 5801

PostPosted: Fri Nov 14, 2008 11:50 pm    Post subject: Reply with quote

Yeah, managed C++ is fugly, and is no longer supported. Use native code, or C#.

You can use the process class as stated above, it will do all you need and more.
Back to top
View user's profile Send private message
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