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++] A few little noobie questions XD
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue May 27, 2008 8:01 am    Post subject: Reply with quote

well if string compare isnt working you could always do individual character checking in a loop.

Code:
BOOL PasswordCmp( char *Password )
{
    char *szPass = "123";
    for ( int i = 0; i <= strlen(Password); i++ )
    {
        if ( Password[i] != szPass[i] ) return FALSE;
    }
    return TRUE;
}

_________________
Back to top
View user's profile Send private message
Symbol
I'm a spammer
Reputation: 0

Joined: 18 Apr 2007
Posts: 5094
Location: Israel.

PostPosted: Tue May 27, 2008 8:05 am    Post subject: Reply with quote

lurc wrote:
well if string compare isnt working you could always do individual character checking in a loop.

Code:
BOOL PasswordCmp( char *Password )
{
    char *szPass = "123";
    for ( int i = 0; i <= strlen(Password); i++ )
    {
        if ( Password[i] != szPass[i] ) return FALSE;
    }
    return TRUE;
}

< instead of <=
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 8:30 am    Post subject: Reply with quote

now it's says YES any time "123" is in the string even if the string goes like: "333123333" or "1223" and stuff :O
_________________
Stylo
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue May 27, 2008 8:40 am    Post subject: Reply with quote

Here's how I would do it.

Code:

char *pword;
int len = GetWindowTextLength(GetDlgItem(hwnd, IDC_PWORD_EDIT));
if(len > 0) {
   pword = (char*)GlobalAlloc(GPTR, len+1);
   GetDlgItemText(hwnd, IDC_PWORD_EDIT, pword, len+1);
   if(strcmp(pword, "123") == 0) {
      MessageBox(NULL, "Correct Password!", "Correct", MB_OK);
   }
   else {
      MessageBox(NULL, "Incorrect Password!", "Incorrect", MB_OK);
   }
}

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 8:53 am    Post subject: Reply with quote

i dont think that'll help me cuz the problem is where i use strcmp function
i dont need other ways to get the text inside a variable

_________________
Stylo
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue May 27, 2008 8:59 am    Post subject: Reply with quote

Try putting "123" in a variable?
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 9:04 am    Post subject: Reply with quote

it's saying YES all the time now lol this went all crazy XDDD
and if i'm comparing "123" with "123" it's says NO XDDDD
it's screwed lol

_________________
Stylo
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue May 27, 2008 9:05 am    Post subject: Reply with quote

I'll try making something when I get home lol.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 9:05 am    Post subject: Reply with quote

k thanks bro.
i'll work on it till you'll come home maybe i'll figure something out Surprised

btw about the password characters when i use the passwordChars message or whatever it is so all i can write inside the textbox is capital letters
what's wrong?

that's my code:
Code:

hPassword = CreateWindowEx(NULL,L"EDIT",L"",WS_CHILD | WS_BORDER | WS_VISIBLE | EM_SETPASSWORDCHAR,10,35,150,22,hwnd,(HMENU)IDC_PASS_EDIT,GetModuleHandle(NULL),NULL);


oh oops XD
now i opened msdn and saw the correct syntax of SETPASSWORDCHARS

_________________
Stylo
Back to top
View user's profile Send private message
Ferocious
Advanced Cheater
Reputation: 0

Joined: 06 Feb 2008
Posts: 54

PostPosted: Tue May 27, 2008 9:36 am    Post subject: Reply with quote

get , Visual Assist X it won't get you wrong on the parameters anymore.

it's not a freeware, so goodluck on finding cracked version of it.

_________________
I wanna hack, but I don't know how...
Back to top
View user's profile Send private message
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 9:39 am    Post subject: Reply with quote

i didnt have a wrong parameters i just used the message wrong inside a wrong function
_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Tue May 27, 2008 4:36 pm    Post subject: Reply with quote

Ferocious wrote:
get , Visual Assist X it won't get you wrong on the parameters anymore.

it's not a freeware, so goodluck on finding cracked version of it.


Uhg, when SunBeam started programming to learn C/C++ he got this program to test it out. We had so many issues with it. It caused nothing but more head aches then what it did to help. It messes up the IDE integrated intellisense and breaks their own and causes it to either not show up, stop working at random, or just crashes Visual Studio. The coloring additions it added to the code also tended to randomly mess up and cause things to look incorrect or look misspelled and such. From personal experience, I would say avoid that with all costs. :s

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Tue May 27, 2008 5:19 pm    Post subject: Reply with quote

It also doesn't work on any Express Editions of Visual Studio. And seeing as you (I assume) have the Express Edition, it won't work.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Stylo
Grandmaster Cheater Supreme
Reputation: 3

Joined: 16 May 2007
Posts: 1073
Location: Israel

PostPosted: Tue May 27, 2008 9:46 pm    Post subject: Reply with quote

