Jump to content


Photo

GAPI to GDI wrapper for 8390

- - - - -

  • Please log in to reply
140 replies to this topic

#1
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts
mystery solved. together with schriss we finally found out why the original GAPI doesn't work. there is a miss configuration in mio8390's security system and to use direct video memory access (kernel mode) not only the GAPI dll have to be privileged signed but the application itself too. schriss wrote a small tutorial how can you do that for all your games and video applications. check this post. this is developer signing so your phone has to be unlocked (see other topics about unlocking )

never the less i updated the wrapper if someone doesn't want to bother with signing applications. but this solution is slower and doesn't work for all applications.

just install. no need for manual dll copying. (if you installed the old wrapper please uninstall it before upgrading and remove all manually copied gx.dll)

http://picard.exceed...90/gapi2gdi.exe with installer
http://picard.exceed...90/gapi2gdi.cab only cab
http://picard.exceed...90/gapi2gdi.zip source

ps: word definitions:
GDI http://msdn.microsof...e_interface.asp
GAPI http://msdn.microsof...htm/gx_bvrh.asp

Edited by picard_beta, 03 January 2005 - 07:14 PM.

  • 0

#2
the bishop

the bishop

    Enthusiast

  • Members
  • PipPipPip
  • 171 posts
  • Location:San Antonio, TX
  • Devices:Moto Q9h
i would try it but indeed my phone has bought the farm. :/

  • 0
I'm a phone-holic, please donate to support my habit! :)

#3
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts
sorry man :D

i had no luck either. i just broke one of my pda's lcd screen
tonight :cry: fortunatelly it's only for development and still usable
at an acceptable level.

ps: i had to lookup the 'bought the farm' expression :D

  • 0

#4
schriss

schriss

    Addict

  • Members
  • PipPipPipPipPip
  • 548 posts
  • Gender:Male
  • Location:Dublin
  • Devices:HTC One X Tegra 3
HOLY s***, THIS WRAPPER WORKS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Picard is a genius :lol:

Games/apps that work with wrapper:
Eclipse First Wave - WORKS! It's fast without SmartPhone Turbo activated :D
6th Gear - WORKS fast :D
SPVQuake - runs!! I hear sounds but the screen is completely white :cry:
BetaPlayer - works in GAPI mode, see benchmark results below
PocketClive (ZX Spectrum) - WORKS

BetaPlayer WORKS in GAPI mode - here are benchmark results in both: GDI and GAPI mode, tested with the same movie (crystal clear quality, link to file at the bottom) :D
Results for GAPI wrapper (WITHOUT SmartPhoneTurbo):
Average Speed: 102.55%
Original Data Rate: 401 kbit/s
Bench. Data Rate: 411 kbit/s

Results for GDI:
Average Speed: 121.60%
Original Data Rate: 401 kbit/s
Bench. Data Rate: 487 kbit/s

Results WITH SmartPhoneTurbo activated :D
Results for GAPI wrapper:
Average Speed: 112.76%
Original Data Rate: 401 kbit/s
Bench. Data Rate: 452 kbit/s

Results for GDI:
Average Speed: 130.83%
Original Data Rate: 401 kbit/s
Bench. Data Rate: 524 kbit/s

--== AND NOW RESULTS WITH ORIGINAL GAPI (BetaPlayer signed) AND TURBO ==--
Average Speed: 147.09%
Original Data Rate: 401 kbit/s
Bench. Data Rate: 589 kbit/s

The test TopGun video is here: http://www.certihost.net/smartphone/

  • 0

#5
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts
are you sure there was no old gx.dll in the application folder when the program crashed? when worked did you copied my gx.dll from windows directory to the application folder? i don't understand why you have to copy gx.dll from windows directory if there was no old gx.dll in the application folder. maybe the OS gx.dll could not be "overwritten". on pocketpc any OS dll can be patched with just simple copying a file with the same name on it. if you delete the file the original OS file will reappear.

about BetaPlaye speed: this is a GDI wrapper so using directly GDI has the same or even better speed because only the actual video area is drawn.

  • 0

#6
mikevirgil

mikevirgil

    Newbie

  • Members
  • Pip
  • 16 posts
Installed GAPI2GDI wrapper:

