[Q] DeleteFile and real file system (fat12,fat16) - Windows Mobile Software Development

Hi there,
I'm programming something for Windows Mobile 2003. It basically removes and creates files around. One of the files it deletes is special file.reg, which is normally picked up during the hard-reset.
The file gets deleted using "DeleteFile" and very soon after, I force a hard-reset.
The problem is, the special file.reg is deleted from the file system tree, but it is apparently still available from the hard-reset.
I was wondering if there was another function I had to call to "flush" the file system? If not, I need to find a good trick to 1) enforce the file deletion (like rename first, then delete) and to 2) flush current ghost files left around.
The file system on those persistent drives are fat12 and/or fat16.
Thanks in advance for any input,
Simon

The hard reset returns the machine to its first power up state. If 'file.reg' was part of the original build, then the hard reset will restore it from ROM.
Also any programs you have installed to run on startup, will also be lost, so it is going to be a little difficult, if not impossible, to get rid of this file programatically.

Right, but I'm not talking about the ROM.
I'm talking about the persistent memory which are mounted as \Platform and \Application on this device. Those are FAT12 and/or FAT16, and files deleted (normally) do not come back.
In this case, the files are not coming back, they are not hidden either, but the hardreset process is able to pick them up somehow.

I mean, I call it the problem of the "Ghost files", because they are supposed to be nowhere, but they are found during during the hardreset.
(The files are not recreated, they are still not there, but their contents gets loaded. The info in them cannot be placed in ROM as it contains stuff that changes often)

They come back after a hard reset because during cold boot, they're being copied there from the rom or being created by the system. You may be able to delete them afterwards, but the only way to prevent them from being formed will be to re-cook the rom and stop them from being copied/created during boot-up.

The files DO NOT come back, it's gone, I cannot re-delete it. But somehow it is "read" by a program during the hard-reset.
This file is not part of the ROM, it's part of the persistent memory that doesn't get wiped out upon hardreset but is read-write.
I need to wipe out the ghost file that is stuck on the read/write partition... and I need a way to avoid these being created!

I understand that, but clearly the file is being created (or copied from rom) during cold re-boot, otherwise you wouldn't see it coming back. There isn't going to be any easy way to prevent that, unless you can re-cook the rom, or include some sort of user customization that would delete the files prior to using the device. There are lots of ways that the rom could create the files and put them onto persistant storage.

Hi Farmer Ted,
this is not a ROM issue, recooking the ROM will not help. The problem is a FAT12 or FAT16 filesystem that has bogus data in it.

The problem is most likely a bug in the program that reads the persistent folders... It probably reads it in a way that goes around the change made by DeleteFile()...
Changing that program is not possible (in ROM and I don't have the source, it's also necessary). I just need to make sure it can't find the file I've deleted on the persistent directory (not in ROM).

Related

Technical Question: Recovering a lost file byte-for-byte

Hi all,
My girlfriend has an XDA-II that - on a whim - decided to hard reset itself. (It has done this once before for me aswell.)
Most of the lost files are of no consequence because a backup is available. However, there is one Word document that we would like to recover that is not backed up. The device has not been used since the hard reset.
I presume that it is likely that the text contents of this Word file are likely to still be in tact somewhere in the RAM (i.e. the bytes are unlikely to have been overwritten just yet). I suppose then that it must be possible - at least theoretically - to obtain a dump of all the contents of the volatile RAM memory (perhaps writing out the contents of RAM to a PC hard drive in one dump).
With this resulting RAM dump I could then search it for words that we know are definitely in the file to obtain most of the text back again.
I was wondering if anyone knows of any program for the XDA-II (or PC) that will copy the ENTIRE contents of all device RAM - byte-for-byte - to the PC.
Failing this, can anyone suggest any way whatsoever to view/copy RAM contents byte-for-byte?
Many Thanks,
Rob
you can undelete media like hd's magnetic storage and flash
because they dont fill in 0's in the bits when they delete they just free up the storage and overwrite the data next time data is saved
ram however goes 100% blank when power is not supplied
so ram cant be undeleted and data cant be recovered from it
which is why newer devices with 2005 place data in flash and not in ram
so their device dont goes blank when a hardreset or dead batt happens
Thanks
Not the feedback I was hoping to get! But thankyou very much all the same for letting me know.
Cheers.
Rob

