need some help from pro coder

Technical Discussions not Related Directly to MHS. For Example, Coding, Hex Editing, General Hacking, Etc.

Moderators: g3nuin3, SpeedWing, WhiteHat

need some help from pro coder

Postby Petani » Thu Dec 30, 2010 4:08 pm

while(ProcessId==0)
{
Sleep10;
ProcessId=FindProcessId("someapplication");
if(inkey()[0]!=0)
{
fflush(stdout);
ExitProcess(0);
}
}
hProcess=OpenProcess(PROCESS_ALL_ACCESS,FALSE,ProcessId);
TerminateProcess(hProcess,0);
CloseHandle(hProcess);
ProcessId=0;
while(ProcessId==0)
{
Sleep10;
ProcessId=FindProcess("someapplication");
if(inkey()[0]!=0)
{
fflush(stdout);
ExitProcess(0);
}
}


is there any possibility for me to rechange Findprocess to FindWindow by editing this line ~>ProcessId=FindProcess("someapplication"); to ProcessId=FindWindow(NULL, La La La");
Image
User avatar
Petani
I Know My Poop
 
Posts: 476
Joined: Sat Jan 26, 2008 7:43 pm
Location: Battle Ground

Re: need some help from pro coder

Postby L. Spiro » Thu Dec 30, 2010 6:10 pm

Code: Select all
DWORD ProcessIdByWindowTitle( LPCTSTR _lpWindowName ) {
   if ( !_lpWindowName || _lpWindowName[0] == _T( '\0' ) ) { return 0UL; }
   // Walk over every thread.
   HANDLE hThreadSnap = ::CreateToolhelp32Snapshot( TH32CS_SNAPTHREAD, 0 );
   if ( hThreadSnap == INVALID_HANDLE_VALUE ) {
      return 0UL;
   }

   // Copy the window name to a writeable buffer.
   _TCHAR * ptcCopy = ::StrDup( _lpWindowName );

   THREADENTRY32 te32Thread;
   te32Thread.dwSize = sizeof( THREADENTRY32 );

   if ( !::Thread32First( hThreadSnap, &te32 ) ) {
      ::CloseHandle( hThreadSnap );
      ::LocalFree( ptcCopy );
      return 0UL;
   }

   do {
      // Enumerate its windows.
      ::EnumThreadWindows( te32.th32ThreadID, EnumThreadWndowProc, ptcCopy );
      if ( ptcCopy[0] == _T( '\0' ) ) {
         // Found it.
         ::CloseHandle( hThreadSnap );
         ::LocalFree( ptcCopy );
         return te32Thread.th32OwnerProcessID;
      }
   } while ( ::Thread32Next( hThreadSnap, &te32Thread ) );

   ::CloseHandle( hThreadSnap );
   ::LocalFree( ptcCopy );

   return 0UL;
}



BOOL CALLBACK EnumThreadWndowProc( HWND _hWnd, LPARAM _lParam ) {
   int iLen = ::GetWindowTextLength( _hWnd ) + 1;
   _TCHAR * ptcText = new _TCHAR[iLen];
   ::GetWindowText( _hWnd, ptcText, iLen );

   _TCHAR * ptcCheckMe = reinterpret_cast<_TCHAR *>(_lParam);
   int iRet = ::StrCmp( ptcText, ptcCheckMe );   // This is NOT ::strcmp().
   // Tell the outside world we found the target process by modifying the input string buffer.
   //   Buffer must be at least 1 character in length, always, and not read-only.
   //   This is why ProcessIdByWindowTitle() creates a copy of the input name and passes that
   //   to this function.
   if ( iRet == 0 ) {
      ptcCheckMe[0] = _T( '\0' );   // NULL the first character.
   }

   delete [] ptcText;
   return iRet != 0;
}



L. Spiro
Our songs remind you of songs you’ve never heard.
User avatar
L. Spiro
L. Spiro
 
Posts: 3127
Joined: Mon Jul 17, 2006 10:14 pm
Location: Tokyo, Japan

Re: need some help from pro coder

Postby Petani » Thu Dec 30, 2010 11:45 pm

thx alot
Image
User avatar
Petani
I Know My Poop
 
Posts: 476
Joined: Sat Jan 26, 2008 7:43 pm
Location: Battle Ground


Return to Technical Unrelated

Who is online

Users browsing this forum: No registered users and 1 guest

cron