- XRAlly Alpha doesn't work (freezes the phone)
- SPVMan doesn't work (back to Start Menu)
- Xtris doesn't work
- Picodrive doesn't work... :D

  • 0

#7
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts
ok so it seems overwriting the original gx.dll doesn't work :D

@mikevirgil: you should try copy the new gx.dll and gxorig.dll to each application folders as schriss suggested
(you can download them with the .zip file)

  • 0

#8
schriss

schriss

    Addict

  • Members
  • PipPipPipPipPip
  • 548 posts
  • Gender:Male
  • Location:Dublin
  • Devices:HTC One X Tegra 3
Yes, I deleted original gx.dll from BetaPlayer's directory, but still didn't work. I had to copy your gx.dll to app folder. I think this is because there is a gx.dll in Windows folder (the gx.dll that does not work). Your gx.dll has been installed into Storage/Windows
Probably system first tries the gx.dll found in the original, protected Windows directory, not the one from Storage/Windows.

There are following directories:
Storage (this one contains windows folder)
Storage Card
Temp
Windows (this one is protected)

  • 0

#9
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts
ops. yes this is the problem

what does it mean windows is protected? i know you can't copy ROM files, but patching them should be possible at least on pocketpc. could you try to copy the new gx.dll over the one in windows?

  • 0

#10
stohn

stohn

    Regular

  • Members
  • PipPip
  • 52 posts
Hi,

the idea looks great and it should be possible to get this to work!

Here are some findings and bug fixes (which cause this not to work):

DC = GetDC(NULL);
requires a ReleaseDC... otherwise the complete GDI will lock up until you call GXCloseDisplay()

:arrow: add the following line to GXOpenDisplay() and remove it from GXCloseDisplay()

GXDLL_API int GXOpenDisplay(HWND hWnd, DWORD dwFlags)

{

  ...

  Width = GetDeviceCaps(DC,HORZRES);

  Height = GetDeviceCaps(DC,VERTRES);

  

  ReleaseDC( NULL, DC ); //<== ADD THIS LINE

  ...

}



GXDLL_API int GXCloseDisplay()

{

  DeleteDC(DC2);

  DeleteObject(Bitmap);

  //ReleaseDC(NULL,DC);  //<== REMOVE THIS LINE

  ...

}

Of course you have to put GetDC() and ReleaseDC () now to each DC operation...

GXDLL_API void* GXBeginDraw()

{

  _GXBeginDraw();

  if (!FullScreen && ViewHeight > 0)

  {

    DC = GetDC(NULL);

    BitBlt(DC2,0,ViewTop,Width,ViewHeight,DC,0,ViewTop,SRCCOPY);

    ReleaseDC(NULL,DC);

  }

  return Buffer;

}



GXDLL_API int GXEndDraw()

{

  if (ViewHeight > 0)

  {

    DC = GetDC(NULL);

    BitBlt(DC,0,ViewTop,Width,ViewHeight,DC2,0,ViewTop,SRCCOPY);

    ReleaseDC(NULL,DC);

  }

  return _GXEndDraw();

}


Next thing:

It's not a good idea NOT to take the original device gx.dll!!!!

You better should rename the original and copy yours to Windows. To do this I suggest to write a little tool which will do it on each device startup since Windows folder is not persistent on smartphone.

Last but not least:
you can detect operations to your memory block (bitmap copy of the screen) by setting up an hardware breakpoint on memory write operations. So you will not need a timer for redraws... Unfortunately you will need priv. access to do this. But unlocked MIO's could use it.

Maik

  • 0

#11
mikevirgil

mikevirgil

    Newbie

  • Members
  • Pip
  • 16 posts
now using the source gx.gll and gxold.dll:

- SPVMan starts but black screen (sound ok)
- Picodrive works (but some glitches when switching between screen orientations) (no sound)

  • 0

#12
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts
@stohn: thanks for the feedback

requires a ReleaseDC... otherwise the complete GDI will lock up until you call GXCloseDisplay()

are you sure? i never had this problem on any windows platform yet. you can even create more DC's. example in BetaPlayer it work's perfectly even on the mio8390 for sure. btw you will need that DC for blitting so if you release it in opendisplay you have to requery/release it in begindraw/enddraw.

Why do you call BitBlt in GXBeginDraw() ? There should be no need for this.

