| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/basictypes.h" | 5 #include <stdint.h> |
| 6 |
| 6 #include "sandbox/win/src/crosscall_client.h" | 7 #include "sandbox/win/src/crosscall_client.h" |
| 7 #include "sandbox/win/src/crosscall_server.h" | 8 #include "sandbox/win/src/crosscall_server.h" |
| 8 #include "sandbox/win/src/sharedmem_ipc_client.h" | 9 #include "sandbox/win/src/sharedmem_ipc_client.h" |
| 9 #include "sandbox/win/src/sharedmem_ipc_server.h" | 10 #include "sandbox/win/src/sharedmem_ipc_server.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 12 |
| 12 namespace sandbox { | 13 namespace sandbox { |
| 13 | 14 |
| 14 // Helper function to make the fake shared memory with some | 15 // Helper function to make the fake shared memory with some |
| 15 // basic elements initialized. | 16 // basic elements initialized. |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 size_t base_start = 0; | 152 size_t base_start = 0; |
| 152 IPCControl* client_control = | 153 IPCControl* client_control = |
| 153 MakeChannels(kIPCChannelSize, 4096 * 4, &base_start); | 154 MakeChannels(kIPCChannelSize, 4096 * 4, &base_start); |
| 154 client_control->server_alive = HANDLE(1); | 155 client_control->server_alive = HANDLE(1); |
| 155 FixChannels(client_control, base_start, kIPCChannelSize, FIX_PONG_READY); | 156 FixChannels(client_control, base_start, kIPCChannelSize, FIX_PONG_READY); |
| 156 | 157 |
| 157 char* mem = reinterpret_cast<char*>(client_control); | 158 char* mem = reinterpret_cast<char*>(client_control); |
| 158 SharedMemIPCClient client(mem); | 159 SharedMemIPCClient client(mem); |
| 159 | 160 |
| 160 CrossCallReturn answer; | 161 CrossCallReturn answer; |
| 161 uint32 tag1 = 666; | 162 uint32_t tag1 = 666; |
| 162 const wchar_t *text = L"98765 - 43210"; | 163 const wchar_t *text = L"98765 - 43210"; |
| 163 base::string16 copied_text; | 164 base::string16 copied_text; |
| 164 CrossCallParamsEx* actual_params; | 165 CrossCallParamsEx* actual_params; |
| 165 | 166 |
| 166 CrossCall(client, tag1, text, &answer); | 167 CrossCall(client, tag1, text, &answer); |
| 167 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); | 168 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); |
| 168 EXPECT_EQ(1, actual_params->GetParamsCount()); | 169 EXPECT_EQ(1, actual_params->GetParamsCount()); |
| 169 EXPECT_EQ(tag1, actual_params->GetTag()); | 170 EXPECT_EQ(tag1, actual_params->GetTag()); |
| 170 EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); | 171 EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); |
| 171 EXPECT_STREQ(text, copied_text.c_str()); | 172 EXPECT_STREQ(text, copied_text.c_str()); |
| 172 | 173 |
| 173 // Check with an empty string. | 174 // Check with an empty string. |
| 174 uint32 tag2 = 777; | 175 uint32_t tag2 = 777; |
| 175 const wchar_t* null_text = NULL; | 176 const wchar_t* null_text = NULL; |
| 176 CrossCall(client, tag2, null_text, &answer); | 177 CrossCall(client, tag2, null_text, &answer); |
| 177 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); | 178 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); |
| 178 EXPECT_EQ(1, actual_params->GetParamsCount()); | 179 EXPECT_EQ(1, actual_params->GetParamsCount()); |
| 179 EXPECT_EQ(tag2, actual_params->GetTag()); | 180 EXPECT_EQ(tag2, actual_params->GetTag()); |
| 180 uint32 param_size = 1; | 181 uint32_t param_size = 1; |
| 181 ArgType type = INVALID_TYPE; | 182 ArgType type = INVALID_TYPE; |
| 182 void* param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); | 183 void* param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); |
| 183 EXPECT_TRUE(NULL != param_addr); | 184 EXPECT_TRUE(NULL != param_addr); |
| 184 EXPECT_EQ(0, param_size); | 185 EXPECT_EQ(0, param_size); |
| 185 EXPECT_EQ(WCHAR_TYPE, type); | 186 EXPECT_EQ(WCHAR_TYPE, type); |
| 186 EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); | 187 EXPECT_TRUE(actual_params->GetParameterStr(0, &copied_text)); |
| 187 | 188 |
| 188 uint32 tag3 = 888; | 189 uint32_t tag3 = 888; |
| 189 param_size = 1; | 190 param_size = 1; |
| 190 copied_text.clear(); | 191 copied_text.clear(); |
| 191 | 192 |
| 192 // Check with an empty string and a non-empty string. | 193 // Check with an empty string and a non-empty string. |
| 193 CrossCall(client, tag3, null_text, text, &answer); | 194 CrossCall(client, tag3, null_text, text, &answer); |
| 194 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); | 195 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); |
| 195 EXPECT_EQ(2, actual_params->GetParamsCount()); | 196 EXPECT_EQ(2, actual_params->GetParamsCount()); |
| 196 EXPECT_EQ(tag3, actual_params->GetTag()); | 197 EXPECT_EQ(tag3, actual_params->GetTag()); |
| 197 type = INVALID_TYPE; | 198 type = INVALID_TYPE; |
| 198 param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); | 199 param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); |
| (...skipping 27 matching lines...) Expand all Loading... |
| 226 } | 227 } |
| 227 | 228 |
| 228 TEST(IPCTest, CrossCallIntPacking) { | 229 TEST(IPCTest, CrossCallIntPacking) { |
| 229 // Check handling for regular 32 bit integers used in Windows. | 230 // Check handling for regular 32 bit integers used in Windows. |
| 230 size_t base_start = 0; | 231 size_t base_start = 0; |
| 231 IPCControl* client_control = | 232 IPCControl* client_control = |
| 232 MakeChannels(kIPCChannelSize, 4096 * 4, &base_start); | 233 MakeChannels(kIPCChannelSize, 4096 * 4, &base_start); |
| 233 client_control->server_alive = HANDLE(1); | 234 client_control->server_alive = HANDLE(1); |
| 234 FixChannels(client_control, base_start, kIPCChannelSize, FIX_PONG_READY); | 235 FixChannels(client_control, base_start, kIPCChannelSize, FIX_PONG_READY); |
| 235 | 236 |
| 236 uint32 tag1 = 999; | 237 uint32_t tag1 = 999; |
| 237 uint32 tag2 = 111; | 238 uint32_t tag2 = 111; |
| 238 const wchar_t *text = L"godzilla"; | 239 const wchar_t *text = L"godzilla"; |
| 239 CrossCallParamsEx* actual_params; | 240 CrossCallParamsEx* actual_params; |
| 240 | 241 |
| 241 char* mem = reinterpret_cast<char*>(client_control); | 242 char* mem = reinterpret_cast<char*>(client_control); |
| 242 SharedMemIPCClient client(mem); | 243 SharedMemIPCClient client(mem); |
| 243 | 244 |
| 244 CrossCallReturn answer; | 245 CrossCallReturn answer; |
| 245 DWORD dw = 0xE6578; | 246 DWORD dw = 0xE6578; |
| 246 CrossCall(client, tag2, dw, &answer); | 247 CrossCall(client, tag2, dw, &answer); |
| 247 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); | 248 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); |
| 248 EXPECT_EQ(1, actual_params->GetParamsCount()); | 249 EXPECT_EQ(1, actual_params->GetParamsCount()); |
| 249 EXPECT_EQ(tag2, actual_params->GetTag()); | 250 EXPECT_EQ(tag2, actual_params->GetTag()); |
| 250 ArgType type = INVALID_TYPE; | 251 ArgType type = INVALID_TYPE; |
| 251 uint32 param_size = 1; | 252 uint32_t param_size = 1; |
| 252 void* param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); | 253 void* param_addr = actual_params->GetRawParameter(0, ¶m_size, &type); |
| 253 ASSERT_EQ(sizeof(dw), param_size); | 254 ASSERT_EQ(sizeof(dw), param_size); |
| 254 EXPECT_EQ(UINT32_TYPE, type); | 255 EXPECT_EQ(UINT32_TYPE, type); |
| 255 ASSERT_TRUE(NULL != param_addr); | 256 ASSERT_TRUE(NULL != param_addr); |
| 256 EXPECT_EQ(0, memcmp(&dw, param_addr, param_size)); | 257 EXPECT_EQ(0, memcmp(&dw, param_addr, param_size)); |
| 257 | 258 |
| 258 // Check handling for windows HANDLES. | 259 // Check handling for windows HANDLES. |
| 259 HANDLE h = HANDLE(0x70000500); | 260 HANDLE h = HANDLE(0x70000500); |
| 260 CrossCall(client, tag1, text, h, &answer); | 261 CrossCall(client, tag1, text, h, &answer); |
| 261 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); | 262 actual_params = reinterpret_cast<CrossCallParamsEx*>(client.GetBuffer()); |
| (...skipping 30 matching lines...) Expand all Loading... |
| 292 ASSERT_TRUE(NULL != param_addr); | 293 ASSERT_TRUE(NULL != param_addr); |
| 293 EXPECT_EQ(0, memcmp(&h, param_addr, param_size)); | 294 EXPECT_EQ(0, memcmp(&h, param_addr, param_size)); |
| 294 | 295 |
| 295 CloseChannelEvents(client_control); | 296 CloseChannelEvents(client_control); |
| 296 delete[] reinterpret_cast<char*>(client_control); | 297 delete[] reinterpret_cast<char*>(client_control); |
| 297 } | 298 } |
| 298 | 299 |
| 299 TEST(IPCTest, CrossCallValidation) { | 300 TEST(IPCTest, CrossCallValidation) { |
| 300 // First a sanity test with a well formed parameter object. | 301 // First a sanity test with a well formed parameter object. |
| 301 unsigned long value = 124816; | 302 unsigned long value = 124816; |
| 302 const uint32 kTag = 33; | 303 const uint32_t kTag = 33; |
| 303 const uint32 kBufferSize = 256; | 304 const uint32_t kBufferSize = 256; |
| 304 ActualCallParams<1, kBufferSize> params_1(kTag); | 305 ActualCallParams<1, kBufferSize> params_1(kTag); |
| 305 params_1.CopyParamIn(0, &value, sizeof(value), false, UINT32_TYPE); | 306 params_1.CopyParamIn(0, &value, sizeof(value), false, UINT32_TYPE); |
| 306 void* buffer = const_cast<void*>(params_1.GetBuffer()); | 307 void* buffer = const_cast<void*>(params_1.GetBuffer()); |
| 307 | 308 |
| 308 uint32 out_size = 0; | 309 uint32_t out_size = 0; |
| 309 CrossCallParamsEx* ccp = 0; | 310 CrossCallParamsEx* ccp = 0; |
| 310 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, params_1.GetSize(), | 311 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, params_1.GetSize(), |
| 311 &out_size); | 312 &out_size); |
| 312 ASSERT_TRUE(NULL != ccp); | 313 ASSERT_TRUE(NULL != ccp); |
| 313 EXPECT_TRUE(ccp->GetBuffer() != buffer); | 314 EXPECT_TRUE(ccp->GetBuffer() != buffer); |
| 314 EXPECT_EQ(kTag, ccp->GetTag()); | 315 EXPECT_EQ(kTag, ccp->GetTag()); |
| 315 EXPECT_EQ(1, ccp->GetParamsCount()); | 316 EXPECT_EQ(1, ccp->GetParamsCount()); |
| 316 delete[] (reinterpret_cast<char*>(ccp)); | 317 delete[] (reinterpret_cast<char*>(ccp)); |
| 317 | 318 |
| 318 // Test that we handle integer overflow on the number of params | 319 // Test that we handle integer overflow on the number of params |
| 319 // correctly. We use a test-only ctor for ActualCallParams that | 320 // correctly. We use a test-only ctor for ActualCallParams that |
| 320 // allows to create malformed cross-call buffers. | 321 // allows to create malformed cross-call buffers. |
| 321 const int32 kPtrDiffSz = sizeof(ptrdiff_t); | 322 const int32_t kPtrDiffSz = sizeof(ptrdiff_t); |
| 322 for (int32 ix = -1; ix != 3; ++ix) { | 323 for (int32_t ix = -1; ix != 3; ++ix) { |
| 323 uint32 fake_num_params = (kuint32max / kPtrDiffSz) + ix; | 324 uint32_t fake_num_params = (UINT32_MAX / kPtrDiffSz) + ix; |
| 324 ActualCallParams<1, kBufferSize> params_2(kTag, fake_num_params); | 325 ActualCallParams<1, kBufferSize> params_2(kTag, fake_num_params); |
| 325 params_2.CopyParamIn(0, &value, sizeof(value), false, UINT32_TYPE); | 326 params_2.CopyParamIn(0, &value, sizeof(value), false, UINT32_TYPE); |
| 326 buffer = const_cast<void*>(params_2.GetBuffer()); | 327 buffer = const_cast<void*>(params_2.GetBuffer()); |
| 327 | 328 |
| 328 EXPECT_TRUE(NULL != buffer); | 329 EXPECT_TRUE(NULL != buffer); |
| 329 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, params_1.GetSize(), | 330 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, params_1.GetSize(), |
| 330 &out_size); | 331 &out_size); |
| 331 // If the buffer is malformed the return is NULL. | 332 // If the buffer is malformed the return is NULL. |
| 332 EXPECT_TRUE(NULL == ccp); | 333 EXPECT_TRUE(NULL == ccp); |
| 333 } | 334 } |
| 334 | 335 |
| 335 ActualCallParams<1, kBufferSize> params_3(kTag, 1); | 336 ActualCallParams<1, kBufferSize> params_3(kTag, 1); |
| 336 params_3.CopyParamIn(0, &value, sizeof(value), false, UINT32_TYPE); | 337 params_3.CopyParamIn(0, &value, sizeof(value), false, UINT32_TYPE); |
| 337 buffer = const_cast<void*>(params_3.GetBuffer()); | 338 buffer = const_cast<void*>(params_3.GetBuffer()); |
| 338 EXPECT_TRUE(NULL != buffer); | 339 EXPECT_TRUE(NULL != buffer); |
| 339 | 340 |
| 340 uint32 correct_size = params_3.OverrideSize(1); | 341 uint32_t correct_size = params_3.OverrideSize(1); |
| 341 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, kBufferSize, &out_size); | 342 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, kBufferSize, &out_size); |
| 342 EXPECT_TRUE(NULL == ccp); | 343 EXPECT_TRUE(NULL == ccp); |
| 343 | 344 |
| 344 // The correct_size is 8 bytes aligned. | 345 // The correct_size is 8 bytes aligned. |
| 345 params_3.OverrideSize(correct_size - 7); | 346 params_3.OverrideSize(correct_size - 7); |
| 346 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, kBufferSize, &out_size); | 347 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, kBufferSize, &out_size); |
| 347 EXPECT_TRUE(NULL == ccp); | 348 EXPECT_TRUE(NULL == ccp); |
| 348 | 349 |
| 349 params_3.OverrideSize(correct_size); | 350 params_3.OverrideSize(correct_size); |
| 350 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, kBufferSize, &out_size); | 351 ccp = CrossCallParamsEx::CreateFromBuffer(buffer, kBufferSize, &out_size); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 ServerEvents* events = reinterpret_cast<ServerEvents*>(param); | 383 ServerEvents* events = reinterpret_cast<ServerEvents*>(param); |
| 383 DWORD wait_result = 0; | 384 DWORD wait_result = 0; |
| 384 wait_result = ::WaitForSingleObject(events->ping, INFINITE); | 385 wait_result = ::WaitForSingleObject(events->ping, INFINITE); |
| 385 ::InterlockedExchange(events->state, kAckChannel); | 386 ::InterlockedExchange(events->state, kAckChannel); |
| 386 ::SetEvent(events->pong); | 387 ::SetEvent(events->pong); |
| 387 return wait_result; | 388 return wait_result; |
| 388 } | 389 } |
| 389 | 390 |
| 390 class CrossCallParamsMock : public CrossCallParams { | 391 class CrossCallParamsMock : public CrossCallParams { |
| 391 public: | 392 public: |
| 392 CrossCallParamsMock(uint32 tag, uint32 params_count) | 393 CrossCallParamsMock(uint32_t tag, uint32_t params_count) |
| 393 : CrossCallParams(tag, params_count) { | 394 : CrossCallParams(tag, params_count) {} |
| 394 } | |
| 395 }; | 395 }; |
| 396 | 396 |
| 397 void FakeOkAnswerInChannel(void* channel) { | 397 void FakeOkAnswerInChannel(void* channel) { |
| 398 CrossCallReturn* answer = reinterpret_cast<CrossCallReturn*>(channel); | 398 CrossCallReturn* answer = reinterpret_cast<CrossCallReturn*>(channel); |
| 399 answer->call_outcome = SBOX_ALL_OK; | 399 answer->call_outcome = SBOX_ALL_OK; |
| 400 } | 400 } |
| 401 | 401 |
| 402 // Create two threads that will quickly answer IPCs; the first one | 402 // Create two threads that will quickly answer IPCs; the first one |
| 403 // using channel 1 (channel 0 is busy) and one using channel 0. No time-out | 403 // using channel 1 (channel 0 is busy) and one using channel 0. No time-out |
| 404 // should occur. | 404 // should occur. |
| (...skipping 24 matching lines...) Expand all Loading... |
| 429 EXPECT_EQ(kFreeChannel, client_control->channels[2].state); | 429 EXPECT_EQ(kFreeChannel, client_control->channels[2].state); |
| 430 | 430 |
| 431 void* buff1 = client.GetBuffer(); | 431 void* buff1 = client.GetBuffer(); |
| 432 EXPECT_TRUE(mem + client_control->channels[1].channel_base == buff1); | 432 EXPECT_TRUE(mem + client_control->channels[1].channel_base == buff1); |
| 433 EXPECT_EQ(kBusyChannel, client_control->channels[0].state); | 433 EXPECT_EQ(kBusyChannel, client_control->channels[0].state); |
| 434 EXPECT_EQ(kBusyChannel, client_control->channels[1].state); | 434 EXPECT_EQ(kBusyChannel, client_control->channels[1].state); |
| 435 EXPECT_EQ(kFreeChannel, client_control->channels[2].state); | 435 EXPECT_EQ(kFreeChannel, client_control->channels[2].state); |
| 436 | 436 |
| 437 EXPECT_EQ(0, client_control->channels[1].ipc_tag); | 437 EXPECT_EQ(0, client_control->channels[1].ipc_tag); |
| 438 | 438 |
| 439 uint32 tag = 7654; | 439 uint32_t tag = 7654; |
| 440 CrossCallReturn answer; | 440 CrossCallReturn answer; |
| 441 CrossCallParamsMock* params1 = new(buff1) CrossCallParamsMock(tag, 1); | 441 CrossCallParamsMock* params1 = new(buff1) CrossCallParamsMock(tag, 1); |
| 442 FakeOkAnswerInChannel(buff1); | 442 FakeOkAnswerInChannel(buff1); |
| 443 | 443 |
| 444 ResultCode result = client.DoCall(params1, &answer); | 444 ResultCode result = client.DoCall(params1, &answer); |
| 445 if (SBOX_ERROR_CHANNEL_ERROR != result) | 445 if (SBOX_ERROR_CHANNEL_ERROR != result) |
| 446 client.FreeBuffer(buff1); | 446 client.FreeBuffer(buff1); |
| 447 | 447 |
| 448 EXPECT_TRUE(SBOX_ALL_OK == result); | 448 EXPECT_TRUE(SBOX_ALL_OK == result); |
| 449 EXPECT_EQ(tag, client_control->channels[1].ipc_tag); | 449 EXPECT_EQ(tag, client_control->channels[1].ipc_tag); |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 events2.pong = events.pong; | 528 events2.pong = events.pong; |
| 529 events2.mutex = client_control->server_alive; | 529 events2.mutex = client_control->server_alive; |
| 530 | 530 |
| 531 HANDLE t2 = ::CreateThread(NULL, 0, MainServerThread, &events2, 0, NULL); | 531 HANDLE t2 = ::CreateThread(NULL, 0, MainServerThread, &events2, 0, NULL); |
| 532 ASSERT_TRUE(NULL != t2); | 532 ASSERT_TRUE(NULL != t2); |
| 533 ::CloseHandle(t2); | 533 ::CloseHandle(t2); |
| 534 | 534 |
| 535 ::Sleep(1); | 535 ::Sleep(1); |
| 536 | 536 |
| 537 void* buff0 = client.GetBuffer(); | 537 void* buff0 = client.GetBuffer(); |
| 538 uint32 tag = 4321; | 538 uint32_t tag = 4321; |
| 539 CrossCallReturn answer; | 539 CrossCallReturn answer; |
| 540 CrossCallParamsMock* params1 = new(buff0) CrossCallParamsMock(tag, 1); | 540 CrossCallParamsMock* params1 = new(buff0) CrossCallParamsMock(tag, 1); |
| 541 FakeOkAnswerInChannel(buff0); | 541 FakeOkAnswerInChannel(buff0); |
| 542 | 542 |
| 543 ResultCode result = client.DoCall(params1, &answer); | 543 ResultCode result = client.DoCall(params1, &answer); |
| 544 if (SBOX_ERROR_CHANNEL_ERROR != result) | 544 if (SBOX_ERROR_CHANNEL_ERROR != result) |
| 545 client.FreeBuffer(buff0); | 545 client.FreeBuffer(buff0); |
| 546 | 546 |
| 547 EXPECT_TRUE(SBOX_ALL_OK == result); | 547 EXPECT_TRUE(SBOX_ALL_OK == result); |
| 548 EXPECT_EQ(tag, client_control->channels[0].ipc_tag); | 548 EXPECT_EQ(tag, client_control->channels[0].ipc_tag); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 563 }; | 563 }; |
| 564 | 564 |
| 565 UnitTestIPCDispatcher(); | 565 UnitTestIPCDispatcher(); |
| 566 ~UnitTestIPCDispatcher() override{}; | 566 ~UnitTestIPCDispatcher() override{}; |
| 567 | 567 |
| 568 bool SetupService(InterceptionManager* manager, int service) override { | 568 bool SetupService(InterceptionManager* manager, int service) override { |
| 569 return true; | 569 return true; |
| 570 } | 570 } |
| 571 | 571 |
| 572 private: | 572 private: |
| 573 bool CallOneHandler(IPCInfo* ipc, HANDLE p1, uint32 p2) { | 573 bool CallOneHandler(IPCInfo* ipc, HANDLE p1, uint32_t p2) { |
| 574 ipc->return_info.extended[0].handle = p1; | 574 ipc->return_info.extended[0].handle = p1; |
| 575 ipc->return_info.extended[1].unsigned_int = p2; | 575 ipc->return_info.extended[1].unsigned_int = p2; |
| 576 return true; | 576 return true; |
| 577 } | 577 } |
| 578 | 578 |
| 579 bool CallTwoHandler(IPCInfo* ipc, HANDLE p1, uint32 p2) { | 579 bool CallTwoHandler(IPCInfo* ipc, HANDLE p1, uint32_t p2) { return true; } |
| 580 return true; | |
| 581 } | |
| 582 }; | 580 }; |
| 583 | 581 |
| 584 UnitTestIPCDispatcher::UnitTestIPCDispatcher() { | 582 UnitTestIPCDispatcher::UnitTestIPCDispatcher() { |
| 585 static const IPCCall call_one = {{CALL_ONE_TAG, {VOIDPTR_TYPE, UINT32_TYPE}}, | 583 static const IPCCall call_one = {{CALL_ONE_TAG, {VOIDPTR_TYPE, UINT32_TYPE}}, |
| 586 reinterpret_cast<CallbackGeneric>( | 584 reinterpret_cast<CallbackGeneric>( |
| 587 &UnitTestIPCDispatcher::CallOneHandler)}; | 585 &UnitTestIPCDispatcher::CallOneHandler)}; |
| 588 static const IPCCall call_two = {{CALL_TWO_TAG, {VOIDPTR_TYPE, UINT32_TYPE}}, | 586 static const IPCCall call_two = {{CALL_TWO_TAG, {VOIDPTR_TYPE, UINT32_TYPE}}, |
| 589 reinterpret_cast<CallbackGeneric>( | 587 reinterpret_cast<CallbackGeneric>( |
| 590 &UnitTestIPCDispatcher::CallTwoHandler)}; | 588 &UnitTestIPCDispatcher::CallTwoHandler)}; |
| 591 ipc_calls_.push_back(call_one); | 589 ipc_calls_.push_back(call_one); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 &call_return)); | 622 &call_return)); |
| 625 EXPECT_EQ(SBOX_ALL_OK, call_return.call_outcome); | 623 EXPECT_EQ(SBOX_ALL_OK, call_return.call_outcome); |
| 626 EXPECT_TRUE(bar == call_return.extended[0].handle); | 624 EXPECT_TRUE(bar == call_return.extended[0].handle); |
| 627 EXPECT_EQ(foo, call_return.extended[1].unsigned_int); | 625 EXPECT_EQ(foo, call_return.extended[1].unsigned_int); |
| 628 | 626 |
| 629 CloseChannelEvents(client_control); | 627 CloseChannelEvents(client_control); |
| 630 delete[] reinterpret_cast<char*>(client_control); | 628 delete[] reinterpret_cast<char*>(client_control); |
| 631 } | 629 } |
| 632 | 630 |
| 633 } // namespace sandbox | 631 } // namespace sandbox |
| OLD | NEW |