[Q] Where does file created by fopen() resides ? - Windows Phone 8 Q&A, Help & Troubleshooting

In Windows Phone 8 Runtime component (C++/CX) we can use fopen or CreateFile2 to create/open a file. For example
Code:
fopen("hello.txt", "w");
You see, I don't explicitly specify any path. And I can't figure out where this hello.txt resides? It can't be in Installed Location, and it isn't in Local Folder. Where is it?

Well, you could try the following:
_fileno() to get the integer file descriptor from the FILE*
_get_osfhandle() to get the Win32 HANDLE from the fd
GetFileInformationByHandleEx() to get the file name from the HANDLE.
I *think* those are even all supported on WP8, though I haven't checked except for the last one.
APIs like GetFullPathName() would make it easy, but may not be supported. CreateFile2 would let you skip the first two APIs in that list, if it works.

I inspected the WP8 .vhd file, and saw that my file was created in the Install folder. It looks like native code does not conform to the rule (Install folder is read-only location)

Whaaaaaat?!? That's... um. Serious. I'll look into it.

onmyway133 said:
I inspected the WP8 .vhd file, and saw that my file was created in the Install folder. It looks like native code does not conform to the rule (Install folder is read-only location)
Click to expand...
Click to collapse
Are you sure it does not create it on the root of the isolated storage space? That's rather unexpected to have the file in a read-only folder...

The install location is read/write to the app.
What
the
hell?
I can send test code if anybody wants, but it's easy enough to check yourself. You don't even need native code to do it, the .NET APIs work well enough.
I am somewhat confused.

