yashsingh1/xdaforums huggingface dataset:
[Xperia Play Android Development] m3dteam:
Hi Yifanlu,

I have write a code to inject your own function to native libraries on Android (kind of like injectso for android). I was planning on releasing it, but it is not fully polished yet.

it is in C, and it allows you to intercept all calls to a function, and do:

1- completly replace the function with your own,

2- read/modify input

3- read/modify output

4- call the original function

you also don't have to patch the original JNI, so less possible of errors. you don't need root, and it is automatically triggered every time you run app.

I can share it with you, but you must not share it with anyone (I might need to walk you through it).

I am kind of good with JNI, so what exactly do you want to do?

One more thing: if you use apktool to extract the apk and looked at \res\values\ids.xml there a few c parameters that are set to false, such as ctext, I am guessing if you turn them to true, JNI will be more talkative ^^
[Xperia Play Android Development] yifanlu:
Thanks, can you PM me your email or MSN/AIM/Gtalk/etc? I'll try the ids thing. Thanks for the ideas.

Here's the current problem I'm having. I can't get my library to load sony's on JNI_OnLoad and I think it's because of a limitation of Java (can't call loadLibrary while another library is loading), so I added the following to the first native method to be called (JNI_InitializeActivity)

jclass cls;
jmethodID get_load_id;
jstring jstr;
cls = env->FindClass("java/lang/System");
get_load_id = env->GetStaticMethodID(cls, "load", "(Ljava/lang/String;)V");
jstr = env->NewStringUTF("/data/data/com.sony.playstation.NCUA94900_1/lib/libjava-activity.so");
env->CallStaticVoidMethod(cls, get_load_id, jstr);

and then tried to call the original InitializeActivity

cls = env->FindClass("com/sonyericsson/zsystem/jni/ZJavaActivity");
get_load_id = env->GetMethodID(cls, "JNI_InitializeActivity", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Landroid/content/res/AssetManager;)I");
env->CallIntMethod(obj, get_load_id, dataDir, sdDataDir, packageName, assistMgr);

but it crashes. So I thought maybe it's because it's calling itself or because of name conflicts or something (I don't think so because I've enabled logging and my text is printed once). I tried to load the library into memory before hand on JNI_OnLoad

void* libHandle;
libHandle = dlopen("/data/data/com.sony.playstation.NCUA94900_1/lib/libjava-activity.so", RTLD_LAZY);

and then when InitializeActivity is called, I get a pointer to the original and invoke it

#define JNI_InitializeActivity_Offset 0x17394
*(void **)(&JNI_InitializeActivityPtr) = dlsym(libHandle, "PsCrypt_LoadLibrary") + JNI_InitializeActivity_Offset; // Have to calculate offset because function does not have symbol and is hidden
(*JNI_InitializeActivityPtr)(*env, obj, dataDir, sdDataDir, packageName, assistMgr);

Same error. All I really need is to replace two functions, and redirect the rest. What's the easiest/fastest/best way of doing so? I think my code is too bloated even if it works.

Also, to everyone else, I've done a second writeup about all the stuff I figured out this week: http://yifan.lu/2011/08/07/reverse-engineering-a-dynamic-library-on-the-xperia-play/

EDIT: Well, sometime my stupidity even surprises myself. It was crashing because I was not returning a value. My wrapper library loads, now I just need to write the memory patcher.
[Xperia Play Android Development] yifanlu:
Ok, so my wrapper library works now. It runs before JNI so I can use it to replace the function in memory. Problem is how.

Even before that, I need to know the correct paramater list for PsCrypt_GetImageToc. All I can guess is that it requires 4 paramaters, but I don't know the types or what they do. If you have good ARM ASM knowledge, could you try to figure it out from the assembly code?
[Xperia Play Android Development] keytor69:
Ok I did this for Medieval that I bought 3 months ago and updated 4 days ago.

platform_version = 0.96.0

data name="release_number" value="3"

android:versionName="1.0.2"

hope it helps
[Xperia Play Android Development] Blizzrar:
SUCESS

Hello members.

I have maked a fully worked "Star Ocean 2 the second story" apk created.

no grafical glitches, no sound problems against fpse problems with this game.

thanks for all the hard work.

greeeetz Blizzrar:eek:
[Xperia Play Android Development] nextria:
Ahh tnx found it.

