(self, fiber: Fiber)
| 74 | |
| 75 | # TODO: this one is unused for now; see above |
| 76 | def __invoke_callback(self, fiber: Fiber): |
| 77 | assert fiber.cb is not None |
| 78 | |
| 79 | # we are in an api hook. extract the return address of the free |
| 80 | # api to know where the callback should be returning to |
| 81 | retaddr = self.ql.stack_read(0) |
| 82 | |
| 83 | # one PVOID arg, set to fiber data |
| 84 | args = ((PVOID, fiber.data),) |
| 85 | |
| 86 | # set up call frame for callback |
| 87 | fcall = self.ql.os.fcall_select(CDECL) |
| 88 | fcall.call_native(fiber.cb, args, retaddr) |
| 89 | |
| 90 | # callback has to be invoked before returning from the free api |
| 91 | self.ql.emu_start(fiber.cb, retaddr) |
| 92 | |
| 93 | # unwind call frame |
| 94 | fcall.cc.unwind(len(args)) |
| 95 | |
| 96 | # ms64 cc needs also to unwind the reserved shadow slots on the stack |
| 97 | if self.ql.arch.type == QL_ARCH.X8664: |
| 98 | self.ql.arch.regs.arch_sp += (4 * self.ql.arch.pointersize) |
| 99 | |
| 100 | def set(self, idx: int, data: int) -> bool: |
| 101 | if idx not in self.fibers: |
nothing calls this directly
no test coverage detected