| 51 | END_MSG_MAP() |
| 52 | |
| 53 | LRESULT CopyData(HWND destination_window_handle, |
| 54 | int data_size, |
| 55 | void* pointer_to_data) { |
| 56 | if (data_size > data_buffer_size) { |
| 57 | LOG(WARN) << "Destination data buffer not large enough"; |
| 58 | } |
| 59 | |
| 60 | // Copy the contents of local memory into a temporary structure |
| 61 | // for transport across the process boundary. |
| 62 | std::vector<char> buffer(data_size); |
| 63 | memcpy_s(&buffer[0], data_size, pointer_to_data, data_size); |
| 64 | |
| 65 | // Send the data across using SendMessage with the WM_COPYDATA |
| 66 | // message. N.B., the window procedure in the other process *must* |
| 67 | // have a handler for the WM_COPYDATA message, which copies the |
| 68 | // content from the message payload into a local buffer. The |
| 69 | // HookProcessor::CopyDataToBuffer method provides a common |
| 70 | // implementation to copy the data into the shared buffer location. |
| 71 | COPYDATASTRUCT data; |
| 72 | data.dwData = 1; |
| 73 | data.cbData = static_cast<int>(buffer.size()); |
| 74 | data.lpData = &buffer[0]; |
| 75 | LRESULT result = ::SendMessage(destination_window_handle, |
| 76 | WM_COPYDATA, |
| 77 | reinterpret_cast<WPARAM>(this->m_hWnd), |
| 78 | reinterpret_cast<LPARAM>(&data)); |
| 79 | return result; |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | HookProcessor::HookProcessor() { |