I don't get it why it isnt working for me. i have everything installed and it works, except for the extracting part.

I still get the error : This APK is not a know valid one. The extractor will continue , but you may get errors later on.

When i do this, and convert a ISO i get no error at all, but they wont install.

what am i doing wrong ?

regards nextria
[Xperia Play Android Development] Dyelon:
Will I be able to access all the files that yifanlus emulator needs to extract/convert if my phone isn't rooted?
[Xperia Play Android Development] Blagus:
Yes. Copy ZPAK from /sdcard/Android/data/com.sony.crash....../

And adb pull /system/app/com.sony.crash...apk c:\ -> use ls /system/app to find out the apk name.
[Xperia Play Android Development] Dyelon:
Sorry, I was referring to the Syphon Filter part.

I guess I'm getting too jumpy. I'll just wait for someone to test if there's a difference between emulator performance depending on the official game/apk used.

Because the original crash one doesn't play the games I need it most for.
[Xperia Play Android Development] Blizzrar:
Another Success

Now I created a worked apk "Diablo1" + cover.png

with image.bin + image.cue

but I have a question

where is the different in the options of parential rating, analog mode and store typ?

Greeetz -Blizzrar-
[Xperia Play Android Development] Dousan:
Yes you will, the .apk is in /data/app as blagus stated and the Zpak is in /android/data/com.sonyplaystation.NCXX.XXXXXX_X all accessible from a file manager such as astro.

