OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 // WARNING this file was generated by generate_monacl_bindings.py |
| 6 // Do not edit by hand. |
| 7 |
| 8 #include "mojo/monacl/mojo_syscall.h" |
| 9 |
| 10 #include <stdio.h> |
| 11 |
| 12 #include "mojo/public/c/system/core.h" |
| 13 #include "native_client/src/public/nacl_app.h" |
| 14 #include "native_client/src/trusted/desc/nacl_desc_custom.h" |
| 15 #include "native_client/src/trusted/service_runtime/nacl_copy.h" |
| 16 #include "native_client/src/trusted/service_runtime/sel_ldr.h" |
| 17 |
| 18 static INLINE uintptr_t NaClUserToSysAddrArray( |
| 19 struct NaClApp *nap, |
| 20 uintptr_t uaddr, |
| 21 size_t count, |
| 22 size_t size) { |
| 23 // TODO overflow checking |
| 24 size_t range = count * size; |
| 25 return NaClUserToSysAddrRange(nap, uaddr, range); |
| 26 } |
| 27 |
| 28 void MojoDescDestroy(void *handle) { |
| 29 UNREFERENCED_PARAMETER(handle); |
| 30 } |
| 31 |
| 32 ssize_t MojoDescSendMsg(void *handle, |
| 33 const struct NaClImcTypedMsgHdr *msg, |
| 34 int flags) { |
| 35 UNREFERENCED_PARAMETER(flags); |
| 36 |
| 37 struct NaClApp *nap = static_cast<struct NaClApp*>(handle); |
| 38 |
| 39 if (msg->iov_length != 1 || msg->iov[0].length < 8 || msg->ndesc_length != 0)
{ |
| 40 return -1; |
| 41 } |
| 42 |
| 43 uint32_t *params = static_cast<uint32_t*>(msg->iov[0].base); |
| 44 uint32_t numParams = msg->iov[0].length / sizeof(*params); |
| 45 |
| 46 uint32_t msgType = params[0]; |
| 47 switch (msgType) { |
| 48 case 0: |
| 49 { |
| 50 if (numParams != 5) { |
| 51 return -1; |
| 52 } |
| 53 NaClCopyTakeLock(nap); |
| 54 const struct MojoCreateSharedBufferOptions* options; |
| 55 if (params[1] == 0) { |
| 56 options = NULL; |
| 57 } else { |
| 58 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(*options)
); |
| 59 if (temp == kNaClBadAddress) { |
| 60 return -1; |
| 61 } |
| 62 options = reinterpret_cast<const struct MojoCreateSharedBufferOptions*>(
temp); |
| 63 } |
| 64 uint64_t num_bytes; |
| 65 if (params[2] == 0) { |
| 66 return -1; |
| 67 } else { |
| 68 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(num_bytes
)); |
| 69 if (temp == kNaClBadAddress) { |
| 70 return -1; |
| 71 } |
| 72 num_bytes = *reinterpret_cast<uint64_t volatile*>(temp); |
| 73 } |
| 74 MojoHandle* shared_buffer_handle_ptr; |
| 75 MojoHandle shared_buffer_handle; |
| 76 if (params[3] == 0) { |
| 77 return -1; |
| 78 } else { |
| 79 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(shared_bu
ffer_handle)); |
| 80 if (temp == kNaClBadAddress) { |
| 81 return -1; |
| 82 } |
| 83 shared_buffer_handle_ptr = reinterpret_cast<MojoHandle*>(temp); |
| 84 } |
| 85 MojoResult* result_ptr; |
| 86 MojoResult result; |
| 87 if (params[4] == 0) { |
| 88 return -1; |
| 89 } else { |
| 90 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(result)); |
| 91 if (temp == kNaClBadAddress) { |
| 92 return -1; |
| 93 } |
| 94 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 95 } |
| 96 NaClCopyDropLock(nap); |
| 97 |
| 98 result = MojoCreateSharedBuffer(options, num_bytes, &shared_buffer_handle)
; |
| 99 |
| 100 NaClCopyTakeLock(nap); |
| 101 *shared_buffer_handle_ptr = shared_buffer_handle; |
| 102 *result_ptr = result; |
| 103 NaClCopyDropLock(nap); |
| 104 |
| 105 return 0; |
| 106 } |
| 107 case 1: |
| 108 { |
| 109 if (numParams != 5) { |
| 110 return -1; |
| 111 } |
| 112 NaClCopyTakeLock(nap); |
| 113 MojoHandle buffer_handle; |
| 114 if (params[1] == 0) { |
| 115 return -1; |
| 116 } else { |
| 117 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(buffer_ha
ndle)); |
| 118 if (temp == kNaClBadAddress) { |
| 119 return -1; |
| 120 } |
| 121 buffer_handle = *reinterpret_cast<MojoHandle volatile*>(temp); |
| 122 } |
| 123 const struct MojoDuplicateBufferHandleOptions* options; |
| 124 if (params[2] == 0) { |
| 125 options = NULL; |
| 126 } else { |
| 127 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(*options)
); |
| 128 if (temp == kNaClBadAddress) { |
| 129 return -1; |
| 130 } |
| 131 options = reinterpret_cast<const struct MojoDuplicateBufferHandleOptions
*>(temp); |
| 132 } |
| 133 MojoHandle* new_buffer_handle_ptr; |
| 134 MojoHandle new_buffer_handle; |
| 135 if (params[3] == 0) { |
| 136 return -1; |
| 137 } else { |
| 138 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(new_buffe
r_handle)); |
| 139 if (temp == kNaClBadAddress) { |
| 140 return -1; |
| 141 } |
| 142 new_buffer_handle_ptr = reinterpret_cast<MojoHandle*>(temp); |
| 143 } |
| 144 MojoResult* result_ptr; |
| 145 MojoResult result; |
| 146 if (params[4] == 0) { |
| 147 return -1; |
| 148 } else { |
| 149 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(result)); |
| 150 if (temp == kNaClBadAddress) { |
| 151 return -1; |
| 152 } |
| 153 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 154 } |
| 155 NaClCopyDropLock(nap); |
| 156 |
| 157 result = MojoDuplicateBufferHandle(buffer_handle, options, &new_buffer_han
dle); |
| 158 |
| 159 NaClCopyTakeLock(nap); |
| 160 *new_buffer_handle_ptr = new_buffer_handle; |
| 161 *result_ptr = result; |
| 162 NaClCopyDropLock(nap); |
| 163 |
| 164 return 0; |
| 165 } |
| 166 case 2: |
| 167 { |
| 168 if (numParams != 7) { |
| 169 return -1; |
| 170 } |
| 171 NaClCopyTakeLock(nap); |
| 172 MojoHandle buffer_handle; |
| 173 if (params[1] == 0) { |
| 174 return -1; |
| 175 } else { |
| 176 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(buffer_ha
ndle)); |
| 177 if (temp == kNaClBadAddress) { |
| 178 return -1; |
| 179 } |
| 180 buffer_handle = *reinterpret_cast<MojoHandle volatile*>(temp); |
| 181 } |
| 182 uint64_t offset; |
| 183 if (params[2] == 0) { |
| 184 return -1; |
| 185 } else { |
| 186 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(offset)); |
| 187 if (temp == kNaClBadAddress) { |
| 188 return -1; |
| 189 } |
| 190 offset = *reinterpret_cast<uint64_t volatile*>(temp); |
| 191 } |
| 192 uint64_t num_bytes; |
| 193 if (params[3] == 0) { |
| 194 return -1; |
| 195 } else { |
| 196 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(num_bytes
)); |
| 197 if (temp == kNaClBadAddress) { |
| 198 return -1; |
| 199 } |
| 200 num_bytes = *reinterpret_cast<uint64_t volatile*>(temp); |
| 201 } |
| 202 void** buffer_ptr; |
| 203 void* buffer; |
| 204 if (params[4] == 0) { |
| 205 return -1; |
| 206 } else { |
| 207 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(buffer)); |
| 208 if (temp == kNaClBadAddress) { |
| 209 return -1; |
| 210 } |
| 211 buffer_ptr = reinterpret_cast<void**>(temp); |
| 212 } |
| 213 MojoMapBufferFlags flags; |
| 214 if (params[5] == 0) { |
| 215 return -1; |
| 216 } else { |
| 217 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(flags)); |
| 218 if (temp == kNaClBadAddress) { |
| 219 return -1; |
| 220 } |
| 221 flags = *reinterpret_cast<MojoMapBufferFlags volatile*>(temp); |
| 222 } |
| 223 MojoResult* result_ptr; |
| 224 MojoResult result; |
| 225 if (params[6] == 0) { |
| 226 return -1; |
| 227 } else { |
| 228 uintptr_t temp = NaClUserToSysAddrRange(nap, params[6], sizeof(result)); |
| 229 if (temp == kNaClBadAddress) { |
| 230 return -1; |
| 231 } |
| 232 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 233 } |
| 234 NaClCopyDropLock(nap); |
| 235 |
| 236 result = MojoMapBuffer(buffer_handle, offset, num_bytes, &buffer, flags); |
| 237 |
| 238 NaClCopyTakeLock(nap); |
| 239 *buffer_ptr = buffer; |
| 240 *result_ptr = result; |
| 241 NaClCopyDropLock(nap); |
| 242 |
| 243 return 0; |
| 244 } |
| 245 case 3: |
| 246 { |
| 247 if (numParams != 3) { |
| 248 return -1; |
| 249 } |
| 250 NaClCopyTakeLock(nap); |
| 251 void* buffer; |
| 252 if (params[1] == 0) { |
| 253 return -1; |
| 254 } else { |
| 255 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(buffer)); |
| 256 if (temp == kNaClBadAddress) { |
| 257 return -1; |
| 258 } |
| 259 buffer = *reinterpret_cast<void* volatile*>(temp); |
| 260 } |
| 261 MojoResult* result_ptr; |
| 262 MojoResult result; |
| 263 if (params[2] == 0) { |
| 264 return -1; |
| 265 } else { |
| 266 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(result)); |
| 267 if (temp == kNaClBadAddress) { |
| 268 return -1; |
| 269 } |
| 270 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 271 } |
| 272 NaClCopyDropLock(nap); |
| 273 |
| 274 result = MojoUnmapBuffer(buffer); |
| 275 |
| 276 NaClCopyTakeLock(nap); |
| 277 *result_ptr = result; |
| 278 NaClCopyDropLock(nap); |
| 279 |
| 280 return 0; |
| 281 } |
| 282 case 4: |
| 283 { |
| 284 if (numParams != 5) { |
| 285 return -1; |
| 286 } |
| 287 NaClCopyTakeLock(nap); |
| 288 const struct MojoCreateDataPipeOptions* options; |
| 289 if (params[1] == 0) { |
| 290 options = NULL; |
| 291 } else { |
| 292 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(*options)
); |
| 293 if (temp == kNaClBadAddress) { |
| 294 return -1; |
| 295 } |
| 296 options = reinterpret_cast<const struct MojoCreateDataPipeOptions*>(temp
); |
| 297 } |
| 298 MojoHandle* data_pipe_producer_handle_ptr; |
| 299 MojoHandle data_pipe_producer_handle; |
| 300 if (params[2] == 0) { |
| 301 return -1; |
| 302 } else { |
| 303 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(data_pipe
_producer_handle)); |
| 304 if (temp == kNaClBadAddress) { |
| 305 return -1; |
| 306 } |
| 307 data_pipe_producer_handle_ptr = reinterpret_cast<MojoHandle*>(temp); |
| 308 } |
| 309 MojoHandle* data_pipe_consumer_handle_ptr; |
| 310 MojoHandle data_pipe_consumer_handle; |
| 311 if (params[3] == 0) { |
| 312 return -1; |
| 313 } else { |
| 314 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(data_pipe
_consumer_handle)); |
| 315 if (temp == kNaClBadAddress) { |
| 316 return -1; |
| 317 } |
| 318 data_pipe_consumer_handle_ptr = reinterpret_cast<MojoHandle*>(temp); |
| 319 } |
| 320 MojoResult* result_ptr; |
| 321 MojoResult result; |
| 322 if (params[4] == 0) { |
| 323 return -1; |
| 324 } else { |
| 325 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(result)); |
| 326 if (temp == kNaClBadAddress) { |
| 327 return -1; |
| 328 } |
| 329 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 330 } |
| 331 NaClCopyDropLock(nap); |
| 332 |
| 333 result = MojoCreateDataPipe(options, &data_pipe_producer_handle, &data_pip
e_consumer_handle); |
| 334 |
| 335 NaClCopyTakeLock(nap); |
| 336 *data_pipe_producer_handle_ptr = data_pipe_producer_handle; |
| 337 *data_pipe_consumer_handle_ptr = data_pipe_consumer_handle; |
| 338 *result_ptr = result; |
| 339 NaClCopyDropLock(nap); |
| 340 |
| 341 return 0; |
| 342 } |
| 343 case 5: |
| 344 { |
| 345 if (numParams != 6) { |
| 346 return -1; |
| 347 } |
| 348 NaClCopyTakeLock(nap); |
| 349 MojoHandle data_pipe_producer_handle; |
| 350 if (params[1] == 0) { |
| 351 return -1; |
| 352 } else { |
| 353 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(data_pipe
_producer_handle)); |
| 354 if (temp == kNaClBadAddress) { |
| 355 return -1; |
| 356 } |
| 357 data_pipe_producer_handle = *reinterpret_cast<MojoHandle volatile*>(temp
); |
| 358 } |
| 359 uint32_t* num_bytes_ptr; |
| 360 uint32_t num_bytes; |
| 361 if (params[3] == 0) { |
| 362 return -1; |
| 363 } else { |
| 364 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(num_bytes
)); |
| 365 if (temp == kNaClBadAddress) { |
| 366 return -1; |
| 367 } |
| 368 num_bytes_ptr = reinterpret_cast<uint32_t*>(temp); |
| 369 // In/Out |
| 370 num_bytes = *num_bytes_ptr; |
| 371 } |
| 372 MojoWriteDataFlags flags; |
| 373 if (params[4] == 0) { |
| 374 return -1; |
| 375 } else { |
| 376 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(flags)); |
| 377 if (temp == kNaClBadAddress) { |
| 378 return -1; |
| 379 } |
| 380 flags = *reinterpret_cast<MojoWriteDataFlags volatile*>(temp); |
| 381 } |
| 382 const void* elements; |
| 383 if (params[2] == 0) { |
| 384 return -1; |
| 385 } else { |
| 386 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], num_bytes); |
| 387 if (temp == kNaClBadAddress) { |
| 388 return -1; |
| 389 } |
| 390 elements = reinterpret_cast<const void*>(temp); |
| 391 } |
| 392 MojoResult* result_ptr; |
| 393 MojoResult result; |
| 394 if (params[5] == 0) { |
| 395 return -1; |
| 396 } else { |
| 397 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(result)); |
| 398 if (temp == kNaClBadAddress) { |
| 399 return -1; |
| 400 } |
| 401 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 402 } |
| 403 NaClCopyDropLock(nap); |
| 404 |
| 405 result = MojoWriteData(data_pipe_producer_handle, elements, &num_bytes, fl
ags); |
| 406 |
| 407 NaClCopyTakeLock(nap); |
| 408 *num_bytes_ptr = num_bytes; |
| 409 *result_ptr = result; |
| 410 NaClCopyDropLock(nap); |
| 411 |
| 412 return 0; |
| 413 } |
| 414 case 6: |
| 415 { |
| 416 if (numParams != 6) { |
| 417 return -1; |
| 418 } |
| 419 NaClCopyTakeLock(nap); |
| 420 MojoHandle data_pipe_producer_handle; |
| 421 if (params[1] == 0) { |
| 422 return -1; |
| 423 } else { |
| 424 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(data_pipe
_producer_handle)); |
| 425 if (temp == kNaClBadAddress) { |
| 426 return -1; |
| 427 } |
| 428 data_pipe_producer_handle = *reinterpret_cast<MojoHandle volatile*>(temp
); |
| 429 } |
| 430 void** buffer_ptr; |
| 431 void* buffer; |
| 432 if (params[2] == 0) { |
| 433 return -1; |
| 434 } else { |
| 435 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(buffer)); |
| 436 if (temp == kNaClBadAddress) { |
| 437 return -1; |
| 438 } |
| 439 buffer_ptr = reinterpret_cast<void**>(temp); |
| 440 } |
| 441 uint32_t* buffer_num_bytes_ptr; |
| 442 uint32_t buffer_num_bytes; |
| 443 if (params[3] == 0) { |
| 444 return -1; |
| 445 } else { |
| 446 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(buffer_nu
m_bytes)); |
| 447 if (temp == kNaClBadAddress) { |
| 448 return -1; |
| 449 } |
| 450 buffer_num_bytes_ptr = reinterpret_cast<uint32_t*>(temp); |
| 451 // In/Out |
| 452 buffer_num_bytes = *buffer_num_bytes_ptr; |
| 453 } |
| 454 MojoWriteDataFlags flags; |
| 455 if (params[4] == 0) { |
| 456 return -1; |
| 457 } else { |
| 458 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(flags)); |
| 459 if (temp == kNaClBadAddress) { |
| 460 return -1; |
| 461 } |
| 462 flags = *reinterpret_cast<MojoWriteDataFlags volatile*>(temp); |
| 463 } |
| 464 MojoResult* result_ptr; |
| 465 MojoResult result; |
| 466 if (params[5] == 0) { |
| 467 return -1; |
| 468 } else { |
| 469 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(result)); |
| 470 if (temp == kNaClBadAddress) { |
| 471 return -1; |
| 472 } |
| 473 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 474 } |
| 475 NaClCopyDropLock(nap); |
| 476 |
| 477 result = MojoBeginWriteData(data_pipe_producer_handle, &buffer, &buffer_nu
m_bytes, flags); |
| 478 |
| 479 NaClCopyTakeLock(nap); |
| 480 *buffer_ptr = buffer; |
| 481 *buffer_num_bytes_ptr = buffer_num_bytes; |
| 482 *result_ptr = result; |
| 483 NaClCopyDropLock(nap); |
| 484 |
| 485 return 0; |
| 486 } |
| 487 case 7: |
| 488 { |
| 489 if (numParams != 4) { |
| 490 return -1; |
| 491 } |
| 492 NaClCopyTakeLock(nap); |
| 493 MojoHandle data_pipe_producer_handle; |
| 494 if (params[1] == 0) { |
| 495 return -1; |
| 496 } else { |
| 497 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(data_pipe
_producer_handle)); |
| 498 if (temp == kNaClBadAddress) { |
| 499 return -1; |
| 500 } |
| 501 data_pipe_producer_handle = *reinterpret_cast<MojoHandle volatile*>(temp
); |
| 502 } |
| 503 uint32_t num_bytes_written; |
| 504 if (params[2] == 0) { |
| 505 return -1; |
| 506 } else { |
| 507 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(num_bytes
_written)); |
| 508 if (temp == kNaClBadAddress) { |
| 509 return -1; |
| 510 } |
| 511 num_bytes_written = *reinterpret_cast<uint32_t volatile*>(temp); |
| 512 } |
| 513 MojoResult* result_ptr; |
| 514 MojoResult result; |
| 515 if (params[3] == 0) { |
| 516 return -1; |
| 517 } else { |
| 518 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(result)); |
| 519 if (temp == kNaClBadAddress) { |
| 520 return -1; |
| 521 } |
| 522 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 523 } |
| 524 NaClCopyDropLock(nap); |
| 525 |
| 526 result = MojoEndWriteData(data_pipe_producer_handle, num_bytes_written); |
| 527 |
| 528 NaClCopyTakeLock(nap); |
| 529 *result_ptr = result; |
| 530 NaClCopyDropLock(nap); |
| 531 |
| 532 return 0; |
| 533 } |
| 534 case 8: |
| 535 { |
| 536 if (numParams != 6) { |
| 537 return -1; |
| 538 } |
| 539 NaClCopyTakeLock(nap); |
| 540 MojoHandle data_pipe_consumer_handle; |
| 541 if (params[1] == 0) { |
| 542 return -1; |
| 543 } else { |
| 544 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(data_pipe
_consumer_handle)); |
| 545 if (temp == kNaClBadAddress) { |
| 546 return -1; |
| 547 } |
| 548 data_pipe_consumer_handle = *reinterpret_cast<MojoHandle volatile*>(temp
); |
| 549 } |
| 550 uint32_t* num_bytes_ptr; |
| 551 uint32_t num_bytes; |
| 552 if (params[3] == 0) { |
| 553 return -1; |
| 554 } else { |
| 555 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(num_bytes
)); |
| 556 if (temp == kNaClBadAddress) { |
| 557 return -1; |
| 558 } |
| 559 num_bytes_ptr = reinterpret_cast<uint32_t*>(temp); |
| 560 // In/Out |
| 561 num_bytes = *num_bytes_ptr; |
| 562 } |
| 563 MojoReadDataFlags flags; |
| 564 if (params[4] == 0) { |
| 565 return -1; |
| 566 } else { |
| 567 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(flags)); |
| 568 if (temp == kNaClBadAddress) { |
| 569 return -1; |
| 570 } |
| 571 flags = *reinterpret_cast<MojoReadDataFlags volatile*>(temp); |
| 572 } |
| 573 void* elements; |
| 574 if (params[2] == 0) { |
| 575 return -1; |
| 576 } else { |
| 577 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], num_bytes); |
| 578 if (temp == kNaClBadAddress) { |
| 579 return -1; |
| 580 } |
| 581 elements = reinterpret_cast<void*>(temp); |
| 582 } |
| 583 MojoResult* result_ptr; |
| 584 MojoResult result; |
| 585 if (params[5] == 0) { |
| 586 return -1; |
| 587 } else { |
| 588 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(result)); |
| 589 if (temp == kNaClBadAddress) { |
| 590 return -1; |
| 591 } |
| 592 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 593 } |
| 594 NaClCopyDropLock(nap); |
| 595 |
| 596 result = MojoReadData(data_pipe_consumer_handle, elements, &num_bytes, fla
gs); |
| 597 |
| 598 NaClCopyTakeLock(nap); |
| 599 *num_bytes_ptr = num_bytes; |
| 600 *result_ptr = result; |
| 601 NaClCopyDropLock(nap); |
| 602 |
| 603 return 0; |
| 604 } |
| 605 case 9: |
| 606 { |
| 607 if (numParams != 6) { |
| 608 return -1; |
| 609 } |
| 610 NaClCopyTakeLock(nap); |
| 611 MojoHandle data_pipe_consumer_handle; |
| 612 if (params[1] == 0) { |
| 613 return -1; |
| 614 } else { |
| 615 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(data_pipe
_consumer_handle)); |
| 616 if (temp == kNaClBadAddress) { |
| 617 return -1; |
| 618 } |
| 619 data_pipe_consumer_handle = *reinterpret_cast<MojoHandle volatile*>(temp
); |
| 620 } |
| 621 const void** buffer_ptr; |
| 622 const void* buffer; |
| 623 if (params[2] == 0) { |
| 624 return -1; |
| 625 } else { |
| 626 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(buffer)); |
| 627 if (temp == kNaClBadAddress) { |
| 628 return -1; |
| 629 } |
| 630 buffer_ptr = reinterpret_cast<const void**>(temp); |
| 631 } |
| 632 uint32_t* buffer_num_bytes_ptr; |
| 633 uint32_t buffer_num_bytes; |
| 634 if (params[3] == 0) { |
| 635 return -1; |
| 636 } else { |
| 637 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(buffer_nu
m_bytes)); |
| 638 if (temp == kNaClBadAddress) { |
| 639 return -1; |
| 640 } |
| 641 buffer_num_bytes_ptr = reinterpret_cast<uint32_t*>(temp); |
| 642 // In/Out |
| 643 buffer_num_bytes = *buffer_num_bytes_ptr; |
| 644 } |
| 645 MojoReadDataFlags flags; |
| 646 if (params[4] == 0) { |
| 647 return -1; |
| 648 } else { |
| 649 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(flags)); |
| 650 if (temp == kNaClBadAddress) { |
| 651 return -1; |
| 652 } |
| 653 flags = *reinterpret_cast<MojoReadDataFlags volatile*>(temp); |
| 654 } |
| 655 MojoResult* result_ptr; |
| 656 MojoResult result; |
| 657 if (params[5] == 0) { |
| 658 return -1; |
| 659 } else { |
| 660 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(result)); |
| 661 if (temp == kNaClBadAddress) { |
| 662 return -1; |
| 663 } |
| 664 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 665 } |
| 666 NaClCopyDropLock(nap); |
| 667 |
| 668 result = MojoBeginReadData(data_pipe_consumer_handle, &buffer, &buffer_num
_bytes, flags); |
| 669 |
| 670 NaClCopyTakeLock(nap); |
| 671 *buffer_ptr = buffer; |
| 672 *buffer_num_bytes_ptr = buffer_num_bytes; |
| 673 *result_ptr = result; |
| 674 NaClCopyDropLock(nap); |
| 675 |
| 676 return 0; |
| 677 } |
| 678 case 10: |
| 679 { |
| 680 if (numParams != 4) { |
| 681 return -1; |
| 682 } |
| 683 NaClCopyTakeLock(nap); |
| 684 MojoHandle data_pipe_consumer_handle; |
| 685 if (params[1] == 0) { |
| 686 return -1; |
| 687 } else { |
| 688 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(data_pipe
_consumer_handle)); |
| 689 if (temp == kNaClBadAddress) { |
| 690 return -1; |
| 691 } |
| 692 data_pipe_consumer_handle = *reinterpret_cast<MojoHandle volatile*>(temp
); |
| 693 } |
| 694 uint32_t num_bytes_read; |
| 695 if (params[2] == 0) { |
| 696 return -1; |
| 697 } else { |
| 698 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(num_bytes
_read)); |
| 699 if (temp == kNaClBadAddress) { |
| 700 return -1; |
| 701 } |
| 702 num_bytes_read = *reinterpret_cast<uint32_t volatile*>(temp); |
| 703 } |
| 704 MojoResult* result_ptr; |
| 705 MojoResult result; |
| 706 if (params[3] == 0) { |
| 707 return -1; |
| 708 } else { |
| 709 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(result)); |
| 710 if (temp == kNaClBadAddress) { |
| 711 return -1; |
| 712 } |
| 713 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 714 } |
| 715 NaClCopyDropLock(nap); |
| 716 |
| 717 result = MojoEndReadData(data_pipe_consumer_handle, num_bytes_read); |
| 718 |
| 719 NaClCopyTakeLock(nap); |
| 720 *result_ptr = result; |
| 721 NaClCopyDropLock(nap); |
| 722 |
| 723 return 0; |
| 724 } |
| 725 case 11: |
| 726 { |
| 727 if (numParams != 2) { |
| 728 return -1; |
| 729 } |
| 730 NaClCopyTakeLock(nap); |
| 731 MojoTimeTicks* result_ptr; |
| 732 MojoTimeTicks result; |
| 733 if (params[1] == 0) { |
| 734 return -1; |
| 735 } else { |
| 736 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(result)); |
| 737 if (temp == kNaClBadAddress) { |
| 738 return -1; |
| 739 } |
| 740 result_ptr = reinterpret_cast<MojoTimeTicks*>(temp); |
| 741 } |
| 742 NaClCopyDropLock(nap); |
| 743 |
| 744 result = MojoGetTimeTicksNow(); |
| 745 |
| 746 NaClCopyTakeLock(nap); |
| 747 *result_ptr = result; |
| 748 NaClCopyDropLock(nap); |
| 749 |
| 750 return 0; |
| 751 } |
| 752 case 12: |
| 753 { |
| 754 if (numParams != 3) { |
| 755 return -1; |
| 756 } |
| 757 NaClCopyTakeLock(nap); |
| 758 MojoHandle handle; |
| 759 if (params[1] == 0) { |
| 760 return -1; |
| 761 } else { |
| 762 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(handle)); |
| 763 if (temp == kNaClBadAddress) { |
| 764 return -1; |
| 765 } |
| 766 handle = *reinterpret_cast<MojoHandle volatile*>(temp); |
| 767 } |
| 768 MojoResult* result_ptr; |
| 769 MojoResult result; |
| 770 if (params[2] == 0) { |
| 771 return -1; |
| 772 } else { |
| 773 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(result)); |
| 774 if (temp == kNaClBadAddress) { |
| 775 return -1; |
| 776 } |
| 777 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 778 } |
| 779 NaClCopyDropLock(nap); |
| 780 |
| 781 result = MojoClose(handle); |
| 782 |
| 783 NaClCopyTakeLock(nap); |
| 784 *result_ptr = result; |
| 785 NaClCopyDropLock(nap); |
| 786 |
| 787 return 0; |
| 788 } |
| 789 case 13: |
| 790 { |
| 791 if (numParams != 5) { |
| 792 return -1; |
| 793 } |
| 794 NaClCopyTakeLock(nap); |
| 795 MojoHandle handle; |
| 796 if (params[1] == 0) { |
| 797 return -1; |
| 798 } else { |
| 799 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(handle)); |
| 800 if (temp == kNaClBadAddress) { |
| 801 return -1; |
| 802 } |
| 803 handle = *reinterpret_cast<MojoHandle volatile*>(temp); |
| 804 } |
| 805 MojoHandleSignals signals; |
| 806 if (params[2] == 0) { |
| 807 return -1; |
| 808 } else { |
| 809 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(signals))
; |
| 810 if (temp == kNaClBadAddress) { |
| 811 return -1; |
| 812 } |
| 813 signals = *reinterpret_cast<MojoHandleSignals volatile*>(temp); |
| 814 } |
| 815 MojoDeadline deadline; |
| 816 if (params[3] == 0) { |
| 817 return -1; |
| 818 } else { |
| 819 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(deadline)
); |
| 820 if (temp == kNaClBadAddress) { |
| 821 return -1; |
| 822 } |
| 823 deadline = *reinterpret_cast<MojoDeadline volatile*>(temp); |
| 824 } |
| 825 MojoResult* result_ptr; |
| 826 MojoResult result; |
| 827 if (params[4] == 0) { |
| 828 return -1; |
| 829 } else { |
| 830 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(result)); |
| 831 if (temp == kNaClBadAddress) { |
| 832 return -1; |
| 833 } |
| 834 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 835 } |
| 836 NaClCopyDropLock(nap); |
| 837 |
| 838 result = MojoWait(handle, signals, deadline); |
| 839 |
| 840 NaClCopyTakeLock(nap); |
| 841 *result_ptr = result; |
| 842 NaClCopyDropLock(nap); |
| 843 |
| 844 return 0; |
| 845 } |
| 846 case 14: |
| 847 { |
| 848 if (numParams != 6) { |
| 849 return -1; |
| 850 } |
| 851 NaClCopyTakeLock(nap); |
| 852 uint32_t num_handles; |
| 853 if (params[3] == 0) { |
| 854 return -1; |
| 855 } else { |
| 856 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(num_handl
es)); |
| 857 if (temp == kNaClBadAddress) { |
| 858 return -1; |
| 859 } |
| 860 num_handles = *reinterpret_cast<uint32_t volatile*>(temp); |
| 861 } |
| 862 MojoDeadline deadline; |
| 863 if (params[4] == 0) { |
| 864 return -1; |
| 865 } else { |
| 866 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(deadline)
); |
| 867 if (temp == kNaClBadAddress) { |
| 868 return -1; |
| 869 } |
| 870 deadline = *reinterpret_cast<MojoDeadline volatile*>(temp); |
| 871 } |
| 872 const MojoHandle* handles; |
| 873 if (params[1] == 0) { |
| 874 return -1; |
| 875 } else { |
| 876 uintptr_t temp = NaClUserToSysAddrArray(nap, params[1], num_handles, siz
eof(*handles)); |
| 877 if (temp == kNaClBadAddress) { |
| 878 return -1; |
| 879 } |
| 880 handles = reinterpret_cast<const MojoHandle*>(temp); |
| 881 } |
| 882 const MojoHandleSignals* signals; |
| 883 if (params[2] == 0) { |
| 884 return -1; |
| 885 } else { |
| 886 uintptr_t temp = NaClUserToSysAddrArray(nap, params[2], num_handles, siz
eof(*signals)); |
| 887 if (temp == kNaClBadAddress) { |
| 888 return -1; |
| 889 } |
| 890 signals = reinterpret_cast<const MojoHandleSignals*>(temp); |
| 891 } |
| 892 MojoResult* result_ptr; |
| 893 MojoResult result; |
| 894 if (params[5] == 0) { |
| 895 return -1; |
| 896 } else { |
| 897 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(result)); |
| 898 if (temp == kNaClBadAddress) { |
| 899 return -1; |
| 900 } |
| 901 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 902 } |
| 903 NaClCopyDropLock(nap); |
| 904 |
| 905 result = MojoWaitMany(handles, signals, num_handles, deadline); |
| 906 |
| 907 NaClCopyTakeLock(nap); |
| 908 *result_ptr = result; |
| 909 NaClCopyDropLock(nap); |
| 910 |
| 911 return 0; |
| 912 } |
| 913 case 15: |
| 914 { |
| 915 if (numParams != 5) { |
| 916 return -1; |
| 917 } |
| 918 NaClCopyTakeLock(nap); |
| 919 const struct MojoCreateMessagePipeOptions* options; |
| 920 if (params[1] == 0) { |
| 921 options = NULL; |
| 922 } else { |
| 923 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(*options)
); |
| 924 if (temp == kNaClBadAddress) { |
| 925 return -1; |
| 926 } |
| 927 options = reinterpret_cast<const struct MojoCreateMessagePipeOptions*>(t
emp); |
| 928 } |
| 929 MojoHandle* message_pipe_handle0_ptr; |
| 930 MojoHandle message_pipe_handle0; |
| 931 if (params[2] == 0) { |
| 932 return -1; |
| 933 } else { |
| 934 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], sizeof(message_p
ipe_handle0)); |
| 935 if (temp == kNaClBadAddress) { |
| 936 return -1; |
| 937 } |
| 938 message_pipe_handle0_ptr = reinterpret_cast<MojoHandle*>(temp); |
| 939 } |
| 940 MojoHandle* message_pipe_handle1_ptr; |
| 941 MojoHandle message_pipe_handle1; |
| 942 if (params[3] == 0) { |
| 943 return -1; |
| 944 } else { |
| 945 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(message_p
ipe_handle1)); |
| 946 if (temp == kNaClBadAddress) { |
| 947 return -1; |
| 948 } |
| 949 message_pipe_handle1_ptr = reinterpret_cast<MojoHandle*>(temp); |
| 950 } |
| 951 MojoResult* result_ptr; |
| 952 MojoResult result; |
| 953 if (params[4] == 0) { |
| 954 return -1; |
| 955 } else { |
| 956 uintptr_t temp = NaClUserToSysAddrRange(nap, params[4], sizeof(result)); |
| 957 if (temp == kNaClBadAddress) { |
| 958 return -1; |
| 959 } |
| 960 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 961 } |
| 962 NaClCopyDropLock(nap); |
| 963 |
| 964 result = MojoCreateMessagePipe(options, &message_pipe_handle0, &message_pi
pe_handle1); |
| 965 |
| 966 NaClCopyTakeLock(nap); |
| 967 *message_pipe_handle0_ptr = message_pipe_handle0; |
| 968 *message_pipe_handle1_ptr = message_pipe_handle1; |
| 969 *result_ptr = result; |
| 970 NaClCopyDropLock(nap); |
| 971 |
| 972 return 0; |
| 973 } |
| 974 case 16: |
| 975 { |
| 976 if (numParams != 8) { |
| 977 return -1; |
| 978 } |
| 979 NaClCopyTakeLock(nap); |
| 980 MojoHandle message_pipe_handle; |
| 981 if (params[1] == 0) { |
| 982 return -1; |
| 983 } else { |
| 984 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(message_p
ipe_handle)); |
| 985 if (temp == kNaClBadAddress) { |
| 986 return -1; |
| 987 } |
| 988 message_pipe_handle = *reinterpret_cast<MojoHandle volatile*>(temp); |
| 989 } |
| 990 uint32_t num_bytes; |
| 991 if (params[3] == 0) { |
| 992 return -1; |
| 993 } else { |
| 994 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(num_bytes
)); |
| 995 if (temp == kNaClBadAddress) { |
| 996 return -1; |
| 997 } |
| 998 num_bytes = *reinterpret_cast<uint32_t volatile*>(temp); |
| 999 } |
| 1000 uint32_t num_handles; |
| 1001 if (params[5] == 0) { |
| 1002 return -1; |
| 1003 } else { |
| 1004 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(num_handl
es)); |
| 1005 if (temp == kNaClBadAddress) { |
| 1006 return -1; |
| 1007 } |
| 1008 num_handles = *reinterpret_cast<uint32_t volatile*>(temp); |
| 1009 } |
| 1010 MojoWriteMessageFlags flags; |
| 1011 if (params[6] == 0) { |
| 1012 return -1; |
| 1013 } else { |
| 1014 uintptr_t temp = NaClUserToSysAddrRange(nap, params[6], sizeof(flags)); |
| 1015 if (temp == kNaClBadAddress) { |
| 1016 return -1; |
| 1017 } |
| 1018 flags = *reinterpret_cast<MojoWriteMessageFlags volatile*>(temp); |
| 1019 } |
| 1020 const void* bytes; |
| 1021 if (params[2] == 0) { |
| 1022 bytes = NULL; |
| 1023 } else { |
| 1024 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], num_bytes); |
| 1025 if (temp == kNaClBadAddress) { |
| 1026 return -1; |
| 1027 } |
| 1028 bytes = reinterpret_cast<const void*>(temp); |
| 1029 } |
| 1030 const MojoHandle* handles; |
| 1031 if (params[4] == 0) { |
| 1032 handles = NULL; |
| 1033 } else { |
| 1034 uintptr_t temp = NaClUserToSysAddrArray(nap, params[4], num_handles, siz
eof(*handles)); |
| 1035 if (temp == kNaClBadAddress) { |
| 1036 return -1; |
| 1037 } |
| 1038 handles = reinterpret_cast<const MojoHandle*>(temp); |
| 1039 } |
| 1040 MojoResult* result_ptr; |
| 1041 MojoResult result; |
| 1042 if (params[7] == 0) { |
| 1043 return -1; |
| 1044 } else { |
| 1045 uintptr_t temp = NaClUserToSysAddrRange(nap, params[7], sizeof(result)); |
| 1046 if (temp == kNaClBadAddress) { |
| 1047 return -1; |
| 1048 } |
| 1049 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 1050 } |
| 1051 NaClCopyDropLock(nap); |
| 1052 |
| 1053 result = MojoWriteMessage(message_pipe_handle, bytes, num_bytes, handles,
num_handles, flags); |
| 1054 |
| 1055 NaClCopyTakeLock(nap); |
| 1056 *result_ptr = result; |
| 1057 NaClCopyDropLock(nap); |
| 1058 |
| 1059 return 0; |
| 1060 } |
| 1061 case 17: |
| 1062 { |
| 1063 if (numParams != 8) { |
| 1064 return -1; |
| 1065 } |
| 1066 NaClCopyTakeLock(nap); |
| 1067 MojoHandle message_pipe_handle; |
| 1068 if (params[1] == 0) { |
| 1069 return -1; |
| 1070 } else { |
| 1071 uintptr_t temp = NaClUserToSysAddrRange(nap, params[1], sizeof(message_p
ipe_handle)); |
| 1072 if (temp == kNaClBadAddress) { |
| 1073 return -1; |
| 1074 } |
| 1075 message_pipe_handle = *reinterpret_cast<MojoHandle volatile*>(temp); |
| 1076 } |
| 1077 uint32_t* num_bytes_ptr; |
| 1078 uint32_t num_bytes; |
| 1079 if (params[3] == 0) { |
| 1080 num_bytes_ptr = NULL; |
| 1081 num_bytes = 0; |
| 1082 } else { |
| 1083 uintptr_t temp = NaClUserToSysAddrRange(nap, params[3], sizeof(num_bytes
)); |
| 1084 if (temp == kNaClBadAddress) { |
| 1085 return -1; |
| 1086 } |
| 1087 num_bytes_ptr = reinterpret_cast<uint32_t*>(temp); |
| 1088 // In/Out |
| 1089 num_bytes = *num_bytes_ptr; |
| 1090 } |
| 1091 uint32_t* num_handles_ptr; |
| 1092 uint32_t num_handles; |
| 1093 if (params[5] == 0) { |
| 1094 num_handles_ptr = NULL; |
| 1095 num_handles = 0; |
| 1096 } else { |
| 1097 uintptr_t temp = NaClUserToSysAddrRange(nap, params[5], sizeof(num_handl
es)); |
| 1098 if (temp == kNaClBadAddress) { |
| 1099 return -1; |
| 1100 } |
| 1101 num_handles_ptr = reinterpret_cast<uint32_t*>(temp); |
| 1102 // In/Out |
| 1103 num_handles = *num_handles_ptr; |
| 1104 } |
| 1105 MojoReadMessageFlags flags; |
| 1106 if (params[6] == 0) { |
| 1107 return -1; |
| 1108 } else { |
| 1109 uintptr_t temp = NaClUserToSysAddrRange(nap, params[6], sizeof(flags)); |
| 1110 if (temp == kNaClBadAddress) { |
| 1111 return -1; |
| 1112 } |
| 1113 flags = *reinterpret_cast<MojoReadMessageFlags volatile*>(temp); |
| 1114 } |
| 1115 void* bytes; |
| 1116 if (params[2] == 0) { |
| 1117 bytes = NULL; |
| 1118 } else { |
| 1119 uintptr_t temp = NaClUserToSysAddrRange(nap, params[2], num_bytes); |
| 1120 if (temp == kNaClBadAddress) { |
| 1121 return -1; |
| 1122 } |
| 1123 bytes = reinterpret_cast<void*>(temp); |
| 1124 } |
| 1125 MojoHandle* handles; |
| 1126 if (params[4] == 0) { |
| 1127 handles = NULL; |
| 1128 } else { |
| 1129 uintptr_t temp = NaClUserToSysAddrArray(nap, params[4], num_handles, siz
eof(*handles)); |
| 1130 if (temp == kNaClBadAddress) { |
| 1131 return -1; |
| 1132 } |
| 1133 handles = reinterpret_cast<MojoHandle*>(temp); |
| 1134 } |
| 1135 MojoResult* result_ptr; |
| 1136 MojoResult result; |
| 1137 if (params[7] == 0) { |
| 1138 return -1; |
| 1139 } else { |
| 1140 uintptr_t temp = NaClUserToSysAddrRange(nap, params[7], sizeof(result)); |
| 1141 if (temp == kNaClBadAddress) { |
| 1142 return -1; |
| 1143 } |
| 1144 result_ptr = reinterpret_cast<MojoResult*>(temp); |
| 1145 } |
| 1146 NaClCopyDropLock(nap); |
| 1147 |
| 1148 result = MojoReadMessage(message_pipe_handle, bytes, num_bytes_ptr ? &num_
bytes : NULL, handles, num_handles_ptr ? &num_handles : NULL, flags); |
| 1149 |
| 1150 NaClCopyTakeLock(nap); |
| 1151 if (num_bytes_ptr != NULL) { |
| 1152 *num_bytes_ptr = num_bytes; |
| 1153 } |
| 1154 if (num_handles_ptr != NULL) { |
| 1155 *num_handles_ptr = num_handles; |
| 1156 } |
| 1157 *result_ptr = result; |
| 1158 NaClCopyDropLock(nap); |
| 1159 |
| 1160 return 0; |
| 1161 } |
| 1162 |
| 1163 default: |
| 1164 return -1; |
| 1165 } |
| 1166 |
| 1167 return -1; |
| 1168 } |
| 1169 |
| 1170 ssize_t MojoDescRecvMsg(void *handle, |
| 1171 struct NaClImcTypedMsgHdr *msg, |
| 1172 int flags) { |
| 1173 UNREFERENCED_PARAMETER(handle); |
| 1174 UNREFERENCED_PARAMETER(msg); |
| 1175 UNREFERENCED_PARAMETER(flags); |
| 1176 |
| 1177 return -1; |
| 1178 } |
| 1179 |
| 1180 struct NaClDesc *MakeMojoDesc(struct NaClApp *nap) { |
| 1181 struct NaClDescCustomFuncs funcs = NACL_DESC_CUSTOM_FUNCS_INITIALIZER; |
| 1182 funcs.Destroy = MojoDescDestroy; |
| 1183 funcs.SendMsg = MojoDescSendMsg; |
| 1184 funcs.RecvMsg = MojoDescRecvMsg; |
| 1185 return NaClDescMakeCustomDesc(nap, &funcs); |
| 1186 } |
| 1187 |
| 1188 #define NACL_MOJO_DESC 5 |
| 1189 |
| 1190 void InjectMojo(struct NaClApp *nap) { |
| 1191 NaClAppSetDesc(nap, NACL_MOJO_DESC, MakeMojoDesc(nap)); |
| 1192 } |
OLD | NEW |