(ql, address, params)
| 1045 | "ctlref": POINTER, |
| 1046 | }) |
| 1047 | def hook__ctl_register(ql, address, params): |
| 1048 | userctl = kern_ctl_reg_t(ql, params["userctl"]) |
| 1049 | userctl = userctl.loadFromMem() |
| 1050 | ctl_name = ql.mem.string(params["userctl"]).encode() |
| 1051 | flag = 0 |
| 1052 | if userctl.ctl_connect.value != 0: |
| 1053 | flag |= 1 << 0 |
| 1054 | ql.os.ev_manager.register(userctl.ctl_connect.value, ctl_name, MacOSEventType.EV_CTL_CONNECT, ev_obj=userctl, idx=0) |
| 1055 | if userctl.ctl_disconnect.value != 0: |
| 1056 | flag |= 1 << 1 |
| 1057 | ql.os.ev_manager.register(userctl.ctl_disconnect.value, ctl_name, MacOSEventType.EV_CTL_DISCONNECT, ev_obj=userctl, idx=0) |
| 1058 | if userctl.ctl_send.value != 0: |
| 1059 | flag |= 1 << 2 |
| 1060 | ql.os.ev_manager.register(userctl.ctl_send.value, ctl_name, MacOSEventType.EV_CTL_SEND, ev_obj=userctl, idx=0) |
| 1061 | if userctl.ctl_setopt.value != 0: |
| 1062 | flag |= 1 << 3 |
| 1063 | ql.os.ev_manager.register(userctl.ctl_setopt.value, ctl_name, MacOSEventType.EV_CTL_SETOPT, ev_obj=userctl, idx=0) |
| 1064 | if userctl.ctl_getopt.value != 0: |
| 1065 | flag |= 1 << 4 |
| 1066 | ql.os.ev_manager.register(userctl.ctl_getopt.value, ctl_name, MacOSEventType.EV_CTL_GETOPT, ev_obj=userctl, idx=0) |
| 1067 | if userctl.ctl_rcvd.value != 0: |
| 1068 | flag |= 1 << 5 |
| 1069 | ql.os.ev_manager.register(userctl.ctl_rcvd.value, ctl_name, MacOSEventType.EV_CTL_RCVD_FUNC, ev_obj=userctl, idx=0) |
| 1070 | if userctl.ctl_send_list.value != 0: |
| 1071 | flag |= 1 << 6 |
| 1072 | ql.os.ev_manager.register(userctl.ctl_send_list.value, ctl_name, MacOSEventType.EV_CTL_SEND_LIST_FUNC, ev_obj=userctl, idx=0) |
| 1073 | if userctl.ctl_bind.value != 0: |
| 1074 | flag |= 1 << 7 |
| 1075 | ql.os.ev_manager.register(userctl.ctl_bind.value, ctl_name, MacOSEventType.EV_CTL_BIND_FUNC, ev_obj=userctl, idx=0) |
| 1076 | |
| 1077 | |
| 1078 | ql.log.debug("New ctl callbacks has been registered: %s (%d/%d/%d/%d/%d/%d/%d/%d)" % ( |
| 1079 | ctl_name, |
| 1080 | (flag & (1 << 0)) != 0, |
| 1081 | (flag & (1 << 1)) != 0, |
| 1082 | (flag & (1 << 2)) != 0, |
| 1083 | (flag & (1 << 3)) != 0, |
| 1084 | (flag & (1 << 4)) != 0, |
| 1085 | (flag & (1 << 5)) != 0, |
| 1086 | (flag & (1 << 6)) != 0, |
| 1087 | (flag & (1 << 7)) != 0)) |
| 1088 | |
| 1089 | ql.mem.write(params["ctlref"], struct.pack("<Q", userctl.base)) |
| 1090 | return 0 |
| 1091 | |
| 1092 | @macos_kernel_api(params={ |
| 1093 | "ctlref": POINTER |
nothing calls this directly
no test coverage detected