Page 2 of 4

Re: OSDcap - Screen (OSD) capture application

Posted: Sun Oct 24, 2010 5:01 pm
by nostromo1983
Seems very interesting application, it will be helpful to make proper screenshot and not with cameras. It could be used to make a "Still image" function as i had with my old cathodic Panasonic TV. It's function to "stop" to an image when we want using a button of the remote controller, when watching TV.
Good work Geo650

Re: OSDcap - Screen (OSD) capture application

Posted: Sun Oct 24, 2010 8:02 pm
by geo650
nostromo1983 wrote:... It could be used to make a "Still image" function ... when watching TV.
I wish it could freeze live video in the future. Nowadays, it can only make OSD snapshots.

One more question from my friend, and me: how to make injection chain ? For example, when other application with injection function that catches remote buttons was loaded first, and then my OSDcap is loaded, then remote buttons presses are reported to OSDcap only, not other application. In other words, how to do this:

Code: Select all

.................................................
in loader.so:
...
   void *prev_injection = NULL;

	// Injecting!
 	int page = ((unsigned) KeyCommon_SendKeyPressInput) & ~0x0FFF;
	mprotect((void *) page, 8192, PROT_READ | PROT_WRITE | PROT_EXEC);

	if (KeyCommon_SendKeyPressInput[4] == 0xE51FF004)	// remapped already ?
	{
	   prev_injection = (void *)KeyCommon_SendKeyPressInput[5];
	   KeyCommon_SendKeyPressInput[4] = 0xE51FF004;         // <----------- BTW, what instructions are there
	   KeyCommon_SendKeyPressInput[5] = (unsigned)ex_nextinjection;
	}
	else	// first remapping?
	{
	   KeyCommon_SendKeyPressInput[4] = 0xE51FF004;         // <----------- BTW, what instructions are there? call or jump???
	   KeyCommon_SendKeyPressInput[5] = (unsigned)ex_injection;
	}
	mprotect((void *) page, 8192, PROT_READ | PROT_EXEC);

..................................................................................
in main library (assume, prev_injection was received from loader):

void nextinjection(int a, int key, int arg_r2)
{
	// gcc should put "STMFD SP!, {R4,LR}" on top, if everything goes as planned (LDMFD...? - I don't think so)
	asm volatile(
		"STMFD   SP!, {R0,R2,R3,R12}\n"		// store some registers
	);

	if (prev_injection) execute_previous_injection_function_here();   // <------- HOW ?????

	button_pressed(key);				// our function returning integer (in R0?)
	
	asm volatile(
		"MOV     R1, R0\n"			// remapped keycode
		"MOV     R6, R0\n"			// remapped keycode
		"LDMFD   SP!, {R0,R2,R3,R12}\n"		// restore registers stored before
		"LDMFD   SP!, {R4,LR}\n"		// restore ...
		"MOV     R7, R2\n"			//This is original command that we overwrite
		"LDR     R3, [R8]\n"			//This is original command that we overwrite
		"LDR     PC, =(_ZN9KeyCommon17SendKeyPressInputEii + 0x18 )\n"	//return after injection
	);
}
Without this, we cannot make any snapshot from our applications working with injection mechanism. For example, you cannot start recording with PVR app, and then make snapshot of REC icon, because after loading OSDcap, your REC button will be ignored. I think, it must be done something like interrupt vectors in PC.

Re: OSDcap - Screen (OSD) capture application

Posted: Mon Oct 25, 2010 7:43 am
by nbd
One solution is to have one common keycode injection code shared across all applications we develop. I think I wrote some ideas already to some other thread, but the basic idea was to have the keycode injection loaded once, and it would then dynamically load other libraries according to config file (and if it is not yet loaded). For example, pressing REC for the first time would load the PVR (and start recording if possible).

I don't really know if this solves your issue, but I hope it gives more ideas how to tackle this problem.

Re: OSDcap - Screen (OSD) capture application

Posted: Mon Oct 25, 2010 11:03 am
by geo650
nbd wrote:One solution is to have one common keycode injection code shared across all applications we develop...
I think that's good idea. In the other hand, you'll have to load that common "dispatcher" first and it will be not very useful for non-patched systems.

UPDATE:
I did it! Chain is working. A few moments with ARM instruction set PDF and my experience with assembler (not ARM) made it possible. Stay tuned for details.

Re: OSDcap - Screen (OSD) capture application

Posted: Mon Oct 25, 2010 7:24 pm
by geo650
Hello again!

And here we go. You can test OSDcap 0.4.
To build remote control button catching chain I made an additional function (next_injection) which is used in case any old injection has been detected. Old injection address is injected to the end of that next_injection() function. After processing new function, old one is processed, where at the very end of chain it reaches exeDSP. Quite simple, isn't it?

Source code included.

Thanks to moras86 for a very nice icon.
~Geo650

EDIT: Attachment removed due to forum quota limits and new version launched.

Re: OSDcap - Screen (OSD) capture application

Posted: Tue Oct 26, 2010 1:57 pm
by nbd
\o/

Speechless. Just awesome! This, and the C series news.. wow, this is a great day for SamyGO :)

Re: OSDcap - Screen (OSD) capture application

Posted: Wed Oct 27, 2010 11:53 pm
by geo650
New version available.
Changes:
- temporary debug log in loader (created in mtd_ram and removed if OK)
- injectso compatibility (fixed minor bug in loader).
- buttons action: now please hit PRE_CH, then 1, 2, 3, 4 or 5 numeric button to capture selected memory area.
Enjoy.

Re: OSDcap - Screen (OSD) capture application

Posted: Thu Oct 28, 2010 4:07 pm
by juusso
Thank You!
I missed an config file to set where to place captured pictures. What if i want run "game: from TV memory (not from USB) and store captured content to NFS or samba directory? Now it stores pictures within OSDcap directory.

Re: OSDcap - Screen (OSD) capture application

Posted: Thu Oct 28, 2010 7:24 pm
by geo650
juuso wrote:Thank You!
I missed an config file to set where to place captured pictures....
...and you say...
New version (I hope the last one, because I have no much time) is available for downloading.
Last changes:
- INI file with DESTINATION path
- simpler injection function
- auto-select mode (press PRE_CH, then numeric 0)
Enjoy!

Re: OSDcap - Screen (OSD) capture application

Posted: Fri Nov 05, 2010 9:55 am
by gchirtoaca
Nice utility, geo650!
Can this method be used in PVR application to record live video from other sources than internal tuner, like HDMI STB?
This way, any encryption can be bypassed.