| View previous topic :: View next topic |
| Author |
Message |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Tue Jan 13, 2009 7:54 pm Post subject: |
|
|
| Code: |
vector<DWORD> threads;
if( Thread32First( hThread, &Thread32) ){
do{
if(Thread32.th32OwnerProcessID == ggPID && (DWORD)hThread != GetCurrentThreadId() ){
try{
threads.push_back( Thread32.th32ThreadID );
printf("GGThreadID[%d]: %d\n", threads.size(), Thread32.th32ThreadID );
} catch(out_of_range & except){
}
}
} while( Thread32Next( hThread, &Thread32 ));
|
Errors
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Tue Jan 13, 2009 7:56 pm Post subject: |
|
|
| _void_ wrote: | | Code: |
vector<DWORD> threads;
if( Thread32First( hThread, &Thread32) ){
do{
if(Thread32.th32OwnerProcessID == ggPID && (DWORD)hThread != GetCurrentThreadId() ){
try{
threads.push_back( Thread32.th32ThreadID );
printf("GGThreadID[%d]: %d\n", threads.size(), Thread32.th32ThreadID );
} catch(out_of_range & except){
}
}
} while( Thread32Next( hThread, &Thread32 ));
|
Errors |
What are the errors?
|
|
| Back to top |
|
 |
&Vage Grandmaster Cheater Supreme
Reputation: 0
Joined: 25 Jul 2008 Posts: 1053
|
Posted: Tue Jan 13, 2009 8:04 pm Post subject: |
|
|
} catch(out_of_range & except){
"Vectors out of range"
|
|
| Back to top |
|
 |
smartz993 I post too much
Reputation: 2
Joined: 20 Jun 2006 Posts: 2013 Location: USA
|
Posted: Tue Jan 13, 2009 8:16 pm Post subject: |
|
|
| _void_ wrote: | } catch(out_of_range & except){
"Vectors out of range" |
But it doesn't give errors if you resize it first?
Why are you using vectors for storing handles to GG's threads anyway..you know there are 26 (or 21 or something), why not just make allocate some memory that's 30*sizeof(DWORD)..easier..
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Tue Jan 13, 2009 8:27 pm Post subject: |
|
|
Why don't you use pointers and HeapAlloc/HeapReAlloc instead of gay vectors. Just add a counter in the loop, HeapReAlloc to sizeof(DWORD)*Count+1 then do your assignments, then just inc the counter.
_________________
|
|
| Back to top |
|
 |
sloppy Expert Cheater
Reputation: 0
Joined: 17 Aug 2008 Posts: 123
|
Posted: Wed Jan 14, 2009 1:37 am Post subject: |
|
|
| _void_ wrote: | | Code: |
vector<DWORD> threads;
if( Thread32First( hThread, &Thread32) ){
do{
if(Thread32.th32OwnerProcessID == ggPID && (DWORD)hThread != GetCurrentThreadId() ){
try{
threads.push_back( Thread32.th32ThreadID );
printf("GGThreadID[%d]: %d\n", threads.size(), Thread32.th32ThreadID );
} catch(out_of_range & except){
}
}
} while( Thread32Next( hThread, &Thread32 ));
|
Errors |
vector.push_back() reallocates space if required, it will not throw an out of range exception. Your error is elsewhere.
The above code worked fine for me. Though I do wonder why you are comparing a snapshot handle to the current thread id? and are you just assuming no output means out of range has been caught? Did you set the size member of the thread entry structure?
|
|
| Back to top |
|
 |
Noz3001 I'm a spammer
Reputation: 26
Joined: 29 May 2006 Posts: 6220 Location: /dev/null
|
Posted: Wed Jan 14, 2009 11:14 am Post subject: |
|
|
| Maybe you want GetCurrentThread instead of GetCurrentThreadId?
|
|
| Back to top |
|
 |
|