I also got the new beta 2 to work with the NCUA versin of the Zpak and .apk of crash b. Used a pal version of 'medal of honor underground' it works though 2 min. into the game the graphics just dissapears. I had the same problem with fpse but with some ajustments in the settings in fpse it worked without flaws. The analog sticks wont work probably as i set them up to, it seems that both left and right stick is dublicating eachother. Tried all kinds of settings in the game and in the emu (sony's), no luck on getting it to work right. Yes the game supports analog sticks ;) Will try another 'medal of honor' later today and see how that goes. I'm flashing my phone at the mom. It's not the iso i tried several different with fpse, it still had the dissapearing of the graphics, my own rip and some from the net.

Anyway great work yifanlu once again and thanks to all for sharing tips and links :D

Regards Dousan...
[Xperia Play Android Development] kingvillain:
Success at last! Using the updated crash APK referred to in an earlier post by someone I got my first working game.

Hogs of War no graphical glitches at all, full speed, however much like with FPSE the music and speech does not work, but that could possibly be my back rom, sound effects work fine though.

Thrilling result! Thankyou yifanlu
[Xperia Play Android Development] Dyelon:
oh wow. I just played MOH UG and thought it was played great for the minute I tried it. Despite how painful it was trying to aim with the damn sticks. I wish they would've just made the sticks ALOT smaller so that subtle movements were all you needed to look around.

But yeah its funny to think that if I would've played another minute the world would've disappeared lol
[Xperia Play Android Development] siuyau01:
where can download updated crash APK?
[Xperia Play Android Development] kingvillain:
Grab it in this thread, you need to download the "All Original System APKs" link further down in the first post, Crash APK is in there (v1.0.1).

Just tested Ape Escape Game works, and with some configuring of controls in the emu`s menu all controls work including both analogue! Sound works too, however in game there is some slow down but not to off putting, it does cause the music to slowdown a little with it though.

Gonna test some more of my backups now:D
[Xperia Play Android Development] subcu1ture:
Can we make a new thread with the games that work??
[Xperia Play Android Development] Dousan:
Done ;)

http://xdaforums.com/showthread.php?p=16577779#post16577779

Regards Dousan...
[Xperia Play Android Development] kingvillain:
Just posted details of two games I tried so far in that thread.

Update on Ape escape, due to the lack of L3 and R3 things like swimming in the game is awkward as you can`t dive :(
[Xperia Play Android Development] nscxp2005:
I don't if this is ok to ask for, but would somebody be able to upload the ZPAK Data for Crash?

Thanks

All the best,

NSCXP2005
[Xperia Play Android Development] leemarie:
rtype delta , rtypes , and soul blade are all working
[Xperia Play Android Development] kingvillain:
Download it`s APK, install on your phone and let the app download the stuff, that`s how I did it.
[Xperia Play Android Development] nscxp2005:
Unfortunately I don't have a Xperia Play yet. I'm getting one when my contract runs out in November.

I would love to start converting hames ready for it.

Please could you upload the ZPak data for the version.

All the best,

NSCXP2005
[Xperia Play Android Development] AndroHero:
If you dont have an xperia play you cannot have crash.
[Xperia Play Android Development] nscxp2005:
I got Crash from the thread posted above.
[Xperia Play Android Development] muhski:
Chrono Cross os not working!

Game Starts, but after the "Press Start"-Screen the game crashes!

Tried with different Files, also with a bin that worked on FPSE

greetz
[Xperia Play Android Development] sdlaurin:
Guess Sony has zero reason to port anymore ps1 classics.
[Xperia Play Android Development] nextria:
finally got it to work, i removed the JDK 7 and installed version 6.

i also reinstalled android SDK, and now it works :)
[Xperia Play Android Development] ashergray:
Well they certainly wont make any money from anyone with brains and this nifty little app bundle.
[Xperia Play Android Development] MechaBouncer:
What about multi-disc games that share a save file? I don't think that this method will work with more than single disc games unless there's a way to get the save file into the second disc.

On another note, I was able to get Vagrant Story running last night. I had some trouble at first trying to use an archive of the North American Crash Bandicoot that I had when my phone was running the unlocked R800a firmware. I had flashed the generic UK firmware so that I could get the 2.3.3 update. When I did that, I got the UK version of CB instead. So I tried the UK version and that worked like a charm.

Vagrant Story runs pretty well. The sound is perfect, unlike Fpse, and now I can use analog support (although I think this will be coming to Fpse soon). It even looks great, but there are some graphical glitches that appear at times. Rainbow colored textures appear every now and again. It usually happens during dialog sequences or the menu and it looks like it happens in the areas around the text and menus. I'm thinking that it's supposed to be a transparent overlay, but something is getting messed up every now and again. Otherwise it works great!
[Xperia Play Android Development] Logseman:
Had they put PSN integration in the Xperia Play, people would have been able to play their already-acquired PSX games and Minis, and there would have been way less incentive for this. I bought Medievil in PSN, it is insulting to see Sony wanting to charge me other 5 euro for the same thing, just because it's in another platform.

Plus, Sony makes pure profit on the already present games: once the emulator is done, the cost of porting games is zero since Sony has to pay no license fees for the games. Of course they said they didn't worry about the low PSX games sales: however low they were, they were profitable.

Sony didn't have any business porting a dozen of, at best, just decent games (the top games for PSX are all 3rd party) and charging a fiver. This just cuts the undesired middleman, and even for the people who have donated, we pay more in 2 or 3 Sony-officially emulated games than in the donations.
[Xperia Play Android Development] CurtDawg77:
Final Fantasy 7....

I did the first disc of FF7 and it works, but FPSE seems to do a little better although both are not perfect and have lags and stutters at times. I converted mine with Java 7. Do we know if the version of Java used makes a difference. Also, I was interested in trying a different apk to see if that makes a difference. If I download/buy a Euro apk will it work on my US phone? If not, are there any other US games out yet?
[Xperia Play Android Development] subcu1ture:
REMEMBER TO POST YOUR GAME CONVERSION PROGRESS IN THIS THREAD :)

http://xdaforums.com/showthread.php?t=1214703

the more comprehensive the list the less wasted time we have have as a collective :D
[Xperia Play Android Development] muhski:
I thought this should be a list of WORKING games (as the Thread-Titel says...)?!
[Xperia Play Android Development] illuminerdi:
They've already said they're porting Wipeout, which hopefully will have a better emulator and therefore higher compatibility with other games, however they might patch whatever hole Yifanlu has exploited here. Or maybe they won't :)
[Xperia Play Android Development] illuminerdi:
It's really simple: either you save at the end of the disc and copy over your save OR you save right before the end of the disc and copy over your save. Most multi-disc titles have a little bit of overlap between discs, as technically the second/third disc usually has to have some of the previous disc's data (for backtracking, etc).

Almost all multidisc titles have the exact same game data on them, the only files different are the FMVs. This overlapping of files means you can switch discs before you're officially "told" to do so and it will still work. Copy over your saves and all should be well.

