Exemplo n.º 1
0
BOOL CPatch::HookFunction(long FuncToHook, long  MyHook, long* NewCallAddress, bool patch_now)
{
	BOOL retVal = FALSE;
	if(FuncToHook == MyHook) return FALSE;
	if(FuncToHook == 0 || MyHook == 0) return FALSE;


	DWORD OldProtect;
	if(VirtualProtect( reinterpret_cast<void*>(FuncToHook), 10, PAGE_READWRITE, &OldProtect ))
	{
		int rewrite_len = 0;
		m_old_jmp = 0;

		if(okToRewriteTragetInstructionSet(FuncToHook, rewrite_len))
		{
			const int long_jmp_len = 5;
			int new_instruction_set_len = rewrite_len;
			if(m_old_jmp == 0) new_instruction_set_len += long_jmp_len;
			m_PatchInstructionSet = new char[new_instruction_set_len];
			*NewCallAddress = reinterpret_cast<long>(m_PatchInstructionSet);
			m_RestorePatchSet = new char[rewrite_len];
			char InstructionSet[long_jmp_len] = {0xE9, 0x00, 0x00, 0x00, 0x00};
			ZeroMemory(m_PatchInstructionSet, new_instruction_set_len);

			//generating code
			memcpy(m_PatchInstructionSet, reinterpret_cast<char*>(FuncToHook), rewrite_len); //copy old bytes
			if(m_old_jmp == 0) m_PatchInstructionSet [rewrite_len] = 0xE9;                   //long jmp
			long jmp_new = m_old_jmp ? m_old_jmp : FuncToHook + rewrite_len;

			*reinterpret_cast<int*>(m_PatchInstructionSet + (new_instruction_set_len - long_jmp_len) + 1) =
				(jmp_new)   -    ((reinterpret_cast<long>(m_PatchInstructionSet)) + new_instruction_set_len);
													//calculate and set
													//address to jmp
													//to old function

			/////////////////////////////////
			// rewrite function
			// set a jump to my MyHook
			*reinterpret_cast<int*>(InstructionSet + 1) = MyHook - (FuncToHook + long_jmp_len);
			// rewrite original function address
			memcpy(m_RestorePatchSet, InstructionSet, rewrite_len);
			////////////////////////////////


			m_FuncToHook = FuncToHook;
			m_restore_size = rewrite_len;
			m_size = new_instruction_set_len;
			m_valid = true;

			::VirtualProtect( m_PatchInstructionSet, new_instruction_set_len, PAGE_EXECUTE_READWRITE, &m_protect);
			if(patch_now)set_patch();
			retVal = TRUE;

		}


		::VirtualProtect( reinterpret_cast<void*>(FuncToHook), 5, OldProtect, &OldProtect);
	}
	return retVal;
}
Exemplo n.º 2
0
/*****************************************************************
 * ProxySurface
 *****************************************************************/
ProxySurface::ProxySurface(Patch* p) 
{
   set_patch(p);
   _scale = 1.0;
  
   
}
Exemplo n.º 3
0
void
LoadRemotePatchWindow::present(SharedPtr<const PatchModel> patch,
                               GraphObject::Properties     data)
{
    _liststore->clear();

    set_patch(patch);
    _initial_data = data;

    cerr << "FIXME: load remote patch" << endl;
#if 0
    Sord::Model model(*App::instance().world()->rdf_world(),
                      "http://rdf.drobilla.net/ingen_patches/index.ttl",
                      "http://rdf.drobilla.net/ingen_patches/");

    Sord::Query query(*App::instance().world()->rdf_world(), Glib::ustring(
                          "SELECT DISTINCT ?name ?uri WHERE {"
                          "  ?uri a            ingen:Patch ;"
                          "       doap:name    ?name ."
                          "}"));

    SharedPtr<Sord::QueryResults> results(query.run(*App::instance().world()->rdf_world(), model));
    for (; !results->finished(); results->next()) {
        Gtk::TreeModel::iterator iter = _liststore->append();
        (*iter)[_columns._col_name] = results->get("name").to_string();
        (*iter)[_columns._col_uri]  = results->get("uri").to_string();
    }

    _treeview->columns_autosize();

    Gtk::Window::present();
#endif
}
Exemplo n.º 4
0
void netscape_10_1_win32_topmost_patch::init()
{
  /*
   * This is the call to SetWindowPos that makes the Flash Window topmost.
   * We don't want to set it to topmost but bring it to the front of the Z-Order instead.
   */
  unsigned char pattern[] = {
    0x50,                               /* push eax */
    0x57,                               /* push edi */
    0x52,                               /* push edx */
    0x6A, 0xFF,                         /* push -1 (this is HWND_TOPMOST) */
    0xFF, 0x75, 0xFC,                   /* push [ebp+hWnd] */
    0x89, 0x46, 0x30,                   /* mov [esi+30h], eax */
    0x89, 0x4E, 0x34,                   /* mov [esi+34h], ecx */
    0xFF, 0x15, 0x5C, 0xD5, 0x42, 0x10, /* call SetWindowPos */
    0x39, 0x5D, 0xFC,                   /* cmp [ebp+hWnd], ebx */
  };

  unsigned char pattern_mask[] = {
    0xFF,                               /* push eax */
    0xFF,                               /* push edi */
    0xFF,                               /* push edx */
    0xFF, 0xFF,                         /* push -1 (this is HWND_TOPMOST) */
    0xFF, 0xFF, 0x00,                   /* push [ebp+hWnd] */
    0xFF, 0xF0, 0x00,                   /* mov [esi+30h], eax */
    0xFF, 0xF0, 0x00,                   /* mov [esi+34h], ecx */
    0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, /* call SetWindowPos */
    0xFF, 0xFF, 0x00,                   /* cmp [ebp+hWnd], ebx */
  };

  set_pattern(
    utils::buffer(pattern, pattern + sizeof(pattern)),
    utils::buffer(pattern_mask, pattern_mask + sizeof(pattern_mask))
    );

  unsigned char patch[] = { PUSH_EBX, NOP };
  unsigned char patch_mask[] = { 0xFF, 0xFF };

  set_patch(
    3,
    utils::buffer(patch, patch + sizeof(patch)),
    utils::buffer(patch_mask, patch_mask + sizeof(patch_mask))
    );

  set_name("Netscape 10.1 Win32 topmost patch");
}
Exemplo n.º 5
0
void netscape_win32_patch::init()
{
  /*
   * This is the test inside the Netscape Flash player plugin that starts
   * the fullscreen window destruction routine when the player loses focus.
   */
  unsigned char pattern[] = {
    0x39, 0x9E, 0x14, 0x04, 0x00, 0x00, /* cmp [esi+addr], ebx */
    0x74, 0x47,                         /* jz short */
    0x53,                               /* push ebx */
    0x8D, 0x45,                         /* mov ecx, esi */
    0xF0, 0x50,
    0x8B, 0xCE,
    0xE8, 0x0A, 0xC3, 0xFF, 0xFF,
  };

  unsigned char pattern_mask[] = {
    0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF,
    0xFF, 0x00,
    0xFF,
    0xFF, 0xFF,
    0xFF, 0xFF,
    0xFF, 0xFF,
    0xFF, 0x00, 0x00, 0xFF, 0xFF,
  };

  set_pattern(
    utils::buffer(pattern, pattern + sizeof(pattern)),
    utils::buffer(pattern_mask, pattern_mask + sizeof(pattern_mask))
    );

  unsigned char patch[] = { JMP };
  unsigned char patch_mask[] = { 0xFF };

  set_patch(
    6,
    utils::buffer(patch, patch + sizeof(patch)),
    utils::buffer(patch_mask, patch_mask + sizeof(patch_mask))
    );

  set_name("Netscape 10.0 Win32 fullscreen patch");
}
Exemplo n.º 6
0
void netscape_win32_topmost_patch::init()
{
  /*
   * This is the call to SetWindowPos that makes the Flash Window topmost.
   * We don't want to set it to topmost but bring it to the front of the Z-Order instead.
   */
  unsigned char pattern[] = {
    0x52,                               /* push edx */
    0x50,                               /* push eax (eax is zero here) */
    0x51,                               /* push ecx */
    0x6A, 0xFF,                         /* push -1 (this is HWND_TOPMOST) */
    0x53,                               /* push ebx */
    0xFF, 0x15, 0x00, 0x00, 0x00, 0x00, /* call SetWindowPos */
    0x3B, 0x9E, 0x28, 0x10, 0x00, 0x00  /* cmp ebx, [esi+1028h] */
  };

  unsigned char pattern_mask[] = {
    0xFF,
    0xFF,
    0xFF,
    0xFF, 0xFF,
    0xFF,
    0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00,
    0xFF, 0xFF, 0x00, 0x00, 0xFF, 0xFF
  };

  set_pattern(
    utils::buffer(pattern, pattern + sizeof(pattern)),
    utils::buffer(pattern_mask, pattern_mask + sizeof(pattern_mask))
    );

  unsigned char patch[] = { PUSH_EAX, NOP };
  unsigned char patch_mask[] = { 0xFF, 0xFF };

  set_patch(
    3,
    utils::buffer(patch, patch + sizeof(patch)),
    utils::buffer(patch_mask, patch_mask + sizeof(patch_mask))
    );

  set_name("Netscape 10.0 Win32 topmost patch");
}
Exemplo n.º 7
0
void netscape_10_1_win32_patch::init()
{
  /*
   * This is the test inside the Netscape Flash player that checks for WM_KILLFOCUS
   * in fullscreen.
   */
  unsigned char pattern[] = {
    0x48,             /* dec eax */
    0x74, 0x39,       /* jz short loc_10181650 */
    0x83, 0xE8, 0x07, /* sub eax, 7 */
    0x74, 0x11,       /* jz short loc_1018162D */
    0x83, 0xE8, 0x05, /* sub eax, 5 */
    0x75, 0x13,       /* jnz short loc_10181634 */
  };

  unsigned char pattern_mask[] = {
    0xFF,
    0xFF, 0x00,
    0xFF, 0xFF, 0xFF,
    0xFF, 0x00,
    0xFF, 0xFF, 0xFF,
    0xFF, 0x00,
  };

  set_pattern(
    utils::buffer(pattern, pattern + sizeof(pattern)),
    utils::buffer(pattern_mask, pattern_mask + sizeof(pattern_mask))
    );

  unsigned char patch[] = { NOP, NOP };
  unsigned char patch_mask[] = { 0xFF, 0xFF };

  set_patch(
    1,
    utils::buffer(patch, patch + sizeof(patch)),
    utils::buffer(patch_mask, patch_mask + sizeof(patch_mask))
    );

  set_name("Netscape 10.1 Win32 fullscreen patch");
}
Exemplo n.º 8
0
 void set( value_type major, value_type minor = 0, value_type patch = 0 )
 {
     set_major( major );
     set_minor( minor );
     set_patch( patch );
 }