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 


[Question] new/delete operators
Goto page Previous  1, 2
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Tue Jan 13, 2009 7:54 pm    Post subject: Reply with quote

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
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Tue Jan 13, 2009 7:56 pm    Post subject: Reply with quote

_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
View user's profile Send private message
&Vage
Grandmaster Cheater Supreme
Reputation: 0

Joined: 25 Jul 2008
Posts: 1053

PostPosted: Tue Jan 13, 2009 8:04 pm    Post subject: Reply with quote

} catch(out_of_range & except){

"Vectors out of range"
Back to top
View user's profile Send private message
smartz993
I post too much
Reputation: 2

Joined: 20 Jun 2006
Posts: 2013
Location: USA

PostPosted: Tue Jan 13, 2009 8:16 pm    Post subject: Reply with quote

_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
View user's profile Send private message
lurc
Grandmaster Cheater Supreme
Reputation: 2

Joined: 13 Nov 2006
Posts: 1900

PostPosted: Tue Jan 13, 2009 8:27 pm    Post subject: Reply with quote

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
View user's profile Send private message
sloppy
Expert Cheater
Reputation: 0

Joined: 17 Aug 2008
Posts: 123

PostPosted: Wed Jan 14, 2009 1:37 am    Post subject: Reply with quote

_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
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Wed Jan 14, 2009 11:14 am    Post subject: Reply with quote

Maybe you want GetCurrentThread instead of GetCurrentThreadId?
Back to top
View user's profile Send private message MSN Messenger
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
Page 2 of 2

 
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