mcosmin222 said:
Are you sure it does not create it on the root of the isolated storage space? That's rather unexpected to have the file in a read-only folder...
Click to expand...
Click to collapse
You can create a simple project to test this. In the C++ WP Runtime Component project, just use fopen or CreateFile2
Then use Hyper-V manager and Disk Management to easily inspect the WP .vhd file (I'm using Emulator)
You can use some things like IsoStoreSpy to see that the newly created file does not reside in the Local Folder (in WP8, they rename Isolated Storage to Local Folder)

I wrote a small app to test it; I can share the source if you want. It's really simple. I used the native APIs to create the file and write to it, then used the managed APIs to confirm it was there and read it, then used the native APIs to delete it, and the managed ones to confirm it was gone. Very simple. I then used the managed APIs to create the file myself (await Package.Current.InstalledLocation.CreateFileAsync("hello.txt")) and it worked.

Have you tried to create a xap file in the Install folder and reboot?
My 8X is freezing after creating a xap...

@spikedviper: No, I haven't tried anything like that. I don't seem to have write access from my app to the folder where pre-installed / OEM XAPs reside.
I did try editing the manifest; I was able to edit it with no problems but changing the capabilities didn't *do* anything, so I'm pretty sure it's still only parsed at install time.

hm...so what is the default path if no path specified?

looks like it stores it here: ms-appdata:///Local/ anyway check out "Data for Windows Phone" at msdn

Related

How to unpack apk file

Hi, I am using the iskoot software, installed by an apk files. But I need to change a setting of this software, and in Windows Mobile I used to change the registry setting I need, but now, we do not have a registry....so what I am asking is, there is a way to unpack an apk files to see where and wich files it install? So that I can go there and edit the conf file I need?
Thanks!
alex_time said:
Hi, I am using the iskoot software, installed by an apk files. But I need to change a setting of this software, and in Windows Mobile I used to change the registry setting I need, but now, we do not have a registry....so what I am asking is, there is a way to unpack an apk files to see where and wich files it install? So that I can go there and edit the conf file I need?
Thanks!
Click to expand...
Click to collapse
apks are just zip files. Set them to open with your archive manager or change the extension to .zip. All applications install their settings into /data/data/%PACKAGENAME% where %PACKAGENAME% is the Java-style package name of the app.
Ugh, no need to use the evil "R" word here. You're going to give us nightmares!
Each application stores its configurations/settings in its home directory in /data/data as pointed out by the previous poster. You might want to bone up on 'sqlite3' as most configuration settings tend to be stored in such databases.
alex_time said:
Hi, I am using the iskoot software, installed by an apk files. But I need to change a setting of this software, and in Windows Mobile I used to change the registry setting I need, but now, we do not have a registry....so what I am asking is, there is a way to unpack an apk files to see where and wich files it install? So that I can go there and edit the conf file I need?
Thanks!
Click to expand...
Click to collapse
I'am trying right now to find this confing files, thanks, I'll let you know if it's ok.
Note that depending on what you are trying to do, the config files may or may not be able to adjust the property you're after. No matter what, the program itself must support what you are trying to do (this goes for ALL OS's -- you simply can't change something that is irrelevant and expect it to do what you want) and more often than not, the ability to adjust that property would be presented by the program itself.
That is, of course, not to say that manually adjusting the config files is useless, because there IS a lot you can do directly from the config files.
alex_time said:
I'am trying right now to find this confing files, thanks, I'll let you know if it's ok.
Click to expand...
Click to collapse
Er, delete please
Modify an " .apk " file in " .exe " file
Hi everybody ,
Please , does anyone know how
I can modify an Android Mobile File .apk
in a .exe to use it with Windows Mobile ?
ccpgclap said:
Hi everybody ,
Please , does anyone know how
I can modify an Android Mobile File .apk
in a .exe to use it with Windows Mobile ?
Click to expand...
Click to collapse
No, they have absolutely nothing in common.
Modify an " .apk " file in " .exe " file
Originally Posted by ccpgclap View Post
Hi everybody ,
Please , does anyone know how
I can modify an Android Mobile File .apk
in a .exe to use it with Windows Mobile ?
Originally Posted by RubenGM View Post
No, they have absolutely nothing in common.
Originally Posted by ccpgclap View Post
But I have found this and it doesn't work ....
Download APK2EXE and NSIS install system
Follow these steps to create your executable!
* Extract APK2EXE to a new directory
* Add your APK to the directory
* Doubleclick APK2EXE.NSI and edit the 3 lines containing information about your application.
* Right click the NSI file, and select 'Compile NSIS Script' - this will create your install EXE
* Done!
And it is a .apk to .exe converter !!!
Can anyone tell me why it doesn't work ? Many thanks
because your trying to run a Android application on Windows.
it's like saying I want to make this MAC application run on windows.. it just doesn't work..
I dont care what programs say.. Its not coded for Windows so it wont understand what the program does...
BTW you application you speak of is meant to install APK's FROM windows not TO windows
"Hot on the heels of my installAPK utility to let you install APKs from your Windows desktop, I now have another neat trick... which allows developers to distribute APKs as Windows EXE files instead."
boostnek9 said:
because your trying to run a Android application on Windows.
it's like saying I want to make this MAC application run on windows.. it just doesn't work..
I dont care what programs say.. Its not coded for Windows so it wont understand what the program does...
BTW you application you speak of is meant to install APK's FROM windows not TO windows
"Hot on the heels of my installAPK utility to let you install APKs from your Windows desktop, I now have another neat trick... which allows developers to distribute APKs as Windows EXE files instead."
Click to expand...
Click to collapse
shouldnt be too tough. just make a executable file that installs and configures adb, allows user to select apk or select a folder of apk's, create a .bat file that tells windows command prompt adb push the .apk to the sd card, then adb install /sdcard/nameofapk.apk
simple enough!
Can anyone tell me how to edit the app / extracted APK file to make the phone think it's a completely different app i.e. install it twice...
Not trying to cause trouble, I'm just looking to install an older version of an app as well as the updated version...
RichCowell said:
Can anyone tell me how to edit the app / extracted APK file to make the phone think it's a completely different app i.e. install it twice...
Not trying to cause trouble, I'm just looking to install an older version of an app as well as the updated version...
Click to expand...
Click to collapse
apk manager will let you
Asadullah said:
apk manager will let you
Click to expand...
Click to collapse
Thanks for replying, I've had a go with that and extracted / decompiled, compiled, signed, and that doesn't work, when I try to install the newly created apk it still tries to overwrite it...
I've watched the vid and read the comments but haven't worked it out yet... Can you point me in the right direction about which bit to edit?
i think you need apktool
Cool, I'll look into that... Any pointers on how to do it once I've got apktool?
command line usage, this tool unpak and repak

creating personalized roms

my question is this, say for example I have my phone setup just as I like with the theme of my choosing, htc music app instead of the stock android app in the cyanogen mod. i would like to be able to create a rom from this setup that I could then just load on my phone as oppsed to loading a cm mod, then installing music player, then installing the theme. before the flaming begins, i tried the search to no avail. i am aware of how to sign the zip and all of that. just a point in the right direction would be MUCH appreciated.
Its something I would like to be able to do as well. According to Haykuros twitter hes going to be making a video about android rom cooking soon so that should help
jholt0130 said:
my question is this, say for example I have my phone setup just as I like with the theme of my choosing, htc music app instead of the stock android app in the cyanogen mod. i would like to be able to create a rom from this setup that I could then just load on my phone as oppsed to loading a cm mod, then installing music player, then installing the theme. before the flaming begins, i tried the search to no avail. i am aware of how to sign the zip and all of that. just a point in the right direction would be MUCH appreciated.
Click to expand...
Click to collapse
This should've gone in the Q&A section. Will probably get locked soon.
But in response to your question, I guess you could grab the CM rom, then grab the theme you use and overwrite the files in the rom, and then overwrite the music app with the HTC music. Resign and you got your update.zip customized how you want it.
xidominicanoix said:
This should've gone in the Q&A section. Will probably get locked soon.
But in response to your question, I guess you could grab the CM rom, then grab the theme you use and overwrite the files in the rom, and then overwrite the music app with the HTC music. Resign and you got your update.zip customized how you want it.
Click to expand...
Click to collapse
Thanks for the help and my apologies for the wrong section
how do you resign it?
joey3002 said:
how do you resign it?
Click to expand...
Click to collapse
by searching.
Stericson said:
Automatic version!
Do not use this to sign APK files in Vista or windows 7! It will cause your theme to loop phones when placed on a device. Only use this to sign update files if your using those O/S's
Note, this will not work if your SDK or the path that you place this in has any spaces in the dir name!
An Example of this is c:\users\Nikki and Stephen\sdk\tools
Try to put the SDK and the contents of the zip in a dir where the names are all together and not like the one above.
I have made a batch file that will automate the entire process of setting up to use the signing tool made by JF. This batch file will set the CLASSPATH, set the PATH, install the registries, and will even allow you to sign files manually if you wish. I plan on building onto this batch file to include other things. However, for the moment, it will only include what you see here.
In order to use this you should have downloaded the sdk already. Simply extract all of the files into the tools dir of your sdk, and run autosign.bat follow the instructions and go through the options one by one, starting with 1 working through 4. You can however, put the contents of this zip anywhere on your computer and it will work. It is just better to put them into the tools dir of your SDK. Especially for the consideration of future versions.
Autosign .zip: http://www.fightforthepits.com/Androidstuff/signing.zip
Want to set up the signing tool manually?
Here is the link for the signing tool: Http://www.FightForthePits.com/testsign(2).zip
Before using this you need to know how to set this up:
Now you will need to add the tools dir of your sdk to the environment variable CLASSPATH.
FOR XP:
Right click on My Computer click properties, then choose the tab that says advanced.
Click the button that says environmental variables.
Go to system variables find the one that says CLASSPATH
double click it
go to the end of variable value.
There should be a semicolon ; at the end, type in the path to the testsign.jar located in the tools directory of your SDK
for example the path to my testsign.jar was c:\sdk\android-sdk-windows-1.0_r1\tools\testsign.jar
If CLASSPATH is not in your system variables then create it.
Secondly, Find the system variable called PATH and add to the end of it, the full path to your sdk directory.
For example, mine was c:\sdk\android-sdk-windows-1.0_r2\tools
FOR VISTA:
Open a cmd prompt.
Replace THEEXACTPATHTO-TESTSIGN with the path to the dir that holds the file testsign.jar.
Type:
echo %CLASSPATH%
If it is returns %CLASSPATH%
Type the following:
set CLASSPATH=THEXACTPATHTO-TESTSIGN\testsign.jar
If it comes back with something else then
Type the following:
set CLASSPATH=%CLASSPATH%;.;THEXACTPATHTO-TESTSIGN\testsign.jar
For Example, when I type this it looks like:
set CLASSPATH=%CLASSPATH%;.;c:\Android\SDK\tools\tests ign.jar
To set the PATH
Replace THEEXACTPATHTO-SDK with the path to the tools dir of your SDK.
Now type:
set PATH=%PATH%;.;THEXACTPATHTO-SDK\tools
For example, when I type this out it looks like this:
path-%PATH%;.;c:\Android\SDK\tools
Now through doing this you have done two things, first off you have made the resigning process extremely easy, secondly you will not have to cd to the tools dir of the sdk to use adb or any other tool in the sdk.
Signing the Files:
Now right click the reg file that you extracted and choose to install it, or merge.
Now, right click an apk, do you see an option that says ResignApk? That's how you will resign your .apks and .zips.
When you choose it a cmd window should open for a few seconds and then close. the file you signed will be overwritten with the new resigned file.
If you find the right click menu not working for some reason you can type the following in cmd to sign your files: java testsign whateverfiletosign
Click to expand...
Click to collapse
.apk's not showing up after flash in resigned .zip
Ok, so I've created a ROM to my liking. All the .apk's I normally use and got rid of the ones I don't. My problem is after I customized the ROM and flashed it none of the .apk's I added showed up. The only ones that showed up were the paid apps. I never opened the .apk's and made changes. I assume I don't need to change them to .zip resign and back to apk. Do I? I am using Windows 7 though and am able to resign no problem. Thanks to anyone who replies.

HTC Notes App

Hi, I’m having a problem with the HTC Notes App on my Rogers HTC One. I have backed up a copy of the folder ".data\HtcNotes" on the SD card, thinking that this folder contains all my notes files. I then wiped my phone and started setup as a new phone. I tried restoring my backed up notes by replacing the folder ".data\HtcNotes" with the one I had backed up earlier but the Notes App does not recognize the restored files. the Notes App works fine, i.e I can create new notes without any problems.
Also, when I try to open the "contentE.html" stored for each note inside subfolders of ".data\HtcNotes", I get unreadable characters. This happens for my new and properly functioning notes as well. Does the Notes App store content in a non-standard html format?. It used to be that the Notes app stored the content in a file called "content.html" which was a normally readable html format, but now it stores in the non-readable " "contentE.html" file.
Please advise how to recover the content of my notes...is there a way I can open the "contentE.html" files in a readable format?. My notes are not synched to the clouds and are stored only locally on the phone.
Thanks
any suggestions?
dabasdabas said:
any suggestions?
Click to expand...
Click to collapse
you may have to reset the permissions of the files
you do this with ES File Explorer and highlight a file go to properties and set the permissions ... usually to rw-r-r but notes files may be different check one you just created and make the old ones the same
thanks for the suggestion, I am able to open the "contentE.html" of my old notes using an html editor or browser, but the file contains unreadable characters, as if I'm opening a binary file inside a text editor. The same thing happens for any new notes I create.
I remember in earlier versions of Android, the Notes app used to store the content in a file called "content.html" which was a normally readable html format, but now it stores it in a "contentE.html" file which is not readable by html editors...
attached is an example of the "contentE.html" file from a new note I've just created, it's supposed to be titled "w1" and contain only the word hello...if you try to open it you'll understand what I'm trying to describe...can you guys please check the "contentE.html" on your phone and let me know if you're able to open the file properly outside the Notes app...thanks...
guys need your help...can anyone please check the "contentE.html" located in numeric subfolders under ".data\HtcNotes" on the SD card and let me know if you're able to open the file properly outside the Notes app...thanks...
bump
i use colornote app, its free in playstore, you can sync with gmail,.. if you use another android phone just install same app, and your note will there to
BUMP!!
Having the same problem, did a factory reset of my phone and the files arer physically still intact, but I can't open them with Evernote app or HTC Notes app. Alle notes are stored in a folder with a .PNG and a .HTML file, the HTML file contains unreadable text. There's very important info in for me, which I need within a week. Can someone please help? I'm willing to do almost anything to be able to read my files...
Still unsolved (bump)
mpc007 said:
Still unsolved (bump)
Click to expand...
Click to collapse
^^
mpc007 said:
^^
Click to expand...
Click to collapse
This disappoints me. If you consider yourselves even moderately skilled, this little problem of my should be peanuts.
Please, help me how to restore my notes from the ContentE.html file!!
mpc007 said:
This disappoints me. If you consider yourselves even moderately skilled, this little problem of my should be peanuts.
Please, help me how to restore my notes from the ContentE.html file!!
Click to expand...
Click to collapse
Try this, create a new note in the HTC Notes app and save it (If it doesn't save, just write random words and exit, it should save then), then go to your .data/HtcNotes folder, find the folder that contains the note you just created. There should be an existing "ContentE.html" file. Delete it and replace it with the file you want to restore.
mpc007 said:
This disappoints me. If you consider yourselves even moderately skilled, this little problem of my should be peanuts.
Please, help me how to restore my notes from the ContentE.html file!!
Click to expand...
Click to collapse
I think you're wasting your time, just having the ContentIE.hml file won't be enough, the actual database is stored in /data/data/com.htc.notes (i think), and without that, the app can't link to the contents of the sdcard.
nkk71 said:
I think you're wasting your time, just having the ContentIE.hml file won't be enough, the actual database is stored in /data/data/com.htc.notes (i think), and without that, the app can't link to the contents of the sdcard.
Click to expand...
Click to collapse
My data folder is indeed empty. However, can't it just be enough to have the raw files from the .data/htcnotes/ folder? I have those, every note exists of a folder with a PNG and a HTML file. They're just not recognised by the Notes App.
mpc007 said:
My data folder is indeed empty. However, can't it just be enough to have the raw files from the .data/htcnotes/ folder? I have those, every note exists of a folder with a PNG and a HTML file. They're just not recognised by the Notes App.
Click to expand...
Click to collapse
Yes, but unless i'm mistaken, the Notes app will rely on the database file, which in turn would link to the contents on the sdcard... so even if the contents weren't on the sdcard they would still show up in the notes app, but not vice versa.
And I don't know of any way to reconstruct the database file.... maybe try searching for that.
nkk71 said:
Yes, but unless i'm mistaken, the Notes app will rely on the database file, which in turn would link to the contents on the sdcard... so even if the contents weren't on the sdcard they would still show up in the notes app, but not vice versa.
And I don't know of any way to reconstruct the database file.... maybe try searching for that.
Click to expand...
Click to collapse
Nobody found a way yet? right?
If you have a backup of your data (or data partition), you need to restore the contents of /data/data/com.htc.provider.notes (as well as com.htc.notes, i think) and set the file permissions by ES file explorer or sth. This is tested and works (I got this answer off google somewhere else, but since this xda thread is the first result that comes up for searches like "recover htc notes", I (necro-)posted the solution here).
Now comes the hard part: If you don't have backup of com.htc.provider.notes, here's how I suggest you hack it BUT I haven't tested: try adding a new note in an empty instance of the notes app. The file /data/data/com.htc.provider.notes/databases/notes.db will be an SQLite file. Open it with any SQLite editor on your computer and you see IDs and file names in its tables match with the created note in your /sdcard/.data/HtcNotes folder. See if you can modify the notes.db database by adding new rows in all related tables to make the app recognize your old HtcNotes files. Don't forget to change file permissions of notes.db after restoring it to your device (I gave rwx-rwx-rwx to everything I copied). If you're lucky and knowledgeable enough you might be able to fix it.
Lesson to learn: Sync, or use plain-text file next time for writing notes.
Chromatix said:
Now comes the hard part: If you don't have backup of com.htc.provider.notes, here's how I suggest you hack it BUT I haven't tested: try adding a new note in an empty instance of the notes app. The file /data/data/com.htc.provider.notes/databases/notes.db will be an SQLite file. Open it with any SQLite editor on your computer and you see IDs and file names in its tables match with the created note in your /sdcard/.data/HtcNotes folder. See if you can modify the notes.db database by adding new rows in all related tables to make the app recognize your old HtcNotes files. Don't forget to change file permissions of notes.db after restoring it to your device (I gave rwx-rwx-rwx to everything I copied). If you're lucky and knowledgeable enough you might be able to fix it.
Click to expand...
Click to collapse
I have a HTC Sensation and I used the HTC Notes app often and so does my girlfriend on her Sensation. I recently changed ROMS on both our phones and have been trying to figure out how the hell to restore our notes. You indeed need to edit that notes.db as you mentioned. I know you didn't test it, but I just tried your suggestion and it did work on my first try. :victory: Here's what I did:
1) I opened the HTC Notes app and created a new note and named it Blah and saved it.
2) I used ES File Explorer to navigate to /data/data/com.htc.provider.notes. Then I copied the notes.db file to my microsd card.
3) I used DB Browser for SQLite to open the notes.db files that I copied to the card. Then clicked on the tab that says Browse Data, then in the drop down menu where it lets you pick a table, I choose notes. There you can see what notes the HTC Notes app will recognize.
4) The note I created earlier called Blah was on row 2, so I clicked on New Record and carefully made a new entry in row 3 with the same format as row 2. Just VERY carefully edit the columns that say: notebook_id, name, data, saved_time, last_modified_time, saving_time, ap_extra_info, thumdnail_path, widget_screenshot_path, and HTC_CREATED.
5) Verify the info you entered is correct fore ach column, then write changes to the database (File menu, Write Changes.)
6) I copied my now modified notes.db from my sdcard back to /data/data/com.htc.provider.notes ES File Explorer, changed the permissions of the file to match notes.db-journal,
7) And finally, I restarted the HTC Notes app, and the new note I added to the database was recognized.
I can think of a shorter way of doing this, but I''ll have to test it first. :fingers-crossed: Why did HTC have to complicate this? Why can't the app just read the files that are in the same folder or provide a refresh option to read any new files that may have been added to .data\HtcNotes at the very least?