flashing from the sd card

heyy i really need you'e help, im trying to fet to the bootloader id the diamond but i always end's up in the rgb screen, so please tell me what to do...
From the wiki:
http://wiki.xda-developers.com/index.php?pagename=Diamond_FlashfIS
I have a similar problem. But mine is looking for movihand.mtg file then it goes to loading screen and it hangs. I wanted to flash the Deepshining 8 lite also.
I have a lot of files in my internal storage do i need to clear them and leave only the DIAMING.nbh thanks
i have spl 1.40 also thanks
Hope I can help!
Hey! First to 'avior.almo' You need to make sure you have flashed HardSPL to your device before trying to flash ANY ROM to your device (cooked, or custom, or otherwise!) If you are unsure of what I mean, or have any trouble, see sticky threads #2 and #4 of 'Diamond ROM development' http://forum.xda-developers.com/forumdisplay.php?f=430 (I use HardSPL Olinex 1.40)
Once you have this all in place, then flashing from the SD card is easy; you simply need to download the ROM you wish to flash, extract it (if it's downloaded as a .zip or .rar file) so you can find an '.nbh' file. The '.nbh' file is the ROM itself, and the file that you wish to flash. Once you have extracted the ROM you wish to flash (if you needed to extract at all. You may have downloaded the .nbh file as it is) then whatever the .nbh file name is, you need to rename the .nbh file to 'DIAMIMG.nbh' (without quotation marks).
Once you have done that, you need to copy it to your device's internal memory. To do this, connect your Diamond via USB, and when asked on your device screen, choose the 'Disk Drive' type of connection. Once complete, you can then navigate to the root of your (SD card) Internal Storage by accessing 'My Computer' through Windows explorer, Your device drive letter may be different depending on how many hard disks/CD drives you have in your system. (Mine is drive E Anyway, access your internal storage drive, whatever letter it may be on your system. It will appear under 'Drives with removable storage'. This is where you need to copy the 'DIAMIMG.nbh' file to. (To rdelsol: No, you don't need to clear your internal storage of any files or folders, as long as you have enough space in your internal storage to paste the ROM (.nbh file) that you wish to flash, in the root directory. E.g. 'E:' drive. It can be in there along with your 'program files' folder, or your 'my pictures' or 'my videos' folders. Flashing shouldn't delete any files or folders you have in your internal storage either. Even after flashing, 'DIAMIMG.nbh' should also still be there! (After flashing, you can delete that file)) And I noticed that in your post, you typed 'DIAMING.nbh' whether that was just a typo or not, I don't know, but it needs to be 'DIAMIMG.nbh', if so, that may be where you're going wrong.
So, now that we have the ROM image file in the root directory of your internal storage, you need to enter your device into bootloader mode, which is achieved by (while the device is on) holding down the 'VolDown' and 'back' (<-) buttons, while pressing the little red reset button (under the battery cover). Keep hold of the voldown and back buttons until your device displays the tri-colour screen. The instructions are then shown on-screen of what to do next (PROVIDING YOU HAVE HARDSPL INSTALLED, see beginning of post). Your device should detect the ROM image file (saved as DIAMIMG.nbh) and prompt you to press the power button to begin the flash. All going well, your device will display a progress bar, that when reaches 100% will say 'Update Success'
Now you need to press the red reset button again. After that, your device should begin setup of the new ROM as if it had just been bought. Alignment of screen, and maybe time and date setup, for example. Good luck with flashing and setup!
I have done many internal flashing, but today I tried again installing a new custom rom. Strange thing is that the bootloader says that it can´t find any image file and then quits to boot loader screen. I´ve tryied renaming the file using caps and without caps, and also with old radio in order to just test the flashing capability of the internal memory. No luck.
The phone did flash the same image from customruu. Now i´m thinking that it has to do with my messing with the internal memory for partitioning an ext2 and running (badly) android.
I realocated the ext2 partition and made the fat32 the whole internal memory. i´m not sure if i need to re-format the memory throught linux...
Any ideas why I can´t seem to run the internal flashing anymore?

Having problems to install android

hi there
i really need your help. i'm trying to install android on my HTC TyTnII. But i'm having problems to install.
can you please help me to get Android run on my Kaiser?
Right now i'm running the windows mobile 6.1. I want to install Android as a secondary OS.
i followed this installation guide.
androidonhtc.com/wiki/Installing_Android
1. I went to this link to download files.
androidonhtc.com/wiki/Latest_Builds_%28Kaiser%29
2. I downloaded the basefiles-20091116.zip
vogue-android.googlecode.com/files/basefiles-20091116.zip
3. Unzipped this zip file. Renamed the default-kaiser.txt to default.txt and moved the whole folder "android" to my storagecard.
4. then i downloaded the haretinstall.zip and unzipped that file as well. I moved the folder "andboot" to my storagecard.
sourceforge.net/projects/androidhtc/files/2010-02-20/haretinstall.zip/download
5. then i downloaded the polymod_2.1g.zip and unzipped that file. I moved the file "androidinstall.tar" to my storagecard as well.
ponack.net/poly/2.1g/polymod_2.1g.zip
6. i clicked than on "haret.exe" and clicked on Run. the android started to load but then it stops. It gives me this error.
--------
....
Checking for partition...
s2fsck 1.41.4 (27-Jan-209)
ext2fs_check_if_mount: No such file or directory while determing whether /dev/block/loop0 is mounted.
/dev/block/loop0 was not cleanly unmounted. check for ced.
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/block/loop0: 11/65536 files (0.0% non-contigous), 10335/262144 blocks
losetup: /dev/block/loop1: No such file or directory
Failed
Failed to find system.im on SD Card
/bib/sh: can't access tty1 job control turned off
/ #
--------
Can anyone help me out to solve the problem?
Do i need to do some partition? if yes...how can i do it? i'm using a windows xp OS.
This is how my SD-storagecard looks like:
/[android]
/[android]/[andboot]
/[android]/androidinstall.tar
Thank you for your support.
The androidinstall.tar should be in andboot folder, with all the haret files. andboot must be in root of SD card.
/
/andboot
If you were installing to nand it'd be :
/KAISimg.nbh
/andboot
You do not need to partition the SD card, just make sure it is formatted FAT32, not FAT
hi zenity
thanks for the response. I did what you said. Still having the same problem with the same error message.
how do i check format of my sd card? i've never formated it before. it's the original sd card.
Depends if you have an sd card reader and adaptor for micro-sd, if you do you can just format it in windows.
It's likely that it's formatted FAT, most new pre-formatted micro-sd are formatted FAT as standard, how are you transferring files to the sd at the moment?
i connected my htc with microsoft activesync then transfered the files via windows explorer.
i'm still struggeling to get android run on my device.
are those steps correct? or am i doing something totally wrong?
those installation guide are too complicated for me. the instructions are mostly for total replacement of the OS. But i would like to keep my windows mobile because of tomtom navigator. I want to make both OS run with Dual booting function.
if you are so kind...can you please guide me to make this run? I'll be thankful for that.
Best way to format an SD card is to use a card reader and micro-sd adaptor, I've never tried to format an SD with winmo or through activesync, so I'm not sure how easy that is.
I have transferred the files via activesync before, and that works fine, but your SD card must be FAT32, winmo probably does not know the difference, I'm sure there must be a way to format the card FAT32 in winmo, but I cannot think of one, I'll look into it though. I think total commander is able to show what type of format the sd card is, but don't know if it's able to format it.
All the Haret files plus the androidinstall.tar must be in the andboot folder on the SD card, you do not need any other files or folders on the card, but it should not matter if there are any.
You will need an SD card of at least 1GB, 2Gb is better.
I know the guide is meant for Nand install, but does show the installer screen part clearly, and the install procedure is the same for nand and haret, and shows the installer screen you should see when installing on FAT32, (haret).
Download Card Export or WM5Storage to mount the card. Then format it like you would do with a usb stick.
me too
I get the same error.
I have haretinstall and androidinstall.tgz in the /andboot folder.
I renamed default.txt to default.txt.no
I renamed default-kaiser.txt to default.txt
I edited default.txt to point to zImage-eclair
I tried with the regular zImage
I wait till it ask for dpad or vol up button then I press and hold dpad. It never recognizes? Or thats my guess from what has been said here.
right clicking on the drive from within windows using a card reader it says fat32.
When I press dpad it prints a ^@ to the screen, ironically it does the same key for ok. I don't see how I can hold down the vol up/down key cause its a jog wheel? Should I try dpad down?
Volume Up Is the RIght SOftKey. FOr some build only that work.
@zenity: i manage to format my miniSD to fat32. it was fat before. but the problem is still there..does anyone else know how to deal with this?
as tyler51773 already mentioned..i fi start the "haret" which is stored in "andboot" folder it request to hold down the vol button. although i pressed the vol. button,,,it still doesn't work. getting the same error message like tyler51773
seems like i'm totally lost. someone please help!!!
can anyone write down a clean instruction how to install the kaiser on SD incl. the right link (instead of telling users to find out the right one) without wiping out the windows mobile. this would be more helpful to us.
i'm sure there are other users who might be interested in this too.
thankx
When you run Haret and see scrolling text, immediately hold down the d-pad or vol button. Don't wait for it to ask.
hi all,
i have the same problem. the instructions seems to be bad. i cant run it and tried many things. in install-instructions says "androidinstall.tar" but download is androidinstall.tgz.
i don't know if its a big mistake, but someone should make a new "correct" instruction with correct files. maybe it then will be worked.
i also stuck on "can't found system.img"
greetz an sorry for my english
@dukennukemx: i did what you said. no improvement.
@lenzen24: i'm 100% with you!
i tried again,
but also failed on find system.img on sd-card
hope someone has a solution, becaused i woudn't flash a image over my wm6.5.
greetz lenzen
progress
The right soft key button worked, (i.e. the one right above the mail, to the left of the red phone to the right of the dpad just to be perfectly clear for anyone else).
I got the menu, and then it said unbalanced irq 102, unbalanced irq 86?, unbalanced irq 87? it froze then rebooted.
Second try, I hold down the right softkey after i see the penguin. I get the menu with the ok warning. I try all the buttons the warning stays up. I open up the keyboard. I press enter I now am in the menu.
The install option is missing? I have 1. fix permisions. (vs it saying install?) The dpad doesn't seem to work. I have 7 options. The last option is quit. The 6th one is recovery. 5 is wipe. As I'm staring at errors and not the menu I forget which the rest are. I remember seeing a backup/restore. Then their is wipe. Their was also the wipe cache options.
When I try to navigate the menu its a no go. The only real options I have is fix permissions. That leads to errors due to a missing system.img that hasn't been made yet? And then their is quit. I get to quit using the left opt key, and I can get to fix perms using the right opt key. If i open up the keyboard and try every key the only key the menu responds to is enter. I also tried w/ fn lock, but not shift, no responce to the arrow keys was a bummer. When I accessed a shell I can atleast confirm that qwerty mapping was right, but didn't hang out long enough to see the rest of the keymap.
Should I try zimage-eclair? I will of course do that at some compulsive moment, but hey, maybe I wont, or maybe I will and say I haven't yet - maybe I already have {knowingly or not}.. do I need some options in my default.txt? Should I try a different androidinstall? this is polymod-2.1g
This is actually a Tilt vs a Kaiser.
Thanks for the speedy replies and help!
Tyler
Problems with the install option not appearing are usually caused by not formatting the sd as FAT32, or a wrongly set up sd card, for haret installs, everything goes in andboot folder, for nand, androidinstal.tar, (or tgz), in andboot folder, kaisimg.nbh in root, the install instructions are clear enough, they are just not as easy to follow for inexperienced users, and tilt and kaiser are the same thing, if you look under the battery it will say 'kaisxxx'.
zenity
Your last post you can tell someone got under your skin...
I'm a fairly experienced user. I have had troubles installing android since the nand came along.
I feel that if I were willing to nuke my winmo it would be installed. my primary objective with this phone is voip. I'm hoping sipdroid gets fixed or the reports of sipagent working better than sipdroid are true. I'd like to investigate that. I'm poor and with winmo I pretty much make free calls. Albeit I have reliability issues, and I have lots of things i should script to make things work which is all the more motivation to move over. Especially with winmo7 stripping voip out completely [rumor mill]. Anyhow, I am not willing to nuke my winmo. It's quite cryptic to call the volume key, the volume key, when on the kaiser its the right opt key. Perhaps the problem is that I am running a tilt vs a kaiser, another cryptic difference? good thing we don't have a lot of sidekicks running around either. Anyhow. My card is formatted right. I even tried another almost virgin 2gb card, never been formatted but did have a raw filesystem that was only used on sundays while driving to church, it was freshly formatted with fat32 and still it was a no go.
I also just tried myns build. I get an install option, when I press enter it warns me that it is about to delete my all my stuff. So I would say no, but after feeling wrath I tried to say yes, but of course I can't navigate nothing I push will let me choose yes. So I safely run with no.
If I did have a dpad where it says backup data could I backup my winmo? That makes me feel good I've always wanted that. That feature alone would make my day as it would let me finally upgrade my sacred voip setup w/o fear of having to find all those little f!&@&# registry entries again.
Enter does a carriage return in shell? New line in any event..
Dpad/Ok on the front both print a ^@, so does the side ok button, and so does the keyb ok button. {so does; Winkey, MailKey, GreenPhone{send}}
Dpad/Keyb/Jog Up does a ^[[A
Dpad/Keyb/Jog Down does a ^[[B
Dpad/Keyb Left does a ^[[D
Dpad/Keyb Right does a ^[[C
Left Opt: ^[[26~
Right Opt: [BLANK]
e does ^[[1~
red phone{end} ^[[4~
PwrOff ^[[4~
Admittingly this is using myn's androidinstall.tar as i just got done trying that, not sure if the keymap would vary at all (I highly doubt that). Anyhow I also did see the sdcard mounted. I cd'ed into it and did an ls. Everything showed up. It was mounted rw.
Let me know if I can do anything else to speed along the development.
Hate to ask a dumb question? But why not continue to distribute the sqsh builds if they're so much easier to test out for winmo users? Isn't that what the installer is trying to do is process the androidinstall.tar file into either one of three options one of which is cacheable - the sqsh files?
But still, I'd love to hear I now have a back up option..
Zenity thank you for your hard work and even diligent support! I totally get the stress that comes with messing with software for long periods of time. If it helps we can sacrifice a user to the /dev/null ? Hope you're feeling better.
tyler51773 said:
Your last post you can tell someone got under your skin...
Zenity thank you for your hard work and even diligent support! I totally get the stress that comes with messing with software for long periods of time. If it helps we can sacrifice a user to the /dev/null ? Hope you're feeling better.
Click to expand...
Click to collapse
Lol, sorry if it came over like that, I was typing it at a cafe on my kaiser, so I didn't spend as much time as I usually try to on a post, I usually try to structure them as carefully as possible to avoid misunderstandings
To be more accurate, I feel that the present sets of install instructions do assume a lot more knowledge than a lot of those new to Android actually have, this is not a disrespectful statement, simply that most builds have grown and changed so much, and the users who have been using them have also grown in specific knowledge of the install process, this, naturally, has led to some instructions assuming that those users all know the basics, which of course would be true if there were no new users.
It is difficult to produce a generic set of install instructions, since there are still a number of ways to get android onto our devices, and some builds are designed for other hardware originally, myn's for Vogue for example, so the install instructions tend to be more focused on those devices.
As far as the actual installer is concerned, the only time you will wipe winmo is if you have already flashed to nand, running via haret will not wipe winmo, the warning about wiping the system, or data, applies only to the Android build you are installing.
The present installer will process the androidinstall.tar or .tgz and install either to nand, if that is available, EXT2 partition, again, if available, or FAT32 partition, most commonly known as SD card or Haret install, the actual installation will then unpack the tar file to the proper destination, and on haret will produce a system and data img file, I'm unsure if it produces a sqsh file, since it's been a long while since I ran from anything but nand, but I do understand the confusion the install produces for those wishing to stay with winmo, and would prefer that it was clearer, but as with most of android development, once it works, development ceases until it breaks
Rest assured, unless you flash to nand, your winmo should be completely safe, I have not yet seen anyone wipe winmo using the SD/Haret method, not in all the time that we have been running Android on our kaisers.
I'm confused now however, I was always under the impression that the Tilt was merely another kaiser model, and unless you have forgotten to edit the default.txt file to reflect your hardware, the keypad/dpad should function properly, which as far as the escape sequences you have posted, would seem to be the case, ( dpad centre should give ^@ in console etc), so navigating the installer should be as easy as pressing the left, right up or down keys, followed by centre to choose options.
What I am now tempted to do is reflash my secondary Kaiser to winmo stock, and try a few haret installs just to check out things, since most of the above is mainly from memory, although a lot of the Nand install procedure is similar, may not be identical.
Sacrifices will not be necessary, however offerings may be made of caffeine, and/or chocolate, this may help me continue to function in my role as helpful user, and reduce my occasional visits to the mild irony I call my sense of humour
cool
I feel you about short emails making one sound bad! I made that mistake a few times. I actually hate email. I wrote this very funny email to my advisor, he liked it, and forwarded to his boss - just communicating, not to share a laugh or to complain, but to answer a question he did not know; atleast I was told that as I was then later forced to ask him 'did I make you mad?'. Anyhow I got chewed out for professionalism by the department chair which is not the way to a elect a major. Funny enough, I had decided writing funny was the way to go after i had peeved someone off for writing short almost angry sounding emails. In short I hate email/communicating via text.
I was thinking about the whole solution thing. If i need to do a key remap maybe we could just write up a shell script and I could execute it from /sdcard and then re-execute the installer ? unknown.sh??
Also, if you produce some img files what's to stop you from sharing those? I'd totally be willing to try it, maybe it'll work, maybe it'll break wifi calibration? who knows?
Bug found:
http://code.google.com/p/vogue-android/issues/detail?id=124#makechanges
set cmdline "ppp.nostart=0 pm.sleep_mode=1 mddi.width=240 mddi.height=320 no_console_suspend board-kaiser-keypad.atttilt=1"
just tried to change board-kaiser-keypad.atttilt=1 with no results
Just my .02c

[Q] Updating persistent data before hardreset

I'm currently developing a program that basically receives updates and performs them on mobile devices. These are running Windows Mobile 2003.
The update simply consists in a number of files/directories deletes, creates, attributes changes and overwrites (when modified). It's not clever or optimised in any way. But there is a problem.
If the program finds some files need to be modified, the program performs the modification and then immediately makes a kernel call to hard reset the device, so as to reload the OS which is set to read the persistent directories for further booting instructions (which was just changed).
It appears a small number of devices went through such an update but the old data is still being loaded into the registry for instance. There is no trace of where this could come from and I can guarantee it is not burnt into the OS's ROM. I suspect FAT12 or FAT16 corruption of its tables or perhaps its "Root Level Directory" section... reason is probably that the program makes the hardreset too quickly for all buffers to flush in time. Being a hardreset and not a soft one, I assume the buffers are destroyed and never written on disk, thus some changes are lost and some may have been done partially. This problem leaves what I call ghost files around. These files cannot be found anywhere, but somehow are read by the program in OS ROM that is set to find them in the root level dirs of the persistent partitions.
I've been researching like crazy to find a way to make a good call to FlushFileBuffers() to flush everything (data and metadata) before doing the hardreset. But I haven't found any good documentation that works for win32 ce 3.0. I've had to implement all kinds of silly workaround that are making the whole process take much longer than needed...
I'd like your input on how I could make sure everything is flushed properly on these WM2003 devices before I issue the call to hard reset.
Thanks,
Simon

[INFO][SHAREDPAIN]MTP shows /sdcard/sdcard, but deletes /sdcard instead

So, when using dolphin hd for the first time, the downloads folder was set such that it created a folder on the sd partition, at /sdcard/sdcard/Downloads, and put some downloads there; (i'd since had fixed dolphin to store in /sdcard/Downloads)
So, we have /sdcard/sdcard/Downloads
In MTP via windows 7, it shows the folder sdcard/downloads, you can explore it, etc.
BUT, when i went to delete this redundant folder via mtp, specifically, deleted /sdcard/sdcard....mtp deleted /sdcard entirely instead.
I had a feeling this is what happened last time i lost my whole sd partition, but wasn't sure what caused it until now. But, rather than waiting and just deleting the file safely from the term on my phone, instead i rushed, deleted, and oh well, my fault. Funny cause i was backing up files at the time while cleaning up. lol. Passing on my pain
Maybe someone can pass this onto someone involved in development (no way im posting in there lol)

Categories

Resources