Using VM VirtualBox I'm running a copy of 32bit Linux which is itself running a VM for an ARM environment. This entire setup is needed to have an environment that lets me do buffer overflows for a class.
Twice now, I've come back to my code in Nano to find that the entire file had just been changed to a line of nothing but.
#^#^#^#^#^#^#^
going on and on. The first time it happened I thought I made some kind of mistake overwriting my C file with my compiled code. I moved on and worked on a different machine but now it's happened a second time and I'm sure I didn't accidentally overwrite anything.
Does anyone have any idea what could possibly cause this? Is there anyway to save my code?
Related
A few weeks ago, I copied some directories from an old external hard drive to my iMac. I ended up with a few corrupt files due to the bad state of this ancient hard drive.
I managed to delete them, but some remain.
At the beginning, I thought it was only a question of file permissions or character encoding, but surprisingly, it's not. I've read every single posts in stackoverflow about similar issues on other unix systems.
Here are some screenshots, you'll understand easily the issue.
That is my OS and the bad files :
I can not delete anything, even after rewriting :
I can not chmod. Chmod shows me some ghost files I didn't know existed.
I can not chown either :
This is an encrypted APFS partition :
I can not run any Disk Utility repair because of this FS corruption (exit error code 8). This doesn't work either on my Mojave USB installer, same error code.
I can not decrypt the partition using FireVault, it stays stuck at 0% forever.
I never saw anything like this. What do you think we should do ?
I'm writing an extension to mosquitto, however I'm having the issue that only changes that I make in the src folder are actually reflected in the final mosquitto server and mosquitto_pub/mosquitto_sub clients. I originally set it up with CMake and compiled all of that, and now to rebuild the clients/server I run make clean and then make in the src and client folders. They compile fine and new clients are built, however no changes I made in the c files in the client/lib folders are actually in the compiled programs. Anyone know what is going on? Am I misunderstanding something about how to compile it or how it runs?
eg. I modified _mosquitto_handle_connack() in lib/read_handle_client.c to print a different message at line 32 (_mosquitto_log_printf(mosq, MOSQ_LOG_DEBUG, "Client %s received CONNACK", mosq->id);) however no matter what I change the text to it still displays the original text. I even modified _mosquitto_packet_handle() in lib/read_handle.c so that when it receives a CONNACK it doesn't do anything, but when I compile and re-run it still handles the CONNACK like in the standard mosquitto.
Edit: I've done a little bit more testing of the issue and I've found something weird. If I delete an entire method in one of the files, compilation will fail because the method doesn't exist. If I just delete everything inside the method, compilation will succeed and the program will act as if everything I've just deleted is still there.
I realised that the problem is simple, I was running the clients without a ./ in front of them, so it was running the mosquitto clients I had installed (and completely forgotten about) 8 months earlier rather than the clients in the folder I was in.
My setup consists of the Espressif SDK using eclipse and a nodemcu, which I want to program in C.
I have followed all he steps and I can compile and flash the board from the eclipse environment. I don't press any buttons to load the flash because the board can handle it by itself (at least that's what I read). According to this apparently I have a nodemcu 0.9, but the board I have doesn't look quite like the one in the picture (the microstrip antenna looks weird .. and on the back of the board it says www.doit.am ESP12E devkit V2 ... the antenna on mine doesn't even look like the one on the site listed behind the board).
I looked past everything and kept on going. I compiled the blinky example on espressif and flashed it. I saw that it created the eagle.flash.bin and eagle.irom0text.bin and loads them in 0x00000 and 0x10000 respectively (according to documents I've read this is ok). When i reset the board I can see that it really flashed and there is a program in it since the led is blinking. Then I tried the hello_world example. Everything went accordingly and after I reset the board I see that the led keeps on blinking at the same frequency and when I connect to the board via the terminal.exe provided by espressif I can only see garbage in the output, even though the baud is correct according to the code (even so I tried all different bauds possible in terminal.exe).
Ok ... then I went to the blinky example again and increased the delay between blinks. Flashed it and the the frequency stayed the same. I know that it created new .bin files, but still, nothing changed. This led me to create a new project. I did it, following the instructions provided by Mikhail Grigorev. I just put an infinite loop, expecting to get nothing, but after flashing the newly compiled firmware I can still see the led blinking at the same frequency even though there is absolutely nothing in the code, I even wiped the flash before (yes, I verified the flash was empty).
So this lead me to test every single example I could compile. I noticed that some didn't blink the led and others did, like nothing happened. After that i downloaded the nodemcu firmware, and after loading it I noticed that it worked properly and I could even see the ESP in the available wifi networks.
I really don't understand what's happening. Why do some examples work and others don't? Why can't I modify the source code of a simple blinky and see the change? I really prefer to use the esp module this way, since I don't like the arduino interface or the way that it uses a static setup and loop functions, and I don't want to program it in LUA.
I even checked the makefiles provided by espressif and the only difference I can see are the BOOT and APP variables. I even tried modifying them, but still .. no changes.
Can anybody help me?
Ok, finally found my problem. The thing is that the espressif SDK needs some software bits on certain addresses of the flash. What initially happened is that I erased the flash as soon as I got the board, assuming all those binaries would have already been stored in flash.
The next thing I did is that I tried putting all the other binaries, but I was putting them in the wrong addresses, so the software wouldn't work.
Finally, after many many hours of reading forums and reading documentation, I found the correct addresses and it worked.
The addresses are:
0x00000 - boot_v1.6.bin
0x01000 - firmware application (I set the makefile to BOOT=new, APP=1, SIZE_MAP=6)
0x3fc000 - esp_init_data_default.bin
0xfe000 - blank.bin
0x3fe000 - blank.bin
First I want to ask whether is it possible for an application to update itself at runtime on same address space?
If yes, what's the best way to implement the logic?
Usecase : My application is running on a board which is connected to network. At runtime if it detects a new version of same application, then how to update the application on same memory address, where previous one is stored.
As per my understanding first we should take the backup of update and at the time of boot load, main application should be updated with backup and then launch the application normally. Am I right?
Usually you can replace the file containing the executable while it's running without problems.
After you update the file, you can start the application like always, and close your running instance.
If you however want to do it at runtime (i.e. without forking or starting new process), I don't think it's possible without extremely weird hacks:
if you plan to "rebase" your program memory with new executable's code, you'd need to figure the stack, memory and instruction pointers for each thread. You'd need to become a disassembler.
if you plan to call a stub in your program after loading it into auxilliary memory segment, that's fine, but you need to figure where the target function is, and what happens if it's gone in your next update. Plus it's totally platform-specific.
if you plan to standardize the above approach by using shared libraries that are dynamically loaded and unloaded, I see no problem - it's very similar to the approach where you restart entire process.
I'd go with replacing just the executable, or the third option if I have a very good reason for this. The last option is nice since it lets you update your application's components separately (but at the same time this might cause you maintenance headaches later on.)
What you need is something akin to a bootloader. In this case: you will have two programs on the device, hereafter referred to as the Loader and the App.
On your initial install of the system: write the App to the beginning of memory and the Loader somewhere further down to give space if the App grows in size in the future. (Keep note of the beginning memory address of the Loader)
The App will run normally as if it was the only program, periodically checking for updates to itself. If it finds an update on the network, use a GOTO to go to the first memory location of your Loader, which will then begin running and can write over the original App with the new App found on the network. At the end of your Loader, GOTO back to the (new) App.
See this Stack Overflow question for ideas on how to GOTO to specific memory addresses. Goto a specific Address in C
For some strange reason, when I move a PHP file from one folder to another, Vista copies an old version of the file instead of the current version. This really screws up the web application I'm working on and causes me to waste time in figuring out the problem.
What the hell is going on here and how do I prevent Vista from copying or moving previous versions of a file?
To explain a little further, when I open my PHP file in its current location I see the current version of my code. When I copy the file to the new location and open the file I see an old version of the code.
Check \UserName\Documents\AppData\Local\VirtualStore (or whatever %LOCALAPPDATA%\VirtualStore equates to) and see if somehow you're running into Vista's virtual store with your editor.
(This article explains some of how the virtual store works.)