| View previous topic :: View next topic |
| Author |
Message |
DebugMe Newbie cheater
Reputation: 0
Joined: 29 May 2007 Posts: 20
|
Posted: Sat Mar 08, 2008 10:04 am Post subject: TCHAR problems |
|
|
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 |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Sat Mar 08, 2008 10:16 am Post subject: |
|
|
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 |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Sat Mar 08, 2008 1:08 pm Post subject: |
|
|
Works fine for me.. no error.
_________________
- Retired. |
|
| Back to top |
|
 |
DebugMe Newbie cheater
Reputation: 0
Joined: 29 May 2007 Posts: 20
|
Posted: Sat Mar 08, 2008 5:12 pm Post subject: |
|
|
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 |
|
 |
|