in non fullscreen mode this is the correct operation for GAPI. you have to save the current displat state so the program using GAPI can draw only partially on the screen. ofcoz most of the games will use fullscreen mode so this won't slow them down.

you can detect operations to your memory block (bitmap copy of the screen) by setting up an hardware breakpoint on memory write operations. So you will not need a timer for redraws... Unfortunately you will need priv. access to do this. But unlocked MIO's could use it.

could you give me some hints how to do that? i'am really interested. but i'am not sure it can be done on an unlocked phone either. example even on unlocked phone i can't change to kernel mode with a non signed program.

  • 0

#13
schriss

schriss

    Addict

  • Members
  • PipPipPipPipPip
  • 548 posts
  • Gender:Male
  • Location:Dublin
  • Devices:HTC One X Tegra 3
Picard:
I can't even read or copy the gx.dll that is in windows so overwriting it should be possible... yes, got "File is in ROM, are you sure..." and then "Access denied".

Stohn:
this wrapper already works :D maybe with your suggestions it will be even better! Thanks for those great suggestions :lol: (I'm not a programmer, for me it's like Chinese :D )

  • 0

#14
stohn

stohn

    Regular

  • Members
  • PipPip
  • 52 posts
I'm really sure about the GetDC(NULL). This will acquire the main device context and no other application or GDI operation can work then (even offscreen things are not possible... and windows sometimes use it e.g. for updating an invisible clock ;-) )

For priv. access there is a simple trick. You have to put your own certificate to trusted store (this is possible on unlocked devices). Then you have to sign your application with your own certificate. Voila... SetKMode() and stuff working well then :-D


Maik

  • 0

#15
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts

It's not a good idea NOT to take the original device gx.dll!!!!

You better should rename the original and copy yours to Windows. To do this I suggest to write a little tool which will do it on each device startup since Windows folder is not persistent on smartphone.


i thought you can't read nor rename the files in ROM. btw gx.dll is just a wrapper. it was designed this way. so games can install their own copy without compability issues. example if the device uses DMA transfer it's in a separate gxdma.dll, but gx.dll should do the same on all devices.

  • 0

#16
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts

I'm really sure about the GetDC(NULL). This will acquire the main device context and no other application or GDI operation can work then (even offscreen things are not possible... and windows sometimes use it e.g. for updating an invisible clock ;-) )

ok. i will change it.

For priv. access there is a simple trick. You have to put your own certificate to trusted store (this is possible on unlocked devices). Then you have to sign your application with your own certificate. Voila... SetKMode() and stuff working well then :-D


sorry. i'am really a novice smartphone programmer. how can i put my certificate to trusted store?

thanks for helping.

bye, Picard

  • 0

#17
schriss

schriss

    Addict

  • Members
  • PipPipPipPipPip
  • 548 posts
  • Gender:Male
  • Location:Dublin
  • Devices:HTC One X Tegra 3
Stohn: Does it mean that with GetDC(NULL) I won't be able to have anything running in the background? Or answer the phone call?

Picard: can we try again the memdump with that priv. access trick? (certificate)

  • 0

#18
picard_beta

picard_beta

    Regular

  • Members
  • PipPip
  • 148 posts

Picard: can we try again the memdump with that priv. access trick? (certificate)


sure. if i get home and know how to add my certificate.
(i'am checking msdn...)

  • 0

#19
stohn

stohn

    Regular

  • Members
  • PipPip
  • 52 posts
Basically you are right about gx.dll is always the same except one thing...

The gx.dll on Smartphone is in ROM ==> IMPLICIT UNLIMITED TRUST (same as privileged signed).

Your copy is not signed...

Maik

P.S.

Stohn: Does it mean that with GetDC(NULL) I won't be able to have anything running in the background? Or answer the phone call?  

EXACT

how can i put my certificate to trusted store?


Check SDK documentation... ;-)

  • 0

#20
schriss

schriss

    Addict

  • Members
  • PipPipPipPipPip
  • 548 posts
  • Gender:Male
  • Location:Dublin
  • Devices:HTC One X Tegra 3

Stohn: Does it mean that with GetDC(NULL) I won't be able to have anything running in the background? Or answer the phone call?  


EXACT


Is this a good idea? I mean until now, I was uble to answer a phone call while watching a video using BetaPlayer... It kept running in the background, but the system has lowered the volume automatically :D

  • 0




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users