hi, following code cant open all process also gives error in InjectLibrarry() why?
void main()
{
HANDLE hProcess;
DWORD procID[1024];
DWORD noOfProcs;
DWORD szretrn;
int i=0,j=1;
LPTSTR procName;
char szPName[100];
EnumProcesses(procID,sizeof(procID),&szretrn);
noOfProcs=szretrn/sizeof(DWORD);
SetDebugPrivileges();
SetLastError(0);
for (i = 0; i< noOfProcs; i++)
{
if( procID != 0 )
{
hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,procID);
DWORD err=GetLastError();
//printf("%d",err);
if(hProcess)
{
//GetClassName((HWND)hProcess,procName,sizeof(procName));
GetModuleBaseName(hProcess,NULL,szPName,sizeof(szPName));
printf("Process Name %s\n",szPName);
if(strcmp(szPName,"EuWatch.exe")==0)
{
InjectLibrary("DLLInjection.dll",hProcess,7000);
cout<<"find"<<endl;
}
}
else
{
printf("Process cant open %d\n",procID);
}
//printf("%s",procName);
//InjectLibrary("DLLInjection.dll",hProcess,7000);
}
}
}
void SetDebugPrivileges()
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges( hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL )!= FALSE)
{
printf("successfully changed token privilages\n");
}
else
{
printf("problem during changing token privilages\n");
}
CloseHandle( hToken );
}
http://img.tomshardware.com/forum/uk/icones/smilies/wahoo.gif
void main()
{
HANDLE hProcess;
DWORD procID[1024];
DWORD noOfProcs;
DWORD szretrn;
int i=0,j=1;
LPTSTR procName;
char szPName[100];
EnumProcesses(procID,sizeof(procID),&szretrn);
noOfProcs=szretrn/sizeof(DWORD);
SetDebugPrivileges();
SetLastError(0);
for (i = 0; i< noOfProcs; i++)
{
if( procID != 0 )
{
hProcess=OpenProcess(PROCESS_ALL_ACCESS,false,procID);
DWORD err=GetLastError();
//printf("%d",err);
if(hProcess)
{
//GetClassName((HWND)hProcess,procName,sizeof(procName));
GetModuleBaseName(hProcess,NULL,szPName,sizeof(szPName));
printf("Process Name %s\n",szPName);
if(strcmp(szPName,"EuWatch.exe")==0)
{
InjectLibrary("DLLInjection.dll",hProcess,7000);
cout<<"find"<<endl;
}
}
else
{
printf("Process cant open %d\n",procID);
}
//printf("%s",procName);
//InjectLibrary("DLLInjection.dll",hProcess,7000);
}
}
}
void SetDebugPrivileges()
{
HANDLE hToken;
LUID sedebugnameValue;
TOKEN_PRIVILEGES tkp;
OpenProcessToken( GetCurrentProcess(),
TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken );
LookupPrivilegeValue( NULL, SE_DEBUG_NAME, &sedebugnameValue );
tkp.PrivilegeCount = 1;
tkp.Privileges[0].Luid = sedebugnameValue;
tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if(AdjustTokenPrivileges( hToken, FALSE, &tkp, sizeof(tkp), NULL, NULL )!= FALSE)
{
printf("successfully changed token privilages\n");
}
else
{
printf("problem during changing token privilages\n");
}
CloseHandle( hToken );
}
http://img.tomshardware.com/forum/uk/icones/smilies/wahoo.gif