binaryfiles

Is it possible to load a binary file into memory and execute it in windows

空扰寡人 提交于 2019-12-04 18:47:00
I am trying to write a program to read a binary file from memory execute it and exit but the OS doesn't seem to let me execute it from memory, the entire point of this exercise is to load a binary file with no header into memory. This is my code for the binary file: push eax mov eax,3 mov edi,eax sub eax,edi pop eax leave ret And my loader is as follows: int main(int argc, char **argv){ void (*ptr)(void); FILE *fo = fopen(argv[1],"r"); int l = fseek(fo,0,SEEK_END); fread((void*)ptr,l*sizeof(char),1,fo); ptr(); return 0; } I know I am probably going about this the wrong way. While the code you

Write array of Float to binary file and read it in swift

廉价感情. 提交于 2019-12-04 17:13:13
How can I write array of Float to binary file and then read it? var array: [Float]: [0.1, 0.2, 0.3] func writeArrayToBinary(array: [Float]) { //... } func readArrayFromBinary() -> [Float] { //... } Please try this... var array: [Float] = [0.1, 0.2, 0.3] func writeArrayToPlist(array: [Float]) { if let arrayPath: String = createArrayPath() { (array as NSArray).writeToFile(arrayPath, atomically: false) } } func readArrayFromPlist() -> [Float]? { if let arrayPath: String = createArrayPath() { if let arrayFromFile: [Float] = NSArray(contentsOfFile: arrayPath) as? [Float] { return arrayFromFile } }

updating binary file containing structs in c, offsets changing to corrupt rest of file

放肆的年华 提交于 2019-12-04 15:02:11
I'm trying to write a method that will, given a file containing values to update or append, will update a second binary file. Apparently, when I overwrite a struct in the binary file, the offsets somehow change and that corrupts everything after it. Am I doing something wrong, and is there a way to prevent this without truncating and appending to the file? Current code: typedef struct{ int number; double price; } stock; void update(char* updatefile, char* binfile){ FILE *fin, *fout; stock *currStock; stock *updateStock; int currPos; int update; int val1=0; double val2=0; currStock = malloc

binary encoding for JSON?

北城余情 提交于 2019-12-04 13:41:04
My Javascript application is downloading quite a bit of data from the server and I was thinking that in addition to normal gzip that's done by the server, I can encode the data in some binary format rather than textual JSON. Is there a standard way of doing this? Ideally it should be some small tool that can take a JSON text file and convert it to a generic binary format and a small Javascript library which decodes it. Also, is there something special that needs to be done in XHR to pass binary data? If gzip doesn't compress well enough, chances are your binary format won't either, especially

Reading integer values from binary file using Java

戏子无情 提交于 2019-12-04 13:10:23
I am trying to write values greater than 256 using DataOupPutStream.write() method. When i try reading the same value using DataInputStream.read() it will return 0. So, i used DataOutputStream.writeInt() and DataInputStream.readInt() methods to write and retrieve values greater than 256 and it is working fine. Refer the below code snippet i would like to know the behaviour of the compiler as what it does in the in.readInt() inside the while statement. FileOutputStream fout = new FileOutputStream("T.txt"); BufferedOutputStream buffOut = new BufferedOutputStream(fout); DataOutputStream out = new

Uploading BLOB/ArrayBuffer with Dropzone.js

旧街凉风 提交于 2019-12-04 11:37:50
Using SharePoint 2013 REST API, I'm successfully uploading files, such as .docx or .png 's to a folder inside a document library using Dropzone.js. I have a function where I initialize my dropzone as follows: myDropzone = new Dropzone("#dropzone"); myDropzone.on("complete", function (file) { myDropzone.removeFile(file); }); myDropzone.options.autoProcessQueue = false; myDropzone.on("addedfile", function (file) { $('.dz-message').hide(); myDropzone.options.url = String.format( "{0}/{1}/_api/web/getfolderbyserverrelativeurl('{2}')/files" + "/add(overwrite=true, url='{3}')", _spPageContextInfo

Ubuntu: How to link a binary

谁都会走 提交于 2019-12-04 11:18:29
问题 I have a C++ code. I compiled it and I now have the binary xyz. Now everytime I need to execute the binary, I had to switch to the corresponding directory to execute it using ./xyz But how do I run the binary using a command say xyz from anywhere. How do I link this binary to a command in ubuntu. I currently use Ubuntu 10.10 回答1: Ubuntu sets your PATH environment variable to include ~/bin . So the easiest way to make xyz executable from anywhere is move xyz to ~/bin , or to make a symlink

Replace sequence of bytes in binary file

穿精又带淫゛_ 提交于 2019-12-04 08:25:30
问题 What is the best method to replace sequence of bytes in binary file to the same length of other bytes? The binary files will be pretty large, about 50 mb and should not be loaded at once in memory. Update: I do not know location of bytes which needs to be replaced, I need to find them first. 回答1: Assuming you're trying to replace a known section of the file. Open a FileStream with read/write access Seek to the right place Overwrite existing data Sample code coming... public static void

MATLAB reading a mixed data type binary file

故事扮演 提交于 2019-12-04 06:29:41
问题 I am having trouble reading a very large binary file (1,000,000 bytes +) If I fread the file in a 1 byte data format for example 'uint8' the number of data read equals the size of the file so memory isn't an issue. I know in this binary file there is data of type 'int16' and 'single' however I don't know the structure of the file. I think the file is structured so there is an 'int16' data point followed by a 'single' data point and this is repeated until the end of the file. I do not know how

How to delete parts from a binary file in C++

南笙酒味 提交于 2019-12-04 04:59:13
问题 I would like to delete parts from a binary file, using C++. The binary file is about about 5-10 MB. What I would like to do: Search for a ANSI string "something" Once I found this string, I would like to delete the following n bytes, for example the following 1 MB of data. I would like to delete those character, not to fill them with NULL, thus make the file smaller. I would like to save the modified file into a new binary file, what is the same as the original file, except for the missing n