int print_lu_attr(stmfGuid *guid) { luResource hdl = NULL; int stmfRet = 0; int ret = 0; char propVal[MAXPATHLEN]; size_t propValSize = sizeof (propVal); if ((stmfRet = stmfGetLuResource(guid, &hdl)) != STMF_STATUS_SUCCESS) { switch (stmfRet) { case STMF_ERROR_BUSY: (void) fprintf(stderr, "%s: %s\n", cmdName, gettext("resource busy")); break; case STMF_ERROR_PERM: (void) fprintf(stderr, "%s: %s\n", cmdName, gettext("permission denied")); break; case STMF_ERROR_NOT_FOUND: /* No error here */ return (0); break; default: (void) fprintf(stderr, "%s: %s\n", cmdName, gettext("get extended properties failed")); break; } return (1); } print_guid((uint8_t *)guid, stdout); stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_SIZE, propVal, &propValSize); if (stmfRet == STMF_STATUS_SUCCESS) { (void) printf(" %-19s ", propVal); } else if (stmfRet == STMF_ERROR_NO_PROP) { (void) printf("not set\n"); } else { (void) printf("<error retrieving property>\n"); ret++; } stmfRet = stmfGetLuProp(hdl, STMF_LU_PROP_FILENAME, propVal, &propValSize); if (stmfRet == STMF_STATUS_SUCCESS) { (void) printf("%s\n", propVal); } else if (stmfRet == STMF_ERROR_NO_PROP) { (void) printf("not set\n"); } else { (void) printf("<error retrieving property>\n"); ret++; } (void) stmfFreeLuResource(hdl); return (ret); }
int main(int argc, char **argv) { vmi_instance_t vmi; /* this is the VM that we are looking at */ if (argc != 3) { printf("Usage: %s name|domid <domain name|domain id>\n", argv[0]); return 1; } // if uint32_t domid = VMI_INVALID_DOMID; GHashTable *config = g_hash_table_new(g_str_hash, g_str_equal); if(strcmp(argv[1],"name")==0) { g_hash_table_insert(config, "name", argv[2]); } else if(strcmp(argv[1],"domid")==0) { domid = atoi(argv[2]); g_hash_table_insert(config, "domid", &domid); } else { printf("You have to specify either name or domid!\n"); return 1; } /* partialy initialize the libvmi library */ if (vmi_init_custom(&vmi, VMI_AUTO | VMI_INIT_PARTIAL | VMI_CONFIG_GHASHTABLE, config) == VMI_FAILURE) { printf("Failed to init LibVMI library.\n"); g_hash_table_destroy(config); return 1; } g_hash_table_destroy(config); /* the nice thing about the windows kernel is that it's page aligned */ uint32_t i; uint32_t found = 0; for(i = 0; i < MAX_SEARCH_SIZE; i += PAGE_SIZE) { uint8_t pe[MAX_HEADER_SIZE]; if(VMI_SUCCESS == peparse_get_image_phys(vmi, i, MAX_HEADER_SIZE, pe)) { if(VMI_SUCCESS == is_WINDOWS_KERNEL(vmi, i, pe)) { printf("Windows Kernel found @ 0x%"PRIx32"\n", i); print_os_version(vmi, i, pe); print_guid(vmi, i, pe); print_pe_header(vmi, i, pe); found=1; break; } } } /* cleanup any memory associated with the LibVMI instance */ vmi_destroy(vmi); if(found) return 0; return 1; }
static void dump_msft_guidentry(int n) { print_begin_block_id("GuidEntry", n); print_guid("guid"); print_hex("hreftype"); print_hex("next_hash"); print_end_block(); }
void main_entry(void) { TBeaconBuffer pkt; const TiBeacon* ib = (TiBeacon*)&pkt.buf[BT_IB_PREFIX_SIZE]; uint32_t tag_id; /* enabled LED output */ nrf_gpio_cfg_output(CONFIG_LED_PIN); nrf_gpio_pin_set(CONFIG_LED_PIN); /* enabled input pin */ nrf_gpio_cfg_input(CONFIG_SWITCH_PIN, NRF_GPIO_PIN_NOPULL); /* initialize UART */ uart_init(); /* start timer */ timer_init(); /* calculate tag ID from NRF_FICR->DEVICEID */ tag_id = crc32((void*)&NRF_FICR->DEVICEID, sizeof(NRF_FICR->DEVICEID)); /* start radio */ debug_printf("\n\rInitializing Reader[%08X] v" PROGRAM_VERSION "\n\r", tag_id); radio_init(); /* enter main loop */ nrf_gpio_pin_clear(CONFIG_LED_PIN); while(TRUE) { if(!radio_rx(&pkt)) __WFE(); else /* check for iBeacon signature */ if( (pkt.buf[1] >= 36) && !memcmp( &pkt.buf[BT_PREFIX+BT_MAC_SIZE], &g_iBeacon_sig, sizeof(g_iBeacon_sig) ) ) { debug_printf("> "); print_guid(ib->guid); debug_printf(",%i,%i,0x%04X,0x%04X,%i\n\r", pkt.rssi, ib->txpower, ntohs(ib->major), ntohs(ib->minor), pkt.channel ); } } }
int main(int argc, char **argv) { vmi_instance_t vmi; /* this is the VM that we are looking at */ if (argc != 2) { printf("Usage: %s <domain name>\n", argv[0]); return 1; } // if /* partialy initialize the libvmi library */ if (vmi_init(&vmi, VMI_AUTO | VMI_INIT_PARTIAL, argv[1]) == VMI_FAILURE) { printf("Failed to init LibVMI library.\n"); return 1; } /* the nice thing about the windows kernel is that it's page aligned */ uint32_t i; uint32_t found = 0; for(i = 0; i < MAX_SEARCH_SIZE; i += PAGE_SIZE) { uint8_t pe[MAX_HEADER_SIZE]; if(VMI_SUCCESS == peparse_get_image_phys(vmi, i, MAX_HEADER_SIZE, pe)) { if(VMI_SUCCESS == is_WINDOWS_KERNEL(vmi, i, pe)) { printf("Windows Kernel found @ 0x%"PRIx32"\n", i); print_os_version(vmi, i, pe); print_guid(vmi, i, pe); print_pe_header(vmi, i, pe); found=1; break; } } } /* cleanup any memory associated with the LibVMI instance */ vmi_destroy(vmi); if(found) return 0; return 1; }
void UVCCamDevice::_ParseVideoControl(const usbvc_class_descriptor* _descriptor, size_t len) { switch (_descriptor->descriptorSubtype) { case VC_HEADER: { if (fHeaderDescriptor != NULL) { printf("ERROR: multiple VC_HEADER! Skipping...\n"); break; } fHeaderDescriptor = (usbvc_interface_header_descriptor*)malloc(len); memcpy(fHeaderDescriptor, _descriptor, len); printf("VC_HEADER:\tUVC v%x.%02x, clk %.5f MHz\n", fHeaderDescriptor->version >> 8, fHeaderDescriptor->version & 0xff, fHeaderDescriptor->clockFrequency / 1000000.0); for (uint8 i = 0; i < fHeaderDescriptor->numInterfacesNumbers; i++) { printf("\tStreaming Interface %d\n", fHeaderDescriptor->interfaceNumbers[i]); } break; } case VC_INPUT_TERMINAL: { const usbvc_input_terminal_descriptor* descriptor = (const usbvc_input_terminal_descriptor*)_descriptor; printf("VC_INPUT_TERMINAL:\tid=%d,type=%04x,associated terminal=" "%d\n", descriptor->terminalID, descriptor->terminalType, descriptor->associatedTerminal); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->terminal)); if (descriptor->terminalType == 0x201) { const usbvc_camera_terminal_descriptor* desc = (const usbvc_camera_terminal_descriptor*)descriptor; printf("\tObjectiveFocalLength Min/Max %d/%d\n", desc->objectiveFocalLengthMin, desc->objectiveFocalLengthMax); printf("\tOcularFocalLength %d\n", desc->ocularFocalLength); printf("\tControlSize %d\n", desc->controlSize); } break; } case VC_OUTPUT_TERMINAL: { const usbvc_output_terminal_descriptor* descriptor = (const usbvc_output_terminal_descriptor*)_descriptor; printf("VC_OUTPUT_TERMINAL:\tid=%d,type=%04x,associated terminal=" "%d, src id=%d\n", descriptor->terminalID, descriptor->terminalType, descriptor->associatedTerminal, descriptor->sourceID); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->terminal)); break; } case VC_SELECTOR_UNIT: { const usbvc_selector_unit_descriptor* descriptor = (const usbvc_selector_unit_descriptor*)_descriptor; printf("VC_SELECTOR_UNIT:\tid=%d,#pins=%d\n", descriptor->unitID, descriptor->numInputPins); printf("\t"); for (uint8 i = 0; i < descriptor->numInputPins; i++) printf("%d ", descriptor->sourceID[i]); printf("\n"); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->Selector())); break; } case VC_PROCESSING_UNIT: { const usbvc_processing_unit_descriptor* descriptor = (const usbvc_processing_unit_descriptor*)_descriptor; fControlRequestIndex = fControlIndex + (descriptor->unitID << 8); printf("VC_PROCESSING_UNIT:\t unit id=%d,src id=%d, digmul=%d\n", descriptor->unitID, descriptor->sourceID, descriptor->maxMultiplier); printf("\tbControlSize=%d\n", descriptor->controlSize); if (descriptor->controlSize >= 1) { if (descriptor->controls[0] & 1) printf("\tBrightness\n"); if (descriptor->controls[0] & 2) printf("\tContrast\n"); if (descriptor->controls[0] & 4) printf("\tHue\n"); if (descriptor->controls[0] & 8) printf("\tSaturation\n"); if (descriptor->controls[0] & 16) printf("\tSharpness\n"); if (descriptor->controls[0] & 32) printf("\tGamma\n"); if (descriptor->controls[0] & 64) printf("\tWhite Balance Temperature\n"); if (descriptor->controls[0] & 128) printf("\tWhite Balance Component\n"); } if (descriptor->controlSize >= 2) { if (descriptor->controls[1] & 1) printf("\tBacklight Compensation\n"); if (descriptor->controls[1] & 2) printf("\tGain\n"); if (descriptor->controls[1] & 4) printf("\tPower Line Frequency\n"); if (descriptor->controls[1] & 8) printf("\t[AUTO] Hue\n"); if (descriptor->controls[1] & 16) printf("\t[AUTO] White Balance Temperature\n"); if (descriptor->controls[1] & 32) printf("\t[AUTO] White Balance Component\n"); if (descriptor->controls[1] & 64) printf("\tDigital Multiplier\n"); if (descriptor->controls[1] & 128) printf("\tDigital Multiplier Limit\n"); } if (descriptor->controlSize >= 3) { if (descriptor->controls[2] & 1) printf("\tAnalog Video Standard\n"); if (descriptor->controls[2] & 2) printf("\tAnalog Video Lock Status\n"); } printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->Processing())); if (descriptor->VideoStandards() & 2) printf("\tNTSC 525/60\n"); if (descriptor->VideoStandards() & 4) printf("\tPAL 625/50\n"); if (descriptor->VideoStandards() & 8) printf("\tSECAM 625/50\n"); if (descriptor->VideoStandards() & 16) printf("\tNTSC 625/50\n"); if (descriptor->VideoStandards() & 32) printf("\tPAL 525/60\n"); break; } case VC_EXTENSION_UNIT: { const usbvc_extension_unit_descriptor* descriptor = (const usbvc_extension_unit_descriptor*)_descriptor; printf("VC_EXTENSION_UNIT:\tid=%d, guid=", descriptor->unitID); print_guid(descriptor->guidExtensionCode); printf("\n\t#ctrls=%d, #pins=%d\n", descriptor->numControls, descriptor->numInputPins); printf("\t"); for (uint8 i = 0; i < descriptor->numInputPins; i++) printf("%d ", descriptor->sourceID[i]); printf("\n"); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(descriptor->Extension())); break; } default: printf("Unknown control %d\n", _descriptor->descriptorSubtype); } }
void UVCCamDevice::_ParseVideoStreaming(const usbvc_class_descriptor* _descriptor, size_t len) { switch (_descriptor->descriptorSubtype) { case VS_INPUT_HEADER: { const usbvc_input_header_descriptor* descriptor = (const usbvc_input_header_descriptor*)_descriptor; printf("VS_INPUT_HEADER:\t#fmts=%d,ept=0x%x\n", descriptor->numFormats, descriptor->endpointAddress); if (descriptor->info & 1) printf("\tDynamic Format Change supported\n"); printf("\toutput terminal id=%d\n", descriptor->terminalLink); printf("\tstill capture method=%d\n", descriptor->stillCaptureMethod); if (descriptor->triggerSupport) { printf("\ttrigger button fixed to still capture=%s\n", descriptor->triggerUsage ? "no" : "yes"); } const uint8* controls = descriptor->controls; for (uint8 i = 0; i < descriptor->numFormats; i++, controls += descriptor->controlSize) { printf("\tfmt%d: %s %s %s %s - %s %s\n", i, (*controls & 1) ? "wKeyFrameRate" : "", (*controls & 2) ? "wPFrameRate" : "", (*controls & 4) ? "wCompQuality" : "", (*controls & 8) ? "wCompWindowSize" : "", (*controls & 16) ? "<Generate Key Frame>" : "", (*controls & 32) ? "<Update Frame Segment>" : ""); } break; } case VS_FORMAT_UNCOMPRESSED: { const usbvc_format_descriptor* descriptor = (const usbvc_format_descriptor*)_descriptor; fUncompressedFormatIndex = descriptor->formatIndex; printf("VS_FORMAT_UNCOMPRESSED:\tbFormatIdx=%d,#frmdesc=%d,guid=", descriptor->formatIndex, descriptor->numFrameDescriptors); print_guid(descriptor->uncompressed.format); printf("\n\t#bpp=%d,optfrmidx=%d,aspRX=%d,aspRY=%d\n", descriptor->uncompressed.bytesPerPixel, descriptor->uncompressed.defaultFrameIndex, descriptor->uncompressed.aspectRatioX, descriptor->uncompressed.aspectRatioY); printf("\tbmInterlaceFlags:\n"); if (descriptor->uncompressed.interlaceFlags & 1) printf("\tInterlaced stream or variable\n"); printf("\t%d fields per frame\n", (descriptor->uncompressed.interlaceFlags & 2) ? 1 : 2); if (descriptor->uncompressed.interlaceFlags & 4) printf("\tField 1 first\n"); printf("\tField Pattern: "); switch ((descriptor->uncompressed.interlaceFlags & 0x30) >> 4) { case 0: printf("Field 1 only\n"); break; case 1: printf("Field 2 only\n"); break; case 2: printf("Regular pattern of fields 1 and 2\n"); break; case 3: printf("Random pattern of fields 1 and 2\n"); break; } if (descriptor->uncompressed.copyProtect) printf("\tRestrict duplication\n"); break; } case VS_FRAME_MJPEG: case VS_FRAME_UNCOMPRESSED: { const usbvc_frame_descriptor* descriptor = (const usbvc_frame_descriptor*)_descriptor; if (_descriptor->descriptorSubtype == VS_FRAME_UNCOMPRESSED) { printf("VS_FRAME_UNCOMPRESSED:"); fUncompressedFrames.AddItem( new usbvc_frame_descriptor(*descriptor)); } else { printf("VS_FRAME_MJPEG:"); fMJPEGFrames.AddItem(new usbvc_frame_descriptor(*descriptor)); } printf("\tbFrameIdx=%d,stillsupported=%s," "fixedframerate=%s\n", descriptor->frameIndex, (descriptor->capabilities & 1) ? "yes" : "no", (descriptor->capabilities & 2) ? "yes" : "no"); printf("\twidth=%u,height=%u,min/max bitrate=%lu/%lu, maxbuf=%lu\n", descriptor->width, descriptor->height, descriptor->minBitRate, descriptor->maxBitRate, descriptor->maxVideoFrameBufferSize); printf("\tdefault frame interval: %lu, #intervals(0=cont): %d\n", descriptor->defaultFrameInterval, descriptor->frameIntervalType); if (descriptor->frameIntervalType == 0) { printf("min/max frame interval=%lu/%lu, step=%lu\n", descriptor->continuous.minFrameInterval, descriptor->continuous.maxFrameInterval, descriptor->continuous.frameIntervalStep); } else for (uint8 i = 0; i < descriptor->frameIntervalType; i++) { printf("\tdiscrete frame interval: %lu\n", descriptor->discreteFrameIntervals[i]); } break; } case VS_COLORFORMAT: { const usbvc_color_matching_descriptor* descriptor = (const usbvc_color_matching_descriptor*)_descriptor; printf("VS_COLORFORMAT:\n\tbColorPrimaries: "); switch (descriptor->colorPrimaries) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709,sRGB\n"); break; case 2: printf("BT.470-2(M)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M\n"); break; case 5: printf("SMPTE 240M\n"); break; default: printf("Invalid (%d)\n", descriptor->colorPrimaries); } printf("\tbTransferCharacteristics: "); switch (descriptor->transferCharacteristics) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709\n"); break; case 2: printf("BT.470-2(M)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M\n"); break; case 5: printf("SMPTE 240M\n"); break; case 6: printf("Linear (V=Lc)\n"); break; case 7: printf("sRGB\n"); break; default: printf("Invalid (%d)\n", descriptor->transferCharacteristics); } printf("\tbMatrixCoefficients: "); switch (descriptor->matrixCoefficients) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709\n"); break; case 2: printf("FCC\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M (BT.601)\n"); break; case 5: printf("SMPTE 240M\n"); break; default: printf("Invalid (%d)\n", descriptor->matrixCoefficients); } break; } case VS_OUTPUT_HEADER: { const usbvc_output_header_descriptor* descriptor = (const usbvc_output_header_descriptor*)_descriptor; printf("VS_OUTPUT_HEADER:\t#fmts=%d,ept=0x%x\n", descriptor->numFormats, descriptor->endpointAddress); printf("\toutput terminal id=%d\n", descriptor->terminalLink); const uint8* controls = descriptor->controls; for (uint8 i = 0; i < descriptor->numFormats; i++, controls += descriptor->controlSize) { printf("\tfmt%d: %s %s %s %s\n", i, (*controls & 1) ? "wKeyFrameRate" : "", (*controls & 2) ? "wPFrameRate" : "", (*controls & 4) ? "wCompQuality" : "", (*controls & 8) ? "wCompWindowSize" : ""); } break; } case VS_STILL_IMAGE_FRAME: { const usbvc_still_image_frame_descriptor* descriptor = (const usbvc_still_image_frame_descriptor*)_descriptor; printf("VS_STILL_IMAGE_FRAME:\t#imageSizes=%d,compressions=%d," "ept=0x%x\n", descriptor->numImageSizePatterns, descriptor->NumCompressionPatterns(), descriptor->endpointAddress); for (uint8 i = 0; i < descriptor->numImageSizePatterns; i++) { printf("imageSize%d: %dx%d\n", i, descriptor->imageSizePatterns[i].width, descriptor->imageSizePatterns[i].height); } for (uint8 i = 0; i < descriptor->NumCompressionPatterns(); i++) { printf("compression%d: %d\n", i, descriptor->CompressionPatterns()[i]); } break; } case VS_FORMAT_MJPEG: { const usbvc_format_descriptor* descriptor = (const usbvc_format_descriptor*)_descriptor; fMJPEGFormatIndex = descriptor->formatIndex; printf("VS_FORMAT_MJPEG:\tbFormatIdx=%d,#frmdesc=%d\n", descriptor->formatIndex, descriptor->numFrameDescriptors); printf("\t#flgs=%d,optfrmidx=%d,aspRX=%d,aspRY=%d\n", descriptor->mjpeg.flags, descriptor->mjpeg.defaultFrameIndex, descriptor->mjpeg.aspectRatioX, descriptor->mjpeg.aspectRatioY); printf("\tbmInterlaceFlags:\n"); if (descriptor->mjpeg.interlaceFlags & 1) printf("\tInterlaced stream or variable\n"); printf("\t%d fields per frame\n", (descriptor->mjpeg.interlaceFlags & 2) ? 1 : 2); if (descriptor->mjpeg.interlaceFlags & 4) printf("\tField 1 first\n"); printf("\tField Pattern: "); switch ((descriptor->mjpeg.interlaceFlags & 0x30) >> 4) { case 0: printf("Field 1 only\n"); break; case 1: printf("Field 2 only\n"); break; case 2: printf("Regular pattern of fields 1 and 2\n"); break; case 3: printf("Random pattern of fields 1 and 2\n"); break; } if (descriptor->mjpeg.copyProtect) printf("\tRestrict duplication\n"); break; } case VS_FORMAT_MPEG2TS: printf("VS_FORMAT_MPEG2TS:\t\n"); break; case VS_FORMAT_DV: printf("VS_FORMAT_DV:\t\n"); break; case VS_FORMAT_FRAME_BASED: printf("VS_FORMAT_FRAME_BASED:\t\n"); break; case VS_FRAME_FRAME_BASED: printf("VS_FRAME_FRAME_BASED:\t\n"); break; case VS_FORMAT_STREAM_BASED: printf("VS_FORMAT_STREAM_BASED:\t\n"); break; default: printf("INVALID STREAM UNIT TYPE=%d!\n", _descriptor->descriptorSubtype); } }
int main(int argc, char** argv) { if (argc != 2) { fprintf(stderr, "usage: fileid <file>\n"); return 1; } HANDLE file = CreateFileA(argv[1], GENERIC_READ, FILE_SHARE_READ, nullptr, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, nullptr); if (file == INVALID_HANDLE_VALUE) { fprintf(stderr, "Couldn't open file: %s\n", argv[1]); return 1; } HANDLE mapFile = CreateFileMappingA(file, NULL, PAGE_READONLY, 0, 0, 0); if (mapFile == nullptr) { fprintf(stderr, "Couldn't create file mapping\n"); CloseHandle(file); return 1; } uint8_t* base = reinterpret_cast<uint8_t*>(MapViewOfFile(mapFile, FILE_MAP_READ, 0, 0, 0)); if (base == nullptr) { fprintf(stderr, "Couldn't map file\n"); CloseHandle(mapFile); CloseHandle(file); return 1; } DWORD size; PIMAGE_DEBUG_DIRECTORY debug_dir = reinterpret_cast<PIMAGE_DEBUG_DIRECTORY>( ImageDirectoryEntryToDataEx(base, FALSE, IMAGE_DIRECTORY_ENTRY_DEBUG, &size, nullptr)); bool found = false; if (debug_dir->Type == IMAGE_DEBUG_TYPE_CODEVIEW) { CV_INFO_PDB70* cv = reinterpret_cast<CV_INFO_PDB70*>(base + debug_dir->PointerToRawData); if (cv->CvSignature == CV_SIGNATURE_RSDS) { found = true; print_guid(cv->Signature, cv->Age); } } UnmapViewOfFile(base); CloseHandle(mapFile); CloseHandle(file); return found ? 0 : 1; }
void UVCCamDevice::ParseVideoStreaming(const uint8* buffer, size_t len) { int c, i, sz; switch(buffer[2]) { case VS_INPUT_HEADER: c = buffer[3]; printf("VS_INPUT_HEADER:\t#fmts=%d,ept=0x%x\n", c, buffer[6]); if (buffer[7] & 1) printf("\tDynamic Format Change supported\n"); printf("\toutput terminal id=%d\n", buffer[8]); printf("\tstill capture method=%d\n", buffer[9]); if (buffer[10]) printf("\ttrigger button fixed to still capture=%s\n", buffer[11] ? "no" : "yes"); sz = buffer[12]; for (i=0; i < c; i++) { printf("\tfmt%d: %s %s %s %s - %s %s\n", i, (buffer[13+(sz*i)] & 1) ? "wKeyFrameRate" : "", (buffer[13+(sz*i)] & 2) ? "wPFrameRate" : "", (buffer[13+(sz*i)] & 4) ? "wCompQuality" : "", (buffer[13+(sz*i)] & 8) ? "wCompWindowSize" : "", (buffer[13+(sz*i)] & 16) ? "<Generate Key Frame>" : "", (buffer[13+(sz*i)] & 32) ? "<Update Frame Segment>" : ""); } break; case VS_FORMAT_UNCOMPRESSED: c = buffer[4]; printf("VS_FORMAT_UNCOMPRESSED:\tbFormatIdx=%d,#frmdesc=%d,guid=", buffer[3], c); print_guid(buffer+5); printf("\n\t#bpp=%d,optfrmidx=%d,aspRX=%d,aspRY=%d\n", buffer[21], buffer[22], buffer[23], buffer[24]); printf("\tbmInterlaceFlags:\n"); if (buffer[25] & 1) printf("\tInterlaced stream or variable\n"); printf("\t%d fields per frame\n", (buffer[25] & 2) ? 1 : 2); if (buffer[25] & 4) printf("\tField 1 first\n"); printf("\tField Pattern: "); switch((buffer[25] & 0x30) >> 4) { case 0: printf("Field 1 only\n"); break; case 1: printf("Field 2 only\n"); break; case 2: printf("Regular pattern of fields 1 and 2\n"); break; case 3: printf("Random pattern of fields 1 and 2\n"); break; } if (buffer[26]) printf("\tRestrict duplication\n"); break; break; case VS_FRAME_UNCOMPRESSED: printf("VS_FRAME_UNCOMPRESSED:\tbFrameIdx=%d,stillsupported=%s,fixedfrmrate=%s\n", buffer[3], (buffer[4]&1)?"yes":"no", (buffer[4]&2)?"yes":"no"); printf("\twidth=%u,height=%u,min/max bitrate=%lu/%lu, maxbuf=%lu\n", *(uint16*)(buffer+5), *(uint16*)(buffer+7), *(uint32*)(buffer+9), *(uint32*)(buffer+13), *(uint32*)(buffer+17)); printf("\tframe interval: %lu, #intervals(0=cont): %d\n", *(uint32*)(buffer+21), buffer[25]); //TODO print interval table break; case VS_COLORFORMAT: printf("VS_COLORFORMAT:\n\tbColorPrimaries: "); switch(buffer[3]) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709,sRGB\n"); break; case 2: printf("BT.470-2(M)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M\n"); break; case 5: printf("SMPTE 240M\n"); break; default: printf("Invalid (%d)\n", buffer[3]); } printf("\tbTransferCharacteristics: "); switch(buffer[4]) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709\n"); break; case 2: printf("BT.470-2(M)\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M\n"); break; case 5: printf("SMPTE 240M\n"); break; case 6: printf("Linear (V=Lc)\n"); break; case 7: printf("sRGB\n"); break; default: printf("Invalid (%d)\n", buffer[4]); } printf("\tbMatrixCoefficients: "); switch(buffer[5]) { case 0: printf("Unspecified\n"); break; case 1: printf("BT.709\n"); break; case 2: printf("FCC\n"); break; case 3: printf("BT.470-2(B,G)\n"); break; case 4: printf("SMPTE 170M (BT.601)\n"); break; case 5: printf("SMPTE 240M\n"); break; default: printf("Invalid (%d)\n", buffer[5]); } break; case VS_OUTPUT_HEADER: printf("VS_OUTPUT_HEADER:\t\n"); break; case VS_STILL_IMAGE_FRAME: printf("VS_STILL_IMAGE_FRAME:\t\n"); break; case VS_FORMAT_MJPEG: printf("VS_FORMAT_MJPEG:\t\n"); break; case VS_FRAME_MJPEG: printf("VS_FRAME_MJPEG:\t\n"); break; case VS_FORMAT_MPEG2TS: printf("VS_FORMAT_MPEG2TS:\t\n"); break; case VS_FORMAT_DV: printf("VS_FORMAT_DV:\t\n"); break; case VS_FORMAT_FRAME_BASED: printf("VS_FORMAT_FRAME_BASED:\t\n"); break; case VS_FRAME_FRAME_BASED: printf("VS_FRAME_FRAME_BASED:\t\n"); break; case VS_FORMAT_STREAM_BASED: printf("VS_FORMAT_STREAM_BASED:\t\n"); break; default: printf("INVALID STREAM UNIT TYPE=%d!\n", buffer[2]); } }
void UVCCamDevice::ParseVideoControl(const uint8* buffer, size_t len) { int c, i; switch(buffer[2]) { case VC_HEADER: printf("VC_HEADER:\tUVC v%04x, clk %lu Hz\n", *(uint16*)(buffer+3), *(uint32*)(buffer+7)); c = (len >= 12) ? buffer[11] : 0; for (i=0; i < c; i++) printf("\tStreaming Interface %d\n", buffer[12+i]); break; case VC_INPUT_TERMINAL: printf("VC_INPUT_TERMINAL:\tid=%d,type=%04x,associated terminal=%d\n", buffer[3], *(uint16*)(buffer+4), buffer[6]); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(buffer[7])); break; case VC_OUTPUT_TERMINAL: printf("VC_OUTPUT_TERMINAL:\tid=%d,type=%04x,associated terminal=%d, src id=%d\n", buffer[3], *(uint16*)(buffer+4), buffer[6], buffer[7]); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(buffer[8])); break; case VC_SELECTOR_UNIT: printf("VC_SELECTOR_UNIT:\tid=%d,#pins=%d\n", buffer[3], buffer[4]); printf("\t"); for (i=0; i < buffer[4]; i++) printf("%d ", buffer[5+i]); printf("\n"); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(buffer[5+buffer[4]])); break; case VC_PROCESSING_UNIT: printf("VC_PROCESSING_UNIT:\tid=%d,src id=%d, digmul=%d\n", buffer[3], buffer[4], *(uint16*)(buffer+5)); c = buffer[7]; printf("\tbControlSize=%d\n", c); if (c >= 1) { if (buffer[8] & 1) printf("\tBrightness\n"); if (buffer[8] & 2) printf("\tContrast\n"); if (buffer[8] & 4) printf("\tHue\n"); if (buffer[8] & 8) printf("\tSaturation\n"); if (buffer[8] & 16) printf("\tSharpness\n"); if (buffer[8] & 32) printf("\tGamma\n"); if (buffer[8] & 64) printf("\tWhite Balance Temperature\n"); if (buffer[8] & 128) printf("\tWhite Balance Component\n"); } if (c >= 2) { if (buffer[9] & 1) printf("\tBacklight Compensation\n"); if (buffer[9] & 2) printf("\tGain\n"); if (buffer[9] & 4) printf("\tPower Line Frequency\n"); if (buffer[9] & 8) printf("\t[AUTO] Hue\n"); if (buffer[9] & 16) printf("\t[AUTO] White Balance Temperature\n"); if (buffer[9] & 32) printf("\t[AUTO] White Balance Component\n"); if (buffer[9] & 64) printf("\tDigital Multiplier\n"); if (buffer[9] & 128) printf("\tDigital Multiplier Limit\n"); } if (c >= 3) { if (buffer[10] & 1) printf("\tAnalog Video Standard\n"); if (buffer[10] & 2) printf("\tAnalog Video Lock Status\n"); } printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(buffer[8+c])); i=buffer[9+c]; if (i & 2) printf("\tNTSC 525/60\n"); if (i & 4) printf("\tPAL 625/50\n"); if (i & 8) printf("\tSECAM 625/50\n"); if (i & 16) printf("\tNTSC 625/50\n"); if (i & 32) printf("\tPAL 525/60\n"); break; case VC_EXTENSION_UNIT: printf("VC_EXTENSION_UNIT:\tid=%d, guid=", buffer[3]); print_guid(buffer+4); printf("\n\t#ctrls=%d, #pins=%d\n", buffer[20], buffer[21]); c = buffer[21]; printf("\t"); for (i=0; i < c; i++) printf("%d ", buffer[22+i]); printf("\n"); printf("\tDesc: %s\n", fDevice->DecodeStringDescriptor(buffer[23+c+buffer[22+c]])); break; default: printf("Unknown control %d\n", buffer[2]); } }
int main(int argc, char **argv) { vmi_instance_t vmi = NULL; vmi_mode_t mode; /* this is the VM that we are looking at */ if (argc != 3) { printf("Usage: %s name|domid <domain name|domain id>\n", argv[0]); return 1; } // if void *domain; uint64_t domid = VMI_INVALID_DOMID; uint64_t init_flags = 0; if(strcmp(argv[1],"name")==0) { domain = (void*)argv[2]; init_flags |= VMI_INIT_DOMAINNAME; } else if(strcmp(argv[1],"domid")==0) { domid = strtoull(argv[2], NULL, 0); domain = (void*)&domid; init_flags |= VMI_INIT_DOMAINID; } else { printf("You have to specify either name or domid!\n"); return 1; } if (VMI_FAILURE == vmi_get_access_mode(vmi, domain, init_flags, NULL, &mode) ) return 1; /* initialize the libvmi library */ if (VMI_FAILURE == vmi_init(&vmi, mode, domain, init_flags, NULL, NULL)) { printf("Failed to init LibVMI library.\n"); return 1; } max_mem = vmi_get_max_physical_address(vmi); /* the nice thing about the windows kernel is that it's page aligned */ uint32_t found = 0; access_context_t ctx = { .translate_mechanism = VMI_TM_NONE, }; for(ctx.addr = 0; ctx.addr < max_mem; ctx.addr += PAGE_SIZE) { uint8_t pe[MAX_HEADER_SIZE]; if(VMI_SUCCESS == peparse_get_image(vmi, &ctx, MAX_HEADER_SIZE, pe)) { if(VMI_SUCCESS == is_WINDOWS_KERNEL(vmi, ctx.addr, pe)) { printf("Windows Kernel found @ 0x%" PRIx64 "\n", ctx.addr); print_os_version(pe); print_guid(vmi, ctx.addr, pe); print_pe_header(vmi, ctx.addr, pe); found=1; break; } } } /* cleanup any memory associated with the LibVMI instance */ vmi_destroy(vmi); if(found) return 0; return 1; }
int WMA_File::asfReadHeader() { int noEndlessLoop = 0; // ASFContext asf; TAGGER_GUID g; // int size, i; int64_t gsize; get_guid(this, &g); if (memcmp(&g, &asf_header, sizeof(TAGGER_GUID))) goto fail; get_le64(this); get_le32(this); get_byte(this); get_byte(this); // memset(&asf->asfid2avid, -1, sizeof(asf->asfid2avid)); for(;;) { noEndlessLoop++; if( noEndlessLoop > 256 ) { goto fail; } get_guid(this, &g); gsize = get_le64(this); // #ifdef DEBUG // printf("%08Lx: ", url_ftell(f) - 24); // print_guid(&g); // printf(" size=0x%Lx\n", gsize); // #endif if (gsize < 24) goto fail; if (!memcmp(&g, &file_header, sizeof(TAGGER_GUID))) { get_guid(this, &g); // asf.hdr.file_size = get_le64(this); // asf.hdr.create_time = get_le64(this); // asf.hdr.packets_count = get_le64(this); // asf.hdr.play_time int64_t play_time = get_le64(this); // play_time is in 100ns = 10^-7s units if (wmaProperties) wmaProperties->m_length = (play_time / 10000000L); // asf.hdr.send_time = get_le64(this); // asf.hdr.preroll = get_le32(this); // asf.hdr.ignore = get_le32(this); // asf.hdr.flags = get_le32(this); // asf.hdr.min_pktsize = get_le32(this); // asf.hdr.max_pktsize = get_le32(this); // asf.hdr.max_bitrate = get_le32(this); // asf.packet_size = asf.hdr.max_pktsize; // asf.nb_packets = asf.hdr.packets_count; } else if (!memcmp(&g, &stream_header, sizeof(TAGGER_GUID))) { //int type; int type_specific_size; //unsigned int tag1; int64_t pos1, pos2; pos1 = Tell(); get_guid(this, &g); if (!memcmp(&g, &audio_stream, sizeof(TAGGER_GUID))) { // type = CODEC_TYPE_AUDIO; } else { wxLogDebug(wxT("Tagger: WMA file contains non-audio streams.")); return false; } get_guid(this, &g); get_le64(this); // total size type_specific_size = get_le32(this); get_le32(this); get_le16(this) /*& 0x7f*/; /* stream id */ get_le32(this); // st->codec.codec_type = type; // /* 1 fps default (XXX: put 0 fps instead) */ // st->codec.frame_rate = 1000; // st->codec.frame_rate_base = 1; // if (type == CODEC_TYPE_AUDIO) { getWavHeader(type_specific_size); // st->need_parsing = 1; /* We have to init the frame size at some point .... */ pos2 = Tell(); if (gsize > (pos2 + 8 - pos1 + 24)) { /* asf_st.ds_span = */ get_byte(this); /* asf_st.ds_packet_size = */ get_le16(this); // asf_st.ds_chunk_size = get_le16(this); // asf_st.ds_data_size = get_le16(this); // asf_st.ds_silence_data = get_byte(this); } pos2 = Tell(); Seek(gsize - (pos2 - pos1 + 24), SJ_SEEK_CUR); } else if (!memcmp(&g, &data_header, sizeof(TAGGER_GUID))) { break; } else if (!memcmp(&g, &comment_header, sizeof(TAGGER_GUID))) { int len1, len2, len3, len4, len5; len1 = get_le16(this); len2 = get_le16(this); len3 = get_le16(this); len4 = get_le16(this); len5 = get_le16(this); if (wmaTag) { wxString s; //char buf[1]; get_str16_nolen(this, len1, s); wmaTag->setTitle(s); get_str16_nolen(this, len2, s); wmaTag->setLeadArtist(s); get_str16_nolen(this, len3, s); // Copyright notice get_str16_nolen(this, len4, s); wmaTag->setComment(s); Seek(len5, SJ_SEEK_CUR); } else { Seek(len1+len2+len3+len4+len5, SJ_SEEK_CUR); } } else if (!memcmp(&g, &extended_content_header, sizeof(TAGGER_GUID))) { int desc_count, i; desc_count = get_le16(this); for(i=0; i<desc_count; i++) { int name_len,value_type,value_len = 0; int64_t value_num = 0; wxString name, value; name_len = get_le16(this); get_str16_nolen(this, name_len, name); value_type = get_le16(this); value_len = get_le16(this); //debug (name); // printf ("value_type is %d; name_len is %d\n", value_type, name_len); if ((value_type == 0) || (value_type == 1)) // unicode or byte { get_str16_nolen(this, value_len, value); //debug ("string value:"); //debug(value); if ( wmaTag ) { if (name == wxT("WM/AlbumTitle")) { wmaTag->setAlbum(value); } if (name == wxT("WM/Genre")) { wmaTag->setGenre(value); } if (name == wxT("WM/Year")) { long l; if(!value.ToLong(&l)){l=0;} wmaTag->setYear(l); } if (name==wxT("WM/TrackNumber")) { long l; if(!value.ToLong(&l)){l=0;} wmaTag->setTrack(l, 0); } } } if ((value_type >= 2) && (value_type <= 5)) // boolean or DWORD or QWORD or WORD { if (value_type==2) value_num = get_le32(this); if (value_type==3) value_num = get_le32(this); if (value_type==4) value_num = get_le64(this); if (value_type==5) value_num = get_le16(this); //printf("numerical value: %d\n", value_num); if (wmaTag) { if (name==wxT("WM/Track")) { wmaTag->setTrack(value_num + 1, 0); } if (name==wxT("WM/TrackNumber")) { wmaTag->setTrack(value_num, 0); } } } } #if 0 } else if (!memcmp(&g, &head1_guid, sizeof(TAGGER_GUID))) { int v1, v2; get_guid(f, &g); v1 = get_le32(this); v2 = get_le16(this); } else if (!memcmp(&g, &codec_comment_header, sizeof(TAGGER_GUID))) { int len, v1, n, num; char str[256], *q; char tag[16]; get_guid(this, &g); print_guid(&g); n = get_le32(this); for(i=0; i<n; i++) { num = get_le16(this); /* stream number */ get_str16(this, str, sizeof(str)); get_str16(this, str, sizeof(str)); len = get_le16(this); q = tag; while (len > 0) { v1 = get_byte(this); if ((q - tag) < sizeof(tag) - 1) *q++ = v1; len--; } *q = '\0'; } #endif // FIXME: Can we eliminate all further reads? // FIXME: implement EOF check // } else if (url_feof(f)) { // goto fail; } else { Seek(gsize - 24, SJ_SEEK_CUR); } } get_guid(this, &g); get_le64(this); get_byte(this); get_byte(this); // FIXME: implement EOF check // if (url_feof(f)) // goto fail; // asf->data_offset = url_ftell(f); // asf->packet_size_left = 0; return true; fail: return false; // for(i=0;i<s->nb_streams;i++) { // AVStream *st = s->streams[i]; // if (st) { // av_free(st->priv_data); // av_free(st->codec.extradata); // } // av_free(st); // } // return -1; }