Page 2 of 2 FirstFirst 12
Results 11 to 14 of 14
  1. #11
    remka
    remka is offline
    Member-in-training remka's Avatar
    Join Date
    2010 Oct
    Location
    Moscow
    Posts
    161
    Thanks Thanks Given 
    17
    Thanks Thanks Received 
    31
    Thanked in
    6 Posts
    Rep Power
    14
    you crazy...
    Please write to the PM only at the right issues.
    or if you know what 0x90)))
    P.s.
    it's NOT NOP

  2. #12
    codeprada
    codeprada is offline
    New member codeprada's Avatar
    Join Date
    2010 Dec
    Posts
    7
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post
    Rep Power
    0
    using the EnumWindows method i posted before i realized that it created an endless loop until FALSE is returned which could be a problem. after alot of reading and trial and error i came up with a way to get the window handle of the process you've injected your DLL into.

    Code:
    #define T TEXT
    
    LONG oWndProc;
    DWORD threadID;
    HWND hijHwnd;
    
    BOOL CALLBACK WinEnum(HWND hwnd, LPARAM lParam)
    {
    	if (hwnd == NULL) 
    		MessageBox(HWND_DESKTOP, T("Error getting window"),T("Error"), MB_OK);
    	else 
    	{
    		DWORD processId;
    		GetWindowThreadProcessId(hwnd, &processId);
    		if (processId == GetCurrentProcessId()) {
    			hijHwnd = hwnd;
    			return FALSE;
    		}
    		
    	}
    
    	return TRUE;
    }
    
    DWORD WINAPI thread(LPVOID)
    {
    
    	HWND hwnd;
    	EnumWindows(WinEnum, NULL);
    	if (hijHwnd != NULL) {
    		hwnd = hijHwnd;
                    //just printing the window name just for an example
    		char *wName = (char *)malloc(sizeof(char) * MAX_PATH);
    		GetWindowText(hwnd, LPWSTR(wName), MAX_PATH); 
    		MessageBox(NULL, LPCWSTR(wName), TEXT("Window Name"), MB_OK | MB_ICONINFORMATION);
    		free(wName);
    		
    		oWndProc = SetWindowLong(hwnd, GWL_WNDPROC, (long)nWndProc); 
    		
    	}
    	return TRUE;
    
    }
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
    					 )
    {
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
    		{
    			CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)&thread, 0, 0, &threadID);			
    		}
    		break;
    	case DLL_THREAD_ATTACH:
    		{
    			
    		}
    		break;
    	case DLL_THREAD_DETACH:
    	case DLL_PROCESS_DETACH:
    		break;
    	}
    	return TRUE;
    }
    You could never break my stride, you never slowed the momentum at any moment I'm bout to blow, you'll never take my pride

  3. #13
    remka
    remka is offline
    Member-in-training remka's Avatar
    Join Date
    2010 Oct
    Location
    Moscow
    Posts
    161
    Thanks Thanks Given 
    17
    Thanks Thanks Received 
    31
    Thanked in
    6 Posts
    Rep Power
    14
    #define T TEXT -> you can use L example: std::wstring wstr=L"sample widechar text";
    Please write to the PM only at the right issues.
    or if you know what 0x90)))
    P.s.
    it's NOT NOP

  4. #14
    codeprada
    codeprada is offline
    New member codeprada's Avatar
    Join Date
    2010 Dec
    Posts
    7
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post
    Rep Power
    0
    Quote Originally Posted by remka View Post
    #define T TEXT -> you can use L example: std::wstring wstr=L"sample widechar text";
    i used TEXT because L doesn't work with Bloodshed Dev compiler. L seems to be a microsoft thing
    You could never break my stride, you never slowed the momentum at any moment I'm bout to blow, you'll never take my pride

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •