binary

How can i check if binary file's content is found in other binary file?

给你一囗甜甜゛ 提交于 2021-02-08 08:11:14
问题 i need to check if content in a binary file in in other binary file. i've tried to copy both files content into a array of chars with fread and check them with strstr, but strstr is always returning NULL even if the content supposed to be found in the other file. Any ideas? Thanks. 回答1: Since the strstr function won't work here for an arbitrary binary data (it is working only for strings with \0 . termination), I can see three approaches here: 1) Naive approach: iterate over one array of

How does bgrep work?

我与影子孤独终老i 提交于 2021-02-08 05:31:34
问题 I am studying the command bgrep found here. I run bgrep "fafafa" test_27.6.2015.bin | less -M on the the binary data called test_27.6.2015.bin but I get test_27.6.2015.bin: 00005ee4 test_27.6.2015.bin: 0000bd3c I would suspect to get matches containing the term fafafafa . Two matches is the correct amount of matches. These hex numbers are probably of some segment containing fafafafa . How does bgrep form its search result? 回答1: bgrep's search result are formatted this way: printf("%s: %08llx

Why is __LINKEDIT sometimes 0x1000 off?

£可爱£侵袭症+ 提交于 2021-02-07 19:17:05
问题 Parsing an already-loaded Mach-O binary in memory... Sometimes the string table, symbol table, etc, are where they should be, and sometimes they're 0x1000 off. For example, I might run my program and baseOffset + cmd->symoff is accurate. Then I'll unit test and baseOffset + cmd->symoff + 0x1000 is accurate. baseOffset is always valid and pointing to a valid Mach header. 回答1: I figured it out by looking at dyld source code... It's not guarenteed to be 0x1000 off, however, the link edit offset

Why is __LINKEDIT sometimes 0x1000 off?

一世执手 提交于 2021-02-07 19:17:00
问题 Parsing an already-loaded Mach-O binary in memory... Sometimes the string table, symbol table, etc, are where they should be, and sometimes they're 0x1000 off. For example, I might run my program and baseOffset + cmd->symoff is accurate. Then I'll unit test and baseOffset + cmd->symoff + 0x1000 is accurate. baseOffset is always valid and pointing to a valid Mach header. 回答1: I figured it out by looking at dyld source code... It's not guarenteed to be 0x1000 off, however, the link edit offset

Java - parse binary to long [duplicate]

旧时模样 提交于 2021-02-07 13:14:14
问题 This question already has an answer here : Java 8: Why can't I parse this binary string into a long? (1 answer) Closed 4 years ago . I have a binary represenation of a number and want to convert it to long (I have Java 8) public class TestLongs { public static void main(String[] args){ String a = Long.toBinaryString(Long.parseLong("-1")); // 1111111111111111111111111111111111111111111111111111111111111111 System.out.println(a); System.out.println(Long.parseLong(a, 2));// ??? but Long

Java - parse binary to long [duplicate]

帅比萌擦擦* 提交于 2021-02-07 13:13:58
问题 This question already has an answer here : Java 8: Why can't I parse this binary string into a long? (1 answer) Closed 4 years ago . I have a binary represenation of a number and want to convert it to long (I have Java 8) public class TestLongs { public static void main(String[] args){ String a = Long.toBinaryString(Long.parseLong("-1")); // 1111111111111111111111111111111111111111111111111111111111111111 System.out.println(a); System.out.println(Long.parseLong(a, 2));// ??? but Long

How does exponent bias make comparison easier

假如想象 提交于 2021-02-07 09:24:29
问题 I'm reading this article about exponent bias in floating point numbers and it says the following: n IEEE 754 floating point numbers, the exponent is biased in the engineering sense of the word – the value stored is offset from the actual value by the exponent bias. Biasing is done because exponents have to be signed values in order to be able to represent both tiny and huge values, but two's complement, the usual representation for signed values, would make comparison harder. To solve this

Can someone explain Python struct unpacking?

人走茶凉 提交于 2021-02-07 06:27:06
问题 I have a binary file made from C structs that I want to parse in Python. I know the exact format and layout of the binary but I am confused on how to use Python Struct unpacking to read this data. Would I have to traverse the whole binary unpacking a certain number of bytes at a time based on what the members of the struct are? C File Format: typedef struct { int data1; int data2; int data4; } datanums; typedef struct { datanums numbers; char *name; } personal_data; Lets say the binary file

How do I query UUIDs stored as binary in a database (JPA/Hibernate/MySQL)

时光怂恿深爱的人放手 提交于 2021-02-07 02:36:52
问题 I have a Java/JPA/Hibernate/MySQL based app. I want to use UUIDs for object identity, however I want to ensure database performance does not suffer. I found this great blog posting JPA and UUID Primary Keys which gets me some of the way there. Notice how the storage of the UUID is optimized by storing it in binary form (versus the string representation. It solves part of the problem, because now we can insert objects efficiently into the database. However, now I have an issue when I want to

read double type data from binary file

拥有回忆 提交于 2021-02-06 13:47:46
问题 I want to read double values from a binary file and store them in a vector. My values have the following form: 73.6634, 73.3295, 72.6764 and so on. I have this code that read and store data in memory. It works perfectly with char types since the read function has as input a char type ( istream& read (char* s, streamsize n) ). When I try to convert char type to double I get obviously integer values as 74, 73, 73 and so on. Is there any function which allows me to read directly double values or