We really don't need to worry about multidisc stuff right now - it's a total non-issue.
[Xperia Play Android Development] Mills00013:
I made two different apps for MGS: one for the first disc and one for the second. I then created a symbolic link between the save data directories so that they attempt to use the same memory card. I don't know if its gonna work or not, I havn't had the few hours free time to get to the second disc.
[Xperia Play Android Development] ashergray:
That sounds like a great idea, let us know what happens when you get there.
[Xperia Play Android Development] MechaBouncer:
I guess I should have dug a little deeper before posting. I didn't realize that the memory card files were stored on the SD card with the ZPAK. I thought they were contained in the save data for the APK. Do I just need to copy the 0.RAW and 1.RAW files? Thanks!

I hope that works. BTW, how did you go about doing that anyway?
[Xperia Play Android Development] bubblegumballoon:
Hey I have a question, inside of the native ps1 emulator there are hidden options in the preferences.xml file. Is there any way to change these? Ive tried before but the app resets them to tier defaults every time I try to run the game.

the option I am most interested in is enabling the on screen controller, this means the emulator could be made to run on phones without a physical gamepad.

here are the options:

<boolean name="Up-rendering" value="true" />

<string name="Screen Orientation">Landscape</string>

<boolean name="FPS-counter" value="false" />

<boolean name="SW-render" value="false" />

<boolean name="On Screen Controller" value="false" />

<string name="On Screen Controller Type Landscape">Type 1</string>

<string name="On Screen Controller Type Portrait">Type 1</string>

<string name="On Screen Controller Color Landscape">Color 1</string>

<string name="On Screen Controller Color Portrait">Color 1</string>

<boolean name="On Screen Controller Vibrator" value="true" />

<string name="On Screen Controller Transparency 0" value="100" />

<string name="On Screen Controller Transparency 1" value="100" />

<string name="On Screen Controller Transparency 2" value="50" />

<string name="On Screen Controller Scale 0" value="100" />

<string name="On Screen Controller Scale 1" value="100" />

<string name="On Screen Controller Scale 2" value="100" />

<string name="On Screen Controller Scale 3" value="100" />

<string name="Button Mapping">Type 6</string>

<string name="Screen Mode">Wide</string>

<string name="Save Progress">Off</string>

<boolean name="Frame Skipping" value="false" />

<string name="Controller Port" value="1" />

<boolean name="Analog Mode" value="false" />
[Xperia Play Android Development] Blagus:
APK is being unpacked by tool anyways. Before packing, edit it manually ;)
[Xperia Play Android Development] bubblegumballoon:
I managed to do it and it worked :)

It seems that I couldnt change the options of the official crash bandicoot game but any custom games will work. I have gotten the on screen controls to show up but they dont seem to work :/

Edit: I attached a picture of the on screen controls. sorry for the bad quality :P
[Xperia Play Android Development] crono141:
Can you get only certain controls to show up. Such as L2/R2 and L3/R3 only?
[Xperia Play Android Development] bubblegumballoon:
I included a picture above, it only uses the digital controls and there is no L3 or R3 sadly. :/
[Xperia Play Android Development] AndroHero:
wipeout has been out in the UK for ages :p
[Xperia Play Android Development] German-Guy:
Thanks for Release!

I tested Tomb Raider 2. It´s crash when i choose Start Game oder Laras Home (Training) at the same Time on PSXperia and fpse Emulation.

Use Sony the same Emulation Way ;)
[Xperia Play Android Development] thomassafca:
It works with .bin and .img files too! :)
[Xperia Play Android Development] yifanlu:
Thank you, that confirms my suspections that the store games (or at least the newer ones) contain an updated emulator. This means if you bought a store game, use that APK for better support (I think). Can you gift games on android market? I would love to take a better look at release 3 emulator, but I can't access playstation store (not available in your region).
[Xperia Play Android Development] Dyelon:
It seems the compatibility is pretty terrible. Way worse than fpse.

Sonys emulator is the worst one on the market. Who'da thunk it?
[Xperia Play Android Development] crono141:
Do you need the game data to extract the emulator? Could the APKs with the newer emulator be shared? I'm stuck on verizon and I think the ONLY ps game available to us is Crash 1.
[Xperia Play Android Development] Dyelon:
Its updated......sweet.....do we know if its better? Also, we should try to figure out which xperia game has the BEST emulator.
[Xperia Play Android Development] yifanlu:
I know. I assumed that this was going to be like the PSP. And why not? Same people, same idea. I guess sony just got lazy this time around. Maybe release 4 would be better?
[Xperia Play Android Development] crono141:
I said this in a previous message, but I think it got missed between all the bug reports:

