static VOID __stdcall _MmUnmapIoSpace(ULONG_PTR OriginalStackPointer) { PVOID virtualAddress; SIZE_T numberOfBytes; struct diotEvent* event; HookRefFunction(MmUnmapIoSpaceHookContext); virtualAddress = *(PVOID*)OriginalStackPointer; numberOfBytes = *(PSIZE_T)(OriginalStackPointer + sizeof(PVOID)); HookCallFunction(OriginalStackPointer, MmUnmapIoSpaceHookContext); if (mmioNotifyMappingDeletion((ULONG_PTR)virtualAddress, numberOfBytes) == TRUE) { /* notify user */ if (eventQueueAlloc(&event, DIOT_EVENT_MMIO_MAPPING, 0) == STATUS_SUCCESS) { event->data.mappingEvent.isCreated = FALSE; event->data.mappingEvent.mapping.physicalAddress.QuadPart = 0ULL; event->data.mappingEvent.mapping.virtualAddress = (ULONG_PTR)virtualAddress; event->data.mappingEvent.mapping.numberOfBytes = numberOfBytes; eventQueuePush(event); } } HookUnrefFunction(MmUnmapIoSpaceHookContext); }
JNIAPI Java_com_tangide_canvas_CanvasJNI_dispatchTouchEvent(JNIEnv * env, jobject obj, jint action, jint n, jintArray _xs, jintArray _ys) { vector<Touch> touchs; jint* xs = env->GetIntArrayElements(_xs,NULL); jint* ys = env->GetIntArrayElements(_ys,NULL); if(action == 0) { action = V8_TOUCH_START; } else if(action == 1) { action = V8_TOUCH_END; } else { action = V8_TOUCH_MOVE; } for(int i = 0; i < n; i++) { int x = xs[i]; int y = ys[i]; Touch touch(x, y); touchs.push_back(touch); } env->ReleaseIntArrayElements(_xs, xs, 0); env->ReleaseIntArrayElements(_ys, ys, 0); QTouchEvent* event = new QTouchEvent(action, touchs); eventQueuePush(new QEvent(QEvent::Q_EVENT_TOUCH, event)); LOGI("uv_async_send action=%d n=%d\n", action, n); }
static ULONG_PTR __stdcall _MmMapIoSpace(ULONG_PTR OriginalStackPointer) { ULONG_PTR virtualAddress = (ULONG_PTR)NULL; PHYSICAL_ADDRESS physicalAddress; SIZE_T numberOfBytes; struct diotEvent* event; HookRefFunction(MmMapIoSpaceHookContext); physicalAddress = *(PPHYSICAL_ADDRESS)OriginalStackPointer; numberOfBytes = *(PSIZE_T)(OriginalStackPointer + sizeof(PHYSICAL_ADDRESS)); virtualAddress = HookCallFunction(OriginalStackPointer, MmMapIoSpaceHookContext); if (virtualAddress == (ULONG_PTR)NULL) goto onError; if (mmioNotifyMappingCreation(virtualAddress, physicalAddress, numberOfBytes) == FALSE) { /* not intersted in the mapping */ goto onError; } if (areIntHooksInstalled() == FALSE) { /* int hooks not yet installed */ if (installIntHooks() != STATUS_SUCCESS) { DIOT_DEBUG_ERROR("installIntHooks() == FALSE\n"); goto onError; } } /* mark pages as invalid */ ia32MarkPagesInvalid(virtualAddress, numberOfBytes); /* notify user */ if (eventQueueAlloc(&event, DIOT_EVENT_MMIO_MAPPING, 0) == STATUS_SUCCESS) { event->data.mappingEvent.isCreated = TRUE; event->data.mappingEvent.mapping.physicalAddress.QuadPart = physicalAddress.QuadPart; event->data.mappingEvent.mapping.virtualAddress = virtualAddress; event->data.mappingEvent.mapping.numberOfBytes = numberOfBytes; eventQueuePush(event); } onError: HookUnrefFunction(MmMapIoSpaceHookContext); return virtualAddress; }
static void pushIoportEvent(BOOLEAN isInput, SIZE_T Count, UCHAR Size, ULONG_PTR Port, ULONG_PTR Value) { struct diotEvent* event; if (eventQueueAlloc(&event, DIOT_EVENT_IOPORT, 0) != STATUS_SUCCESS) return ; event->data.ioportEvent.isInput = isInput; event->data.ioportEvent.count = Count; event->data.ioportEvent.size = Size; event->data.ioportEvent.port = Port; event->data.ioportEvent.value = Value; eventQueuePush(event); }