Save boot-loader to virtual disk - save

Hope this doesn't sound crazy or something
I am trying to create a mini O.S. (who didn't?, it is like visiting Mecca for a muslim - any programmer must do it at least once in his life)
So, I created a simple boot-loader, that works fine when executed from a virtual boot-able ISO, in a virtual machine (Oracle VM Virtual Box). It just displays a message for now.
At this point, I am supposed to give the control to another code, that would start being my O.S. All this will be executed from the virtual optical disk. I could burn it on a CD and run it on a i386.
No, to make this really something, I want to run the "O.S". from a hard disk, so I wonder if there's a way to "burn" the boot-able information (boot-loader and other files to be loaded) directly on a virtual disk (like .vmi, .vhd, .hdd)
When I install a conventional O.S., like Windows or Linux, from an ISO image, on the virtual machine, the boot-loader starts a new code section, that installs the O.S. on the virtual disk. That is how I should do it, too: create a installer for the O.S., that would write my booting section on the virtual disk. That means that everytime I make a change to my O.S. I must re-install it. I don't like that. I would like to be able to write the booting code directly inside the virtual disk file, start the machine in Virtual Box, and see it running. I opened the .vmi file with an HEX editor but I cannot figure out where should I place the code to be considered boot-able.
Now, tell me whether I don't know what am I talking about or is there a solution for this.
Thanks to everybody!

I found out how to do it. Create a vmdk disk, open in in a HEX editor and paste the bootable information starting from 0

Related

Electron does not run on shared folder

C:\share is shared folder.
C:\share\electron-v13.0.1-win32-x64, \\192.168.1.10\share\electron-v13.0.1-win32-x64 and Z:\electron-v13.0.1-win32-x64 are same folder.
Electron app is launched correctly when I execute C:\share\electron-v13.0.1-win32-x64\electron.exe command.
However, electron app is not launched correctly when I execute Z:\electron-v13.0.1-win32-x64\electron.exe command.
According to the task manager, electron processes are running.
However, electron's window is not shown.
Can electron run correctly on shared folder?
Should be safer to use it locally (from the C:\share). The mapped drives behave very differently compared to local filesystem. And their implementations can differ in their settings as well:
https://wiki.samba.org/index.php/Time_Synchronisation
https://www.truenas.com/community/threads/issue-with-modified-timestamps-on-windows-file-copy.82649/
https://help.2brightsparks.com/support/solutions/articles/43000335953-the-last-modification-date-and-time-are-wrong
If I understand you are just mapping back your own shared folder, and overall the Windows server cofigurations felt to me more consistent, however the protocol changed over the time as well:
https://en.wikipedia.org/wiki/Server_Message_Block
I do not understand the network sharing protocols well to give you exact answer why you have the problem, but I know enough to tell you that the mounted shared folders are not like your own local filesystem. In many cases the differences do not matter and it gives great user expierence, but in some cases these minute differences break things in misterious ways, even if they are mapped/mounted almost like a regular/local drive. This is not exclusive problem to Electron.
And that is a problem with a lot of things through SMB (mainly binaries/tools), the shared folder might be running a different filesystem, different permission and privileges (or run a completely different structure of permissions underneath if it's a completely different filesystem). Remote folders might have issues with inotify getting events on file updates, might miss changed file (like touch on Linux is meant to update date on the file), so through shared folder the date updates might be delayed/rounded. I think at one point even Makefiles were misbehaving as it was depending on the access-date to work the way it would locally.
Other problem with tools is the sharability, can it handle run multiple instances from the same location? Is it saving something into a ./tmp or some other file which could conflict with other user running it at the same time?
Overall with shares I tend to use them for data (and few times had issues with them as well), but have shared remotely applications only if they are known to not cause troubles.

How do I make a simple public read-only WebDAV server with SabreDAV?

I recently began looking into WebDAV, as I found it to be an option for letting me play a Blu-ray folder remotely - i.e. without requiring the viewer to download the whole 24gb ISO first.
Add a WebDAV source in Kodi v18 to a Blu-ray folder - and it actually plays! Very awesome.
The server can also be mounted on Windows with
net use m: http://example.com/webdavfolder/
or in Linux with
sudo mount -t davfs http://example.com/webdavfolder/ /mnt/mywebdav
-and should then (in theory) play with any software media players that supports Blu-ray Disc Java (BD-J), such as PowerDVD and VLC.
vlc bluray:///mnt/mywebdav --bluray-menu
PowerDVD.exe AUTOPLAY BD m:
(Unless of course time-out values has been set too low, which seems to be the case for VLC at the moment).
Anyway, all this is great, except I can't figure out how to make my WebDAV server read-only. Currently anyone can delete files as they wish, and that's of course not optimal.
So far I've only experimented with SabreDAV, because afaik that's the only option I have if I want to keep using my existing webhost. Trying with very minimal setups, because I've read that minimal setups should default to a read-only solution. It just doesn't seem to happen.
I initially used the setup from http://sabre.io/dav/gettingstarted/ and tried removing some lines. Also tried calling chmod 0444 MainFolder -R on the webserver. And I can see that everything does get a read-only attribute. But it changes nothing. It's still possible to delete whatever I want. :-(
What am I missing?
Maybe I'm using the wrong technology for what I want to do? Is there some other/better way of offering a Blu-ray folder for remote viewing? (One that includes the whole experience - i.e. full Java menus etc).
I should probably mention that all of this is of course perfectly legal. It is my own Blu-ray project - not copyright material.
Also: Difficult to decide if this belongs on StackOverflow or SuperUser. I ended up posting it on StackOverflow because SabreDAV is about coding, and because there's no sabredav tag on SuperUser.
You have two options:
Create your own file/directory classes for sabre/dav that simply throw an error when trying to delete. You can basically start with a copy of Sabre\DAV\FS\Directory and Sabre\DAV\FS\File and change the methods that do writing.
Since you're considering just using linux file permissions, really the key thing you are missing is that that 'deleting' is not controlled on the file or directory you're trying to delete. To delete a file or directory in unix, all you need is write permissions on the parent directory. However, I wouldn't recommend going this route as doing this will just cause a weird error in sabre/dav, which might leave clients in a confused state. It would result in a 500 error, not the expected 403 error.

How do I get JetBrains IDE's auto-save to work correctly when used inside a virtual machine?

The default auto-save behavior is "Save files on frame deactivation". However, I'm using it inside a virtual machine, so the frame deactivation is not detected, because the frame I'm deactivating is actually VirtualBox's window in the host machine.
The only other supported way seems to be saving it periodically every second or two, but I'm wondering if there's a better way. It would be ideal if it can save whenever I press the Alt key, but I'm not sure if it is possible to trigger a save on just the Alt key alone. Or maybe there's a way to externally trigger a save command through some API.
I'm wondering if anyone encountered similar problems when using JetBrains IDEs (in my case PyCharm) inside a virtual machine. Any advice?

Import a folder with files inside into a jailbroken iPhone using vb.net

I am writing an app in VB.NET (Visual Studio 2013) and as a final step, it has two copy a folder (with several files inside) into a certain directory in an iPhone.
The iPhone is jailbroken so it is possible to access every kind of directory and it should also be connected to the PC via USB. Is this even possible?
Thank you in advance!
I suck at visual basic, but I can tell you how you would do this programmatically:
First, you need to tunnel SSH over USB. You can do that by programatically executing itunnel_mux.exe from this zip.(you'll have to extract everything first.) Use it like this:
itunnel_mux.exe --tunnel -iport 22 -lport 2222
Then, you can use SCP (I'd recommend this library) to Copy files over from root#127.0.0.1:2222 (password alpine).
This is some example pseudocode (keep in mind, I don't know VB):
'Extract the exe and dll file from that zip
extract_files()
'I'm making a new variable containing the port number.
Dim port As string = "2222"
'I made up this function. Lets pretend it executes Batch code in the current directory (like a bat file)
execbat("itunnel_mux.exe --tunnel -iport 22 -lport " + port)
Using scp As New Rebex.Net.Scp
' connect to a server
scp.Connect(hostname)
' authenticate (change alpine if you changed your root passwd)
scp.Login("root", "alpine")
' Here, you can use "scp" to upload and download files
scp.PutFile("C:\Users\KevinKZ\Desktop\fileToUpload.jpg", "/var/mobile/Documents/fileToUpload.jpg")
scp.GetFile("/var/mobile/Library/SMS/sms.db", "C:\Users\KevinKZ\Desktop\SMS_Backups\2-1-14.db")
scp.Disconnect()
End Using
This solution is far from elegant. It also requires OpenSSH (I think). If you want something easier and/or more flexible, let me know. You might be better off using libimobiledevice. If you still need help let me know. You can email me at alex#alexhulbert.com
If the directory is accessible from Windows then yes.

How to delete a file that is using by windows?

Is there any way to delete a file when its using by any program or other process in windows?
I searched and found this 2 ways:
1- using RunOnce key in Registry;
I'm not gonna use this because i dont want to wait for windows restart or anything else... prefer to do it ontime!
2- using the way declared in this page: http://www.delphipages.com/forum/showthread.php?t=201190
the problem here is its useful under NT windows, i need a way works on all Windowses!
Thank you.
the problem here is its useful under NT windows, i need a way works on all Windowses!
All modern desktop Windowses (XP, Vista, 7) are also NT. Do you really need to work with NT<4 or Win98? Or even Win CE/Mobile/Phone? Probably not.
If you need to delete an open file straight away, about the only thing you can do is attach to each process using debugger privileges, see if it has any handles open on the file, and if so close them underneath it. You can do this the manual way using eg Process Explorer. Many applications won't react well to having their files closed on them; expect them to exception out when they try to do something with the dead handle.
Unfortunately there is no option in Windows to have Unix-style files that can exist attached to a file handle independently of being stored under a filename on disc.
You cant delete a file when someone is using it. No matter how hard you try, windows will not let you. It can work with some files, but in general it does not work.
What you can try is postpone the deletion, when no one is using the file. You can:
1 - use RunOnce, but you dont want that.
2 - Wait in a loop, trying to delete the file. Pseudo code:
DeleteFile
Check if you was able to delete or if file still exists.
if you are able to delete, then exit loop.
That is the best you can do, and what i could remeber.
Try MoveFileEx with MOVEFILE_DELAY_UNTIL_REBOOT flag. Will postpone move or delete action until reboot.
Edit:
If you don't whant to restart the only option is to close those handles. ProcessExplorer does that and works all the time and I have not seen any process to crash. See more info about enumeration handles in a process at
http://www.codeguru.com/forum/archive/index.php/t-176997.html. But keep in mint that you should enumerate all processes in the system and behave different on Vista+ (you need to be elevated)
Your files are most likely locked because some process has a handle open to them. That is the most common reason for the Access denied result when deleting or moving a file.
A really blunt way is to close that handle.
Then Handles tool from SysInternals (you can download the sources too) can do that for you: I have been successfully using that.
Note 1: You need administrative privileges to use it.
Note 2: Closing a handle from another process is considered very rude, and can make that process unstable.

Resources