Sony hasn't created a general emulator here. They've created a very specific emulator to emulate everything the specific game needs to the best of its ability. That is why compatibility is so low, and probably why the emulator doesn't have l3/r3 button support yet. No reason to code it in if the game its attached to doesn't use it. The Xbox360 does its BC emulation this way as well. Microsoft creates a specific emulator for each game or set of games with similar requirements.

The unfortunate result of this, for us, is that you'll have to pick the best version of the emulator for each game you want to convert. The crash 1 emulator works great for all the crash games, and a bunch more, but its completely inadequate for other games. Likewise, the wipeout hd emulator will probably be good wipeout and similar games, but bad for sidescrollers, etc etc.

I congratulate yifanlu for your excellent work getting us where we are. Its just a shame that the promised land of a native sony emulator isn't as awesome as we all hoped it would be.
[Xperia Play Android Development] Dyelon:
QFT
[Xperia Play Android Development] yifanlu:
There are three releases of the emulator, so it's not like cool boarders 2's emulator is going to play better than destruction derby's. I think it's more of a "work in progress". If sony ever releases another game into the store, the emulator code will be newer and would be better.
[Xperia Play Android Development] zero_1_2:
the PSP emulation of the psx wasnt perfect during its first release either. It will take a little bit before they release a working one If sony goes the way it went with PSP. It wont be xbox 360-like emulation. Thats just speculation though. As far as ive seen, There are graphical glitches on games, but most play perfectly with almost no slow down and perfect sound emulation.
[Xperia Play Android Development] yifanlu:
I said I won't accept donations until after the tool's done, and I think it's done now.

Of course, I'll continue to add features and fix bugs when I have the time, and you are not obligated to pay me a cent. The tool is and always will be free and open source.
[Xperia Play Android Development] kupo5131:
I'm using the US version of Crash but cannot get the analogue sticks to work, tried them with Tekken 3 and both disks of Gran Turismo 2. I've tried with the analogue option on and off but it will not work at all for me. Anyone have any ideas?? Or is it a case of buying a game from the market so i can use a newer emulator engine??

(the iso's I'm using are all PAL)
[Xperia Play Android Development] subcu1ture:
Well it is better to know what works and what doesn't if it is emulator specific.

Or else the thread will get flooded with "OMG why doesn't this work, what am I doing wrong"
[Xperia Play Android Development] supermorph:
from what i have seen, a good example is ridge racer,

it seems also to be audio tracks at the end of the data track.

but if that is the same for other games that use this method, i dont know.
[Xperia Play Android Development] keytor69:
ok I tried to compile a game using the Medieval data files as the core but when it trys to load it now trys to authenticate the validity of my license. - looks like emulator 3 is just updated with checks.
[Xperia Play Android Development] Dyelon:
Oh wow....damn.
[Xperia Play Android Development] crono141:
Back to FPSE it is, then.
[Xperia Play Android Development] Dyelon:
Roger that dude
[Xperia Play Android Development] Logseman:
I'm going to use Syphon Filter as my base APK (since I have bought it, it's good to try). It's worthy to mention that if you're going to use a paid app, and at least in the Syphon Filter case, the APK file is called simply "pkg.apk" and it is located in the folder /mnt/asec/com.sony.playstation_<game identifier>. The ZPAK file is located in /sdcard/Android/data/com.sony.playstation_<game identifier>/files/content, as always.
[Xperia Play Android Development] AndroHero:
I don't think anyone is denying that your have more than fulfilled the requirements of the bounty :D Well done :)
[Xperia Play Android Development] yifanlu:
I got the emulator and Crash Bandicoot running on CyanogenMod. In case anyone else wants to do so, you need to install preinstalledservice.apk from the stock rom.
[Xperia Play Android Development] SanGai:
Awesome work, just tested Pocket Fighter (works but annoying flashing screen). Is there any way to get the games to show up through the Xperia Play app (when you slide open the phone). I've tried using the tut in this thread http://xdaforums.com/showthread.php?t=1110405&page=3 but it wouldn't recompile. I've also tried editing the AndroidManifest.xml before converting but that didn't work either.
[Xperia Play Android Development] Logseman:
Erm... those files wouldn't show up in the Xperia Play launcher (the blue one), they'll show in the ... Playstation Pocket one (the purple one).

Like this: