Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
What is the basis difference between an executable file and a non-executable file? is it just that the bytes of an executable are arranged in a meaningful order which a CPU can understand as instructions?
An executable file contains an operating system specific header indicating that the file is meant to hold executable instructions, as well as the instructions themselves. Typically though not universally certain file extensions are either common by convention or required to indicate that a file is executable in addition to the file having a valid header.
If the operating system is told to execute a file, it will check the file header and possibly file extension and, if those match the rules for executability (after possibly checking security concerns as well), the operating system will load the file into memory and attempt to execute the instructions therein.
There's a good overview on Wikipedia
http://en.wikipedia.org/wiki/Executable_and_Linkable_Format
http://en.wikipedia.org/wiki/EXE
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 11 months ago.
Improve this question
everyone! I'm learning how to access files in C but, I wonder how my program(or C) access files(drive sectors)? I'm searching the Internet for answers but they don't have some proper explanation on how C(or my program), loads drive sectors to memory. Please give me some clarity, and thanks in advance.
C programs use functions of the kernel or a device driver to access hardware. A computing platform (Windows, Linux, OSX, etc) that supports C provides an implementation of the C standard library for programmers. This library contains system specific implementations of functions for accessing files, like fopen. The systems implementation of the standard library is most often just a wrapper around their specific system calls. For example on Windows, the C standard library is going to end up calling these functions: https://learn.microsoft.com/en-us/windows/win32/api/fileapi/
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
This post was edited and submitted for review 11 months ago and failed to reopen the post:
Original close reason(s) were not resolved
Improve this question
I need to install a C program UNIX to another UNIX machine, what can I do?
In case the other machine has different architecture how can I share my program in the best way?
The simplest way to share your program is compile it and share the binaries. There are a lot of open question you will have to solve (libraries dependencies, specific distribution configurations, ...). You must to precompile for every targeted hardware architecture (x86-64, ARM, ...) and for every specific SO (BSD, Linux, ... even Windows).
As an example, Gimp is coded in C/C++ and exists binaries for many hardware architectures and operating systems.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I am confused about .obj files created using C language. Does they contain machine code and is the machine code in binary language, as it is known that the machine can understand only binary language. Moreover, my thinking of machine code is that it is a set of machine instructions in binary language (I may be wrong). Please explain.
An object file is a file containing object code, meaning relocatable format machine code that is usually not directly executable. .obj is the compiled object file that is used by the linker (along with the necessary library (.h) files) to create an executable. The executable is then loaded into the memory for execution using a loader.
Please read the following for more information-
What is compiler, linker, loader?
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
Using a C program how to get the free size available in a directory ?
What are the library functions that i can use to achieve this.
A given directory does not have free space, it is the file system (containing that directory) which has free space.
You can query that using the df(1) command (you might popen(3) "/bin/df .", but I don't recommend doing that) and the statfs(2) (and some other) syscall(s).
See syscalls(2) and read Advanced Linux Programming
Perhaps the limit is quota related, see repquota(8), or resource-limit related, see ulimit builtin of bash and getrlimit(2). Maybe use /proc/ pseudo-files, see proc(5)
BTW, that limit is in fact only indicative: other programs and processes are also able to fill the directory (e.g. between the moment your program is querying it and the moment it is writing data).
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 8 years ago.
Improve this question
There are many file shredders programs that one can use in order to delete permanently one file. What I want to know is some implementation details. For example, considering Gutmann algorithm, how it should work with file and file system? Should an application iterate over all hdd cluster in order to overwrite them? Or it will be enough to open one file, change it content in some way and after that to delete it?
Vice versa, how to restore deleted file? I have not found a lot of information for these topics.
I will be very thankful for your replies.
You could look at the source code of the shred utility which is a part of the GNU core utils found on Linux.The basic idea is to make multiple passes over the disk blocks.There are also some assumptions made about the way the underlying files system commits these writes. See info coreutils 'shred invocation' for more information.
Restoring deleted files are done best when you know the internal layout of the file system in question and how the delete operation is implemented on it. For example, many drivers for the FAT file system just mark the directory entry as deleted but leave the file's content in tact. (Until and unless it is over-written by new files that you create). So you could just take a dump of the disk and scan through the raw data looking for what you want.