well guys i tryied all i can :[ all i want is to compare two strings and ask if they're equal
what's wrong with this code :[ why does he keep saying that the strings are not equal

_________________
Stylo
Back to top
View user's profile Send private message
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8588
Location: 127.0.0.1

PostPosted: Tue May 27, 2008 11:13 pm    Post subject: Reply with quote

Heres a quick example I just wrote. Set the compiler to multi-byte and compile:

Code:
#include <windows.h>
#include <tchar.h>

#define IDC_PASSWORD   1000
#define IDC_CHECKPASS   1001

HWND   m_hWnd         = NULL;
HWND   m_hWndPassword   = NULL;

TCHAR   *tszWindowName   = _T( "Some Random Window" );
TCHAR   *tszClassName   = _T( "clswnd_checkPass" );


void CheckPassword( HWND hWnd )
{
   TCHAR *tszRealPassword = _T( "ThISisTHErEaL PASSworD" );

   int iPassLength = GetWindowTextLength( GetDlgItem( hWnd, IDC_PASSWORD ) );

   // Don't bother checking blank passwords..
   if( iPassLength == 0 )
      return;

   // Create A Buffer To Hold The Password
   TCHAR *tszEnteredPassword = (TCHAR*)GlobalAlloc( GPTR, (iPassLength * sizeof(TCHAR)) + 1 );

   // Copy The Textbox Containts To Our Buffer
   GetDlgItemText( hWnd, IDC_PASSWORD, tszEnteredPassword, (iPassLength * sizeof(TCHAR)) + 1 );

   // Compare Without Checking Case
   if( _tcsncicmp( tszRealPassword, tszEnteredPassword, iPassLength ) == 0 )
      MessageBox( hWnd, _T("Passwords matched."), _T("Success!"), MB_OK|MB_ICONINFORMATION );
   else
      MessageBox( hWnd, _T("Passwords did not matched."), _T("Error!"), MB_OK|MB_ICONINFORMATION );

   // Free The Buffer
   GlobalFree( tszEnteredPassword );
}

LRESULT CALLBACK WndProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam )
{
   switch( uMsg )
   {
   case WM_CREATE:
      m_hWndPassword = CreateWindowEx( NULL, _T("EDIT"), NULL, WS_CHILD|WS_BORDER|WS_VISIBLE|ES_AUTOHSCROLL, 10, 35, 150, 22, hWnd, (HMENU)IDC_PASSWORD, NULL, NULL );
      CreateWindowEx( NULL, _T("BUTTON"), _T("Check"), WS_CHILD|WS_BORDER|WS_VISIBLE|BS_FLAT, 84, 60, 75, 20, hWnd, (HMENU)IDC_CHECKPASS, NULL, NULL );
      break;

   case WM_COMMAND:
      switch( wParam )
      {
      case IDC_CHECKPASS:
         CheckPassword( hWnd );
         break;
      }
      break;

   case WM_CLOSE:
   case WM_DESTROY:
      PostQuitMessage( 0 );
      break;
   default:
      return DefWindowProc( hWnd, uMsg, wParam, lParam );
   }
   return 0;
}

int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd )
{
   UNREFERENCED_PARAMETER( hPrevInstance );
   UNREFERENCED_PARAMETER( lpCmdLine );
   UNREFERENCED_PARAMETER( nShowCmd );

   WNDCLASSEX wc      = {0};
   wc.cbSize         = sizeof(WNDCLASSEX);
   wc.style         = CS_HREDRAW | CS_VREDRAW | CS_BYTEALIGNWINDOW;
   wc.lpfnWndProc      = (WNDPROC)WndProc;
   wc.cbClsExtra      = NULL;
   wc.cbWndExtra      = NULL;
   wc.hInstance      = hInstance;
   wc.hbrBackground   = (HBRUSH)COLOR_BACKGROUND;
   wc.lpszMenuName      = NULL;
   wc.lpszClassName   = tszClassName;
   wc.hIcon         = NULL;
   wc.hIconSm         = NULL;
   wc.hCursor         = LoadCursor( NULL, IDC_ARROW );

   if( !RegisterClassEx( &wc ) )
      return 0;

   m_hWnd = CreateWindowEx( NULL, tszClassName, tszWindowName, WS_OVERLAPPEDWINDOW,0,0,180,125, NULL, NULL, hInstance, NULL );
   if( !m_hWnd )
   {
      UnregisterClass( tszClassName, hInstance );
      return 0;
   }

   UpdateWindow( m_hWnd );
   ShowWindow( m_hWnd, SW_SHOWNORMAL );

   MSG uMsg = {0};
   while( GetMessage( &uMsg, NULL, NULL, NULL ) )
   {
      TranslateMessage( &uMsg );
      DispatchMessage( &uMsg );
   }

   UnregisterClass( tszClassName, hInstance );
   return 0;
}

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
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