Month: November 2016

bochs breakpoint panel

extended netbeans, auto scan .c/.cc/.cpp files to find my bochs breakpoint marco, double click it will jump to there. Small tool, but save me a lot of time.pause_bochs-panel

read count : 19

Visual c++ example to read mbr

Install windows ddk and run it using admin permission, otherwise all bytes that read from mbr are 0xcd. It can be compile using visual c++ community exition.

virus

#include "stdafx.h"
#include <cstdlib>
#include <windows.h>
#include <stdio.h>
#include <iostream>
#define FILE_SHARE_VALID_FLAGS (0x00000007) 
using namespace std;

short ReadSect
(
	const char *_dsk,    // disk to access
	char *&_buff,         // buffer where sector will be stored
	unsigned int _nsect   // sector number, starting with 0
)
{
	DWORD dwRead;
	wchar_t wdsk[100];
	size_t count;
	mbstowcs_s(&count, wdsk, sizeof(wdsk) / sizeof(wdsk[0]), _dsk, _TRUNCATE);
	HANDLE hDisk = CreateFile(wdsk, GENERIC_READ, FILE_SHARE_VALID_FLAGS, 0, OPEN_EXISTING, 0, 0);
	if (hDisk == INVALID_HANDLE_VALUE) // this may happen if another program is already reading from disk
	{
		CloseHandle(hDisk);
		return 1;
	}
	SetFilePointer(hDisk, _nsect * 512, 0, FILE_BEGIN); // which sector to read

	ReadFile(hDisk, _buff, 512, &dwRead, 0);  // read sector
	CloseHandle(hDisk);
	return 0;
}

int main()
{
	char *dsk = "\\\\.\\PhysicalDrive0";
	int sector = 0;

	char *buff = new char[512];
	ReadSect(dsk, buff, sector);
	for (int x = 0; x < 512; x++) {
		printf("%x ", buff[x] & 0xff);
	}
	if ((unsigned char)buff[510] == 0x55 && (unsigned char)buff[511] == 0xaa) {
		cout << "Disk is bootable!" << endl;
	}

	getchar();
	return 0;
}

read count : 88

ffmpeg and ffplay for logitech webcam

These command works on windows and capture video using my logitech C920 webcam

Save viewcam to a file, becareful, windows media play may not able to play mp4 in a very clean windows. You can save it to avi.

ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" -c copy -y c:\users\peter\desktop\a.mp4

Save viewcam video and play it using ffplay, but it has few seconds delay

ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" -c copy -y c:\users\peter\desktop\a.mp4 -c:v copy -copytb 1 -an -f mjpeg udp://127.0.0.1:1234/ | ffplay -f mjpeg p-rpbesize 32 udp://127.0.0.1:1234

Just play it by ffplay

ffmpeg -f dshow -i video="Logitech HD Pro Webcam C920" -c:v copy -copytb 1 -an -f mjpeg udp://127.0.0.1:1234/ | ffplay -f mjpeg -probesize 32 udp://127.0.0.1:1234

https://ffmpeg.zeranoe.com/forum/viewtopic.php?t=2421

read count : 91