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 


injection keeps failing
Goto page Previous  1, 2, 3
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Tue May 27, 2008 2:47 am    Post subject: Reply with quote

Didn't x0r mention it somewhere that you should use EnumProcesses for this instead of CreateToolhelp23Snapshot??? (Since EnumProcesses is faster)
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:12 am    Post subject: Reply with quote

Well along the rode I found many problems with EnumProcesses. And if I did happen to use EnumProcesses I would be checking the number of processes, which wouldn't work. Because if one process ends and another starts you have the same number, but difference processes, and then it wouldn't update. Oh, and my timer isn't working. It automatically updates every 3 seconds even when there isn't anything changed.
_________________


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
samuri25404
Grandmaster Cheater
Reputation: 7

Joined: 04 May 2007
Posts: 955
Location: Why do you care?

PostPosted: Tue May 27, 2008 10:03 am    Post subject: Reply with quote

oib111 wrote:
Well along the rode I found many problems with EnumProcesses. And if I did happen to use EnumProcesses I would be checking the number of processes, which wouldn't work. Because if one process ends and another starts you have the same number, but difference processes, and then it wouldn't update. Oh, and my timer isn't working. It automatically updates every 3 seconds even when there isn't anything changed.


Call EnumProcesses, stick the results in arrays, then compare them like I did.

_________________
Wiccaan wrote:

Oh jeez, watchout I'm a bias person! Locked.


Auto Assembly Tuts:
In Depth Tutorial on AA
Extended
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 5:10 pm    Post subject: Reply with quote

The problem with that is. Is you would have to specify different names for each string that is going to hold the name. Let me elaborate.

Code:

DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), &epByteRet);
epNumProcesses = epByteRet/sizeof(DWORD);
for(int i = 0; i<epNumProcesses; i++) {
   char bla[bla]; //problem here
}


The reason I put bla[bla] is because you can't make a difference between the variable names. I mean if you did it like this:

Code:

DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), &epByteRet);
epNumProcesses = epByteRet/sizeof(DWORD);
for(int i = 0; i<epNumProcesses; i++) {
   char procname[255];
   sprintf_s(procname, 255, "%s", epProcesses[i]);
}


Then you declare a string named procname an x amount of times which would cause a problem. And even if you could, you wouldn't be able to specify which procname variable you want to store it in.

_________________


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
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Wed May 28, 2008 3:54 am    Post subject: Reply with quote

I think you shouldn't compare the process names to check for a change. There can be multiple processes with the same names.
I would do something like this:
Code:

DWORD oldProcesses[1024], oldNumProcesses; //This contains the processes found in the previous loop. Should be global

DWORD epProcesses[1024], epByteRet, epNumProcesses;
BOOL found;
EnumProcesses(epProcesses, sizeof(epProcesses), &epByteRet);
epNumProcesses = epByteRet/sizeof(DWORD);
for(int i = 0; i<epNumProcesses; i++) {
   //Check if the pid was already in the previous array
  found = false;
  for(int j = 0; j<oldNumProcesses; j++) {
     if (epProcesses[i] == oldNumProcesses[j] ){
         found = true;
     }
  }
  if (!found){
     //The process is new, do something with it
  }
}
//Clear oldprocesses first, something like zeromemory? I don't know
zeromemory ( bla bla)
//Copy the new processes in the oldprocesses array
for(int i = 0; i<epNumProcesses; i++) {
   //move the epProcesses into oldProcesses for next loop
   oldProcesses[i] = epProcesses[i];
}
oldNumProcesses = epNumProcesses

(I'm not really good at C++ but it's something like that)
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: Wed May 28, 2008 6:28 am    Post subject: Reply with quote

Thanks tombana. I got something like this after I read you thing:

Code:

DWORD epProcesses[1024], epByteRet, epNumProcesses;
EnumProcesses(epProcesses, sizeof(epProcesses), &epByteRet);
epNumProcesses = epByteRet/sizeof(DWORD);

//all my other coding here

BOOL bFound;
int i, j;
DWORD newProcesses[1024], newByteRet, newNumProcesses;
EnumProcesses(newProcesses, sizeof(newProcesses), &newByteRet);
newNumProcesses = newByteRet/sizeof(DWORD);
for(i = 0; i<newNumProcesses; i++) {
   for(j = 0; j<epNumProcesses; j++) {
      if(newProcesses[i] == epProcesses[j]) {
         bFound = true;
      }
      else {
              bFound = false;
      }
   }
}

if(!bFound) {
   SendMessage(hList, LB_RESETCONTENT, NULL, NULL);
   ListProcess();
}

ZeroMemory(&epProcesses, sizeof(epProcesses);
for(i = 0; i<newNumProcesses; i++) {
   epProcesses[i] = newProcesses[i];
}
ZeroMemory(&newProcesses, sizeof(newProcesses);


I'm not quite sure if thats how you would use ZeroMemory on arrays, though. But when I compile it I can check it out. I do have a question, though. In this check I specifically want to check before hand to see if the process being injected into was closed or not. Since EnumProcesses returns the pid, is there an API that will get the process name by the process identifier. I tried looking up GetProcessNameById but couldn't find anything useful about it.

_________________


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
tombana
Master Cheater
Reputation: 2

Joined: 14 Jun 2007
Posts: 456
Location: The Netherlands

PostPosted: Wed May 28, 2008 7:55 am    Post subject: Reply with quote

I'm not sure, the only thing I could think of is CreateToolhelpSnapshot and loop through them but that's what you already had and it's kinda taking away the use of EnumProcesses
Back to top
View user's profile Send private message
Zand
Master Cheater
Reputation: 0

Joined: 21 Jul 2006
Posts: 424

PostPosted: Fri May 30, 2008 8:20 am    Post subject: Reply with quote

OpenProcess(), followed by EnumProcessModules(), followed by GetModuleBaseName().
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
Goto page Previous  1, 2, 3
Page 3 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