Jump to content

GAPI to GDI wrapper for 8390


Guest picard_beta

Recommended Posts

Guest picard_beta

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.hu/mio8390/gapi2gdi.exe with installer

http://picard.exceed.hu/mio8390/gapi2gdi.cab only cab

http://picard.exceed.hu/mio8390/gapi2gdi.zip source

ps: word definitions:

GDI http://msdn.microsoft.com/library/default....e_interface.asp

GAPI http://msdn.microsoft.com/library/default....htm/gx_bvrh.asp

Edited by picard_beta
Link to comment
Share on other sites

Guest picard_beta

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

Link to comment
Share on other sites

Guest schriss

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/

Link to comment
Share on other sites

Guest picard_beta

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.

Link to comment
Share on other sites

Guest mikevirgil

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

Link to comment
Share on other sites

Guest picard_beta

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)

Link to comment
Share on other sites

Guest schriss

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)

Link to comment
Share on other sites

Guest picard_beta

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?

Link to comment
Share on other sites

Guest stohn

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

Link to comment
Share on other sites

Guest mikevirgil

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)

Link to comment
Share on other sites

Guest picard_beta

@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.

Link to comment
Share on other sites

Guest schriss

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 )

Link to comment
Share on other sites

Guest stohn

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

Link to comment
Share on other sites

Guest picard_beta
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.

Link to comment
Share on other sites

Guest picard_beta
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

Link to comment
Share on other sites

Guest schriss

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)

Link to comment
Share on other sites

Guest picard_beta
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...)

Link to comment
Share on other sites

Guest stohn

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... ;-)

Link to comment
Share on other sites

Guest schriss

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

Link to comment
Share on other sites

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

ok, but can i rename or copy the gx.dll ROM file? because i can't have two dll with same name in one process.

Link to comment
Share on other sites

Guest schriss

No, rename of gx.dll in Windows also isn't possible, I tried that.

Funny is, that in case of other files, like .mid, when I try to rename I get the error: "can't delete file" BUT a copy with the new name is beeing created :D So we can write to that folder, it's just that some files are protected.

Additionally, I have read that in case of viruses, there may be patches released, so with proper permissions, an app could possibly get write permission for files in Windows... :twisted:

Link to comment
Share on other sites

Guest markgamber

Am I missing something? Every app that didn't run before installing this patch didn't run after installing it, too. I tried copying the DLLs to the app directory, windows directory and storagewindows directory to no avail.

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.