|
Luc Pattyn wrote: it is a real pain, but in complex situations Windows seems to require each folder level with spaces to be put in its own pair of double quotes, hence:
I have never had that happen. I've always just had to put quotes around the full path to the .EXE and any command lines args that had spaces in them.
|
|
|
|
|
I got that information as a tip years ago, and it did solve a problem where more than one path on the command line contained multiple folder names with spaces. I've never seen any official document on the matter; my library that implements this has "Ask Dr. GUI #54" in its comments, not a real URL. And when I throw that at Google, it fails to come up with anything except for a chinese MSDN page.
Here is the method:
public static string QuoteSpaces(string f) {
env.log(env.TRACE,"quoted in: "+f);
if (f.IndexOf(' ')>=0) {
string[] fa=LP_String.Split(f,'\\');
StringBuilder sb=new StringBuilder(100);
for (int i=0; i<fa.Length; i++) {
if (i!=0) sb.Append('\\');
string fi=fa[i];
if (fi.IndexOf(' ')>=0) {
sb.Append('\\');
sb.Append('"');
sb.Append(fi);
sb.Append('"');
} else {
sb.Append(fi);
}
}
f=sb.ToString();
}
env.log(env.TRACE,"quoted out: "+f);
return f;
}
My IDE app seems to use the method when invoking tools such as DUMPBIN and ILDASM. I'm afraid that is all I can tell you on the subject.
|
|
|
|
|
The way you have your command line right now is this:
C:\Program Files (x86)\Combined Community Codec Pack\MPC\mpc-hc.exe C:\Users\xxx\Documents\Visual Studio 2008\Projects\aa\aa\bin\last.mpcpl
You need to add double quotes around both the path to the .EXE and the arguments you're passing it, like this:
"C:\Program Files (x86)\Combined Community Codec Pack\MPC\mpc-hc.exe" "C:\Users\xxx\Documents\Visual Studio 2008\Projects\aa\aa\bin\last.mpcpl"
|
|
|
|
|
Hello good people,
I was wondering if it is possible to append data to an already encrypted file?
I tried a few projects the past few days but always when i append data to the file, the second line and all lines after that contain mangled data.
Using google to find out if it is possible or not did not give me any desirable results, so i wanted to ask in here if someone knows?
Am i trying to do something that is not possible?
Do i need to take a different approach, like first decrypting all data into a temporary file and then re-encrypt the whole lot?
Any advise would be greatly appreciated, after three days of trying i am hoping someone could enlighten me.
|
|
|
|
|
Although it is possible, it would take a considerable amount of effort to append data to an already encrypted file - in effect running the encryption again to get the encrypter to the correct sate for the insert, including removing any padded final block padding before you append your data. The effort is the equivalent of re-writing the encryption routines.
It would be considerably easier and a lot quicker to decrypt, append, and re-encrypt again. Do NOT use a temporary file, use a memory stream instead as this will not be left on the HDD (unless it is paged off to free memory). A temporary files' contents will be left on the HDD even if the temporary file is deleted, until that disk space is re-used by some other application.
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Thank you for your swift answer OriginalGriff.
Let's see if i understand this correctly then, i will try and use your suggested method.
However using MemoryStream to decrypt, append and then rewrite the whole data into the same file wouldn't that overwrite that same file?
Using a memory stream to let's say decrypt a big file into memory, let's say 200MB wouldn't that affect system speed?
|
|
|
|
|
Balletje wrote: Using a memory stream to let's say decrypt a big file into memory, let's say 200MB wouldn't that affect system speed?
Yes. It may speed it up...
It's one of "those answers" which depends on too many variables: Does your system cache HDD writes? Does the HDD hardware cache writes, and is it big enough?
Think about it: If the stream stays in memory, it will be faster than writing to HDD (unless the HDD data also stays in memory). If it gets paged out, then it will be at about the same speed as the temporary file solution, except any other activity in the PC will slow down.
For me, the security risk of leaving unencrypted data just lying around is too high - it defeats the purpose of encryption in the first place. I always decrypt to memory - I may have no control over the page table, nor how many fragments of unencrypted data are in memory, but at least I can be as confident as possible that if you turn the power off, it will be a non-trivial task to access the unencrypted data!
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Ahhhh yes how stupid of me.......
I will go and try to construct a method that will decrypt the file into memory, append last data added to the end and re-encrypt the whole deal back.
Still i think i need to go and try to find some good lecture about this matter as i am having a bit of trouble understanding how it works.
Though people's input here has been great and i greatly appreciate it.
Thank you for explaining!
|
|
|
|
|
Does it even matter? You can't hide anything from the user anyway - if your application has the key and the user has the application then the user has the key, QED.
Anyway, in general it shouldn't be possible. AES is a block algorithm, so there will be padding, and you can't remove the padding without decrypting, because the padding is encrypted. Therefore at the very least, you will have to decrypt the last block. For the rest I am not sure, but I think I remember something about mixing the key with the data? If that is what it does then you can't just "run the key stream* X bytes where X is the length of the file" as you might otherwise do, since in order to do that you'd need to have the decrypted data an you don't have it. Unless of course you do have it, but you seem to want to avoid that. (why? it's not like you're keeping a secret from your users anyway, as proven above. decrypting to ram isn't going to make the situation any worse, although it may make the process slower)
* incorrect terminology
note: as always with posts about "hard" subjects, I can't guarantee the correctness of the contents of this post - use at your own risk.
|
|
|
|
|
Well it seems i need to do a lot more reading then, any good suggestions on books or online material that touches this subject?
It's critical to my application to store the data encrypted if possible, only the information supplied by the user should be encrypted in one file.
I would like to thank you both about shedding some light on this topic.
|
|
|
|
|
Btw, if you're just hiding the data from other users, wouldn't it be a lot easier to just use build-in NTFS encryption?
|
|
|
|
|
Well the application stores information about servers, their locations and needed passwords.
That was basically the whole reason why i wanted that file encrypted because *should* it fall in the wrong hands they will at least have some trouble getting the information from it.
But i am quite new to the whole encryption stuff, so i did not really know which way to take.
|
|
|
|
|
I see, well the build-in encryption is transparent so you don't have to do anything special - just set a flag that you want the file to be encrypted. The encryption is linked to the password of the current user, which is not the hardest thing to find out these days, but then that's probably true of the key used by your application as well..
|
|
|
|
|
It takes a bit of work, but you could code an interface to write a 'footer' that contains indexes of encrypted blocks within the file.
So for instance,
- you would write 1024 encrypted bytes
- then write a footer that says the index 0 file ends at 1024.
- when you want to append, read the footer to memory.
- shorten the file to that last index (erasing the footer).
- write your new encrypted block.
- write the new index (1) to footer in memory.
- write the new footer to the end of the file.
The downside (potentially) is that if you want to remove a file that is not at the last index, you essentially have to rewrite the entire file.
|
|
|
|
|
How do I 'undelete' files using C#?
|
|
|
|
|
|
Hello Everyone,
So, I am working on a robot for the Inteligent Ground Vehicle Competition (IGVC 2010) which will be held in june at Lawrence University. We have a robot that uses a SICK LMS 220 laser range finder as the object sensor, two webcams to track obstacle course boundry lines, and a GPS system. My job is to get the webcams to detect the white lines and track the distance of the line to the robot in order to keep the robot withing the lines (which are 10 feet apart and spray painted on grass). I got everything working in terms of "detecting" the white lines by using color filtering to select the color RGB value of the white lines via a reference image captured from the course. So it displays the white lines as white pixels on a black background. This works very well. An edge detection algorithm was also placed which does the job. Now I implemented a Projected Plane Transformation Matrix to calculate distances of points on the webcam's video feed via a calibration method using four points of known distances to the robot. This works suprisingly well also. No I arrived at a bit of a dillema; what part of the line shall i use to determine the distance of the line to the robot? Should I get the distances of every white pixel on the plane? Should I pick a few points that trigger an event when scanning horizontal lines on the image? Closest pixel to the robot? What about differing noise (rare) from white line edge pixels? Any feedback would help, this seems like a very fun topic which I know will tickle a few peoples' fancy. Enjoy!
Quick Notes:
-I am using the AForge.NET library for image processing
-I am using the C# Matrix Library (CSML.dll) taken from an article on this site for the plane transformation
-There are two cameras on the robot, one on each side
-The cameras I am using is the Microsoft LifeCam Cinema (2.0mp Widescreen HD)
-The image plane is 320x240 and in 1bpp grayscale
P.S. Once I finish, I will write an article about the robot for the website for everyone to enjoy!
|
|
|
|
|
Hi,
I answered your question (in a hand waving manner) a while back in the Q&A.
http://www.codeproject.com/answers/41166/Vehicle-Lane-Tracking-Algorithm.aspx[^]
I've a couple of questions:
How quickly will the robot go?
What is the track layout (is it tarmac, is it curved/oval)?
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
The only issue would be how to handle avoiding an obstacle and keep between the lines. The trapazoid will not give accurate readings as to how small the space in which the robot can turn (at its blind spot) without going over a white line or hitting an obstacle. My plan was to apply the distances to each white point on the camera's view onto the field of view of the lidar (which otherwise can NOT detect painted white lines) and use that to calculate the possible approach. I just think distancing and angling every white point on the image would be very time consuming processing wise.
|
|
|
|
|
I'd assumed you'd need something more like:
http://cmm.ensmp.fr/~beucher/prom_sta.html[^]
As you can see the lanes on the road form "Trapezoids" which can be detected, this doesn't help you, as you have a very different problem.
sebogawa wrote: I just think distancing and angling every white point on the image would be very time consuming processing wise.
Yes, but complicated tasks such as these are heavy-duty! One thing that strikes me immediately is that you should look at your camera/image resolution, it doesn't need to be very high and this will drastically cut down your processing costs.
Assuming the surface is flatish and the camera is at a constant height and angle, you can calculate the distance of every pixel in the image when the rig is calibrated (i.e. once) as each will always appear at the same distance due to the geometry being constant. Again, at calibration, you then create an ordered (by distance) dictionary of pixel co-ordinates. When you start in earnest it is just a matter of rattling through the image to find the nearest white pixel. Triaging the areas in the image into "Don't worry- too far away", "need to start planning", "urgent" could again reduce your costs.
Things that could complicate this are a) obstacles being mistaken for lines (if they are white) b) The robot heading off in the wrong direction!
Keep us informed as this sort of thing is interesting!!!!
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
One very important aspect that is missing here is the angle at which these webcam will measure the points.
There needs to be a levelor on the vehicle that measure the angle of webcam from horizon (Which cannot be assumed since the vehicle will be moving).
Once you have that angle, you could take the distance between those white lines at a particular angle from horizon to normalize all distances. This distance will always be correct.
|
|
|
|
|
The cameras are set at the edges of the front of the chassis of the robot at a 45 on the x, and a 45 degree on the -z. The matrix calculates the distancing regardless of known angle by comparing the four known points to the field of view of the camera. My issue is not in distancing, but rather in accurately knowing the distance and angle of the closest point of each line.
|
|
|
|
|
Hi,
I haven't done these things myself, however I would not bother about distances too much, instead I would replace the two white lines by a single line; a simple interpolation should yield that. Then aim for a point on the imaginary line, at a reasonable (but not very important) distance in front of you, and update your aiming point while moving.
|
|
|
|
|
The interpolation method would be fine if there were no obstacles that can take up 80% of the track width, I would need to allow the robot to deviate from the imaginary interpolated line almost to the point of crossing the real lines, as well as not being able to see the white lines up close where an obstacle is two feet away from a white line and that is the only method of progressing the course. I have seen a few robots fail last year in this point. The cameras interpolated the lines but when the robot got to a close pinch between obstacle and line, they merely ran through the white line and got back on course but rules state u can not pass lines...ever...
|
|
|
|
|
I see, thanks for that. I'll be looking forward to your article.
Is there a web site on the whole event?
|
|
|
|
|