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 


TCHAR problems

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
DebugMe
Newbie cheater
Reputation: 0

Joined: 29 May 2007
Posts: 20

PostPosted: Sat Mar 08, 2008 10:04 am    Post subject: TCHAR problems Reply with quote

Hey guys, I'm trying to convert old application of mine to use the "tchar" library, but I ran into a problem in the fallowing code:
Code:
#include <windows.h>
#include <TCHAR.h>
#include <stdio.h>
#include <TlHelp32.h>

_TINT _tmain( void )
{
    _TINT lpPID = 0;

   _putts(_T("---------------------------------"));
   _tprintf(_T("Enter a PID: "));
   _tscanf_s(_T("%d"), &lpPID, sizeof(lpPID)/sizeof(_TINT));

   _tprintf(_T("Targeting PID: %d\n"), lpPID);
   _putts(_T("---------------------------------"));
   
        ... rest of the code here

   return EXIT_SUCCESS;
}


The code runs fine till it prints "Targeting PID: number here" and after that I get a stack corruption error =\ I've tried to fix it but no success.

The exact error it: Run-Time Check Failure #2 - Stack around the variable "lpPID" was corrupted.

Any help?
Back to top
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Sat Mar 08, 2008 10:16 am    Post subject: Reply with quote

This works fine for me...
Code:
#include <tchar.h>
#include <windows.h>
#include <iostream>

int main( int argc, char* argv )
{
   DWORD pID;
   wprintf( L"Enter a pID:\n" );
   wscanf( L"%d", &pID );
   wprintf( L"Targetting pID: %d", pID );

   std::cin.sync();
   std::cin.ignore();
   return 0;
}

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

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sat Mar 08, 2008 1:08 pm    Post subject: Reply with quote

Works fine for me.. no error.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DebugMe
Newbie cheater
Reputation: 0

Joined: 29 May 2007
Posts: 20

PostPosted: Sat Mar 08, 2008 5:12 pm    Post subject: Reply with quote

Umm weird, it was the debugger that comes with VC2005. But anyway I fixed it.

But I have another question, and I don't want to make another thread. I have this code now:
Code:
#include <windows.h>
#include <stdio.h>
#include <TCHAR.h>

_TINT lpPID;

_TINT _tmain( void )
{
   HANDLE ProcessHandle = 0;
    lpPID = 0;

   _putts(_T("---------------------------------"));
   _tprintf(_T("[<] Enter a PID: "));
   _tscanf_s(_T("%d"), &lpPID, sizeof(lpPID)/sizeof(_TINT));

   _tprintf(_T("Targeting PID: %d\n"), lpPID);
   _putts(_T("---------------------------------"));

   ProcessHandle = OpenProcess(PROCESS_ALL_ACCESS,FALSE,lpPID);

   _tprintf(_T("Process Handle: %p"), ProcessHandle);

   return EXIT_SUCCESS;

}


I use it to find processes handles, but for some reason, it always gives me the same value: 000007DC

What's wrong?
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