Is it possible to trigger POLICY UNLOCK Lumia ?

I've just look out a pretty "CreateFileW" function in "Nokia.SilentInstaller.Runtime" file.
It work's over the Standard "DeviceIOControl" access level.(Requires InteropServices)
We can "Copy" any type of file to the any part of the whole OS "AcrossAllPartion".
Having the same 'destName' file will be replace.
Edit:
"Nokia.SilentInstaller.Runtime.winmd" uses "RPCInterop" service and NtdkClient.dll uses "DeviceIOControl" Service.
@GoodDayToDie Solved problem about "NrsRuntime.winmd" file. It requires Native "NtdkClient.dll" file in xap path (dependency). Just need to include file in project.

[Q] need the location of the following things

So I need the location of some small things
1.default location of the startup and shutdown boot images of my phone
2.default location of the big NOKIA screen pic of my phone
3.places where junk files are stored in my phone memory..... cause the storage cleaner app is not working on lumias
4.default location of storage of downloaded update files
5.registry key which enables the custom startup and shutdown boot pics
6.Appdata folder of phone memory apps where the savegames of games are located
Additionally if anyone with a interop unlock device have the whatsapp beta can he share it
If anyone knows the location of this things plz share it
Most of that is quite easy to find on your own...
1) I'm not sure, but I'd start by looking in the partitions used for booting, or possibly in the Windows folder somewhere.
2) See #1
3) Storage cleaner is open source. You can see all the paths used in the source code.
4) Pretty sure that's actually in Storage Cleaner. If not, look under "DU" (Device Update) folders and similar; the file system isn't that big.
5) Don't know, but there's whole threads devoted to registry edits and there's a search tool...
6) ... really? Make a trivial app that open the IsolatedStorage StorageFolder and then get the folder's full name. Or just find it using file system access; not hard.

Categories

Resources