• How to update a binary SU file on Android - restoring root access for the SuperSu application. Writing and reading custom data types to binary files

    Files. Moreover, from the point of view of technical implementation at the hardware level, text files are a special case of binary files, and thus, in the broad sense of the word, any file fits the definition of “binary file”.

    Binary files are often used to refer to executable files and compressed data, but it is incorrect to limit this concept in such a way.

    Visualization

    For visual representation binary file it is broken into pieces of equal size, represented as numbers, usually written in hexadecimal, sometimes in octal, binary or decimal. The indicated chunk size can be equal to one octet, as well as two or four (in the case of splitting into chunks of several octets, the byte order adopted on the platform used is used). The dependence of the range of represented numbers on the size of the piece is shown in the table:

    octets number of bits hexadecimal octal decimal
    unsigned
    decimal
    iconic
    1 8 00

    FF
    000

    377
    0

    255
    -128

    127
    2 16 0000

    FFFF
    000000

    177777
    0

    65535
    -32768

    32767
    4 32 00000000

    FFFFFFFF
    00000000000

    37777777777
    0

    4294967295
    -2147483648

    2147483647

    Often, in addition to the numeric byte values, code page characters are also displayed, for example, printed ASCII characters on the right) at the beginning of the Wikipedia logo PNG file:

    00000000 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 |.PNG........IHDR| 00000010 00 00 00 87 00 00 00 a0 08 03 00 00 00 11 90 8f |............| 00000020 b6 00 00 00 04 67 41 4d 41 00 00 d6 d8 d4 4f 58 |.....gAMA.....OX| 00000030 32 00 00 00 19 74 45 58 74 53 6f 66 74 77 61 72 |2....tEXtSoftwar| 00000040 65 00 41 64 6f 62 65 20 49 6d 61 67 65 52 65 61 |e.Adobe ImageRea| 00000050 64 79 71 c9 65 3c 00 00 03 00 50 4c 54 45 22 22 |dyq.e<....PLTE""| 00000060 22 56 56 56 47 47 47 33 33 33 30 30 30 42 42 42 |"VVVGGG333000BBB| 00000070 4b 4b 4b 40 40 40 15 15 15 4f 4f 4f 2c 2c 2c 3c |KKK@@@...OOO,<| 00000080 3c 3c 3e 3e 3e 3a 39 39 04 04 04 1d 1d 1d 35 35 |<<>>>:99......55| 00000090 35 51 50 50 37 37 37 11 11 11 25 25 25 0d 0d 0d |5QPP777...%%%...| 000000a0 27 27 27 1a 1a 1a 38 38 38 2a 2a 2a 08 08 08 20 |"""...888***... | 000000b0 20 20 17 17 17 2e 2e 2e 13 13 13 bb bb bb 88 88 | ...............|

    Tools

    For visualization

    • debug (on Microsoft Windows, partially)
    • hexdump (in GNU/Linux, etc.)

    For editing

    Literature

    • Webster's New World Dictionary of Computer Terms, 4th. Ed, Prentice Hall, NY, 1992. ISBN 0-671-84651-5
    • Leontiev B.K. Microsoft Windows XP file formats: Directory, M.: ZAO “New Publishing House”, 2005. ISBN 5-9643-0059-6

    Wikimedia Foundation. 2010.

    See what a “Binary file” is in other dictionaries:

      Noun, m., used. compare often Morphology: (no) what? file, no? file, (see) what? file, what? file, about what? about the file; pl. What? files, (no) what? files, what? files, (I see) what? files, what? files, about what? about files 1. A file is an array... ... Dmitriev's Explanatory Dictionary

      Binary file in the broadest sense: a sequence of arbitrary bytes. The name is due to the fact that bytes consist of bits, that is, binary digits. In the narrow sense of the word, binary files are opposed to text files.... ... Wikipedia

      Binary file in the broadest sense: a sequence of arbitrary bytes. The name is due to the fact that bytes consist of bits, that is, binary digits. In the narrow sense of the word, binary files are opposed... ... Wikipedia

      configuration file- A binary or text file containing information that determines the behavior of an application, computer, or network device. Computer network topics EN configuration file... Technical Translator's Guide

      This term has other meanings, see IPA (meanings). .IPA format for archive files of Apple applications for iPhone, iPod Touch and iPad. Files with this extension are stored in the App Store and downloaded using iTunes for... ... Wikipedia

      This article or section needs revision. There are no modules, OOP or other newfangled trends in Pascal. Descriptions of extensions should only be present in articles about the corresponding ... Wikipedia

      Pascal Semantics: procedural Execution type: compiler Appeared in: 1970 Author(s): Niklaus Wirth Pascal is a high-level general-purpose programming language. One of the most famous programming languages, widely... ... Wikipedia

      Gopher Name: Gopher Port/ID: 70/TCP Specification: RFC 1436 Main implementations (clients): Mozilla Firefox, Microsoft Windows: IE 5.x, IE 6 (limited to MS) Gopher network protocol for distributed retrieval and document transfer, formerly widely used ... Wikipedia

      Name: Gopher Port/ID: 70/TCP Specification: RFC 1436 Main implementations (clients): Mozilla Firefox, Microsoft Windows: Internet Explorer 5.x, Internet Explorer 6 (limited to MS) Gopher network protocol for distributed search and transmission... ... Wikipedia

      - / * A B C D E F G H I J K L M N O P Q R S T U V W X Y Z Note: Since the file name extension can be anything, the list provided is not complete... Wikipedia

    Today we will talk about the most common error that occurs when launching the SuperSu program. The problem itself appears in the form of a notification with the following content: “There is no SU and SuperSu binary file.” How to update a binary su file on Android? You will learn about this from our material.

    SuperSU is a special administration application that allows advanced management of all installed applications. In other words, with SuperSU you get complete control over your Android device. More details about the program:

    So, when I launched SuperSU, the following message appeared on the screen:

    It needs to be clarified here that the Su file is a fundamental component of the “Superuser” rights, so by deleting it you lose root rights. And even if you have an old version of SuperSU, which does not exclude the possibility of working on it, then problems associated with performing any operations will definitely arise. Therefore, you will have to update, or rather, correctly install the Su binary file in any case.

    To do this, we will need to download and install the Baidu Root program. This application is not available on Google Play, so you can open any browser and find this utility, or click on the link provided and download it directly from this page. After which the downloading of the ark file will begin, the process of which will be visible on the display:

    Now we need to open the file and click the “Install” button. When asked for permission to install, click the “OK” button:

    Then a window will open with information about the data to which the application will gain access, and a warning about the responsibility of the user himself. We agree with everything, and now, the installation of Baidu Root is completed:

    After installation, two buttons will appear at the bottom of the display on the right and left, click on the right one, after which a blue monitor will appear in the center of the screen, where your Android model will be indicated, and a blue button in the center (get root), click on it, after which a reboot will occur apparatus. Now we try to launch the SuperSU application. A request for Root access (Superuser rights) will appear from Baidu Root, we provide it. Next, a request will appear to update the SU binary file, click the “Continue” button:

    Then the program will offer a way to install the SU file, select “Normal”. The installation process will begin, which the system will inform us about, and all our efforts are crowned again by a message from the system that the installation was completed successfully, click “OK”:

    That’s it, the procedure is completed, and we can fully use the SuperSu program and use all the tools available in the program’s arsenal, including carrying out the so-called. temporary 'unroot' on your device.

    How to install the Su binary file on Android using custom Recovery

    Did the method described above not solve the problem? Well, this is possible, especially for HTC models. In this case, you will have to use custom (alternative) recovery. And if you don’t have it installed yet, but you still have the desire to become an advanced user of the Android OS, then sooner or later you will have to install it. Because this tool will allow you to perform many necessary operations: create backups, install system updates or flash your Android with a different version of the operating system (ROM), etc.

    We will not tell you now how to install custom Recovery, because this is a topic for a separate conversation, and if you are interested in it, write, and we will tell you in detail how to perform this operation.

    Now we will assume that you are on topic and return to our question. That is, if you have a custom recovery (or you know how to install it), then look at the last screenshot, and instead of the button “ Fine", click " CWM/TWRP" After completing the procedure, we reboot the smartphone, after which, along with the system update, the Su binary file will also be updated.

    How to install SU file via command line

    If both methods did not help install (update) the SU file, then the situation becomes more complicated, although not fatally. The next method that we will talk about is aimed at fairly advanced users who have experience working with the command line and are familiar with the file structure of Android OS.

    So, our actions:

    Download the Terminal Emulator for Android and Root Browser applications. Then, download the updatesu.zip archive, unzip it and move the folder updaters to the SD card or internal memory of your Android device.

    Now let's launch Root Browser, go to the folder updaters and copy the following files: ( .has_su_daemon) (.installed_su_daemon) (install-recovery.sh) to a folder /system/etc

    After this, we need to set the correct permissions for these files:

    Then we need to go to the next folder, namely /system/bin and create a folder .ext and set permissions for it:

    The next step is to copy the su file located in the folder /system/xbin to the newly created folder ( /system/bin/.ext), rename the su file, putting a dot (.su) in front of the name and set the rights for it:

    All we have to do is launch the Terminal Emulator for Android application and enter the following commands:

    Now we reboot and again try to update the su binary file using the “Normal” button in the SuperSu program (see above).

    records), then it is quite understandable to want to somehow reduce the unused but occupied memory space.

    Especially for such cases there are records with variant part.

    Description of record with variant part

    In the var section record with variant part described like this:

    var<имя_записи>:record<поле1>: <тип1>; [<поле2>: <тип2>;] [...] case<поле_переключатель>: <тип>of<варианты1>: (<поле3>: <тип3>; <поле4>: <тип4>; ...); <варианты2>: (<поле5>: <тип5>; <поле6>: <тип6>; ...); [...] end;

    Non-variant part entries (before the case keyword) follow the same rules as a regular entry. Generally speaking, the non-variant part may be completely absent.

    Variant part begins with the reserved word case, after which the record field is indicated, which will subsequently serve as a switch. As with a regular case statement, the switch must belong to one of enum types data (see lecture 3). The list of options can be a constant, a range, or the union of several constants or ranges. The set of fields that must be included in the record structure if the corresponding option is executed is enclosed in parentheses.

    Example. In order to describe the contents of the library, the following information is needed:

    The columns “Title” and “Publisher” are common to all three options, and the remaining fields depend on the type of publication. To implement this structure we will use record with a variant part:

    type biblio = record name,publisher: string; case item: char of "b": (author: string; year: 0..2004); "n": (data: date); "m": (year: 1700..2004; month: 1..12; number: integer); end;

    Depending on the value of the item field, the record will contain either 4, 5, or 6 fields.

    Mechanism for using a record with a variant part

    The number of bytes allocated by the compiler for record with variant part, is determined by its “longest” version. The "shorter" sets of fields from other options take up only a certain part of the allocated memory.

    In the example above, the "longest" option is "b": it requires 23 bytes (21 bytes for string and 2 bytes for integer). Options "n" and "m" require 4 and 5 bytes respectively (see table).

    name, publisher item Variant part
    ... "b" author year
    ... "n" data
    ... "m" year month number
    ... "b" author year

    Binary files

    Binary files store information in the form in which it is presented in the computer's memory, and therefore are inconvenient for humans. Looking into such a file, it is impossible to understand what is written in it; it cannot be created or corrected manually - in some text editor - etc. However, all these inconveniences are compensated by the speed of working with data.

    In addition, text files are classified as structures sequential access, and binary - direct. This means that at any time you can access any element, not just the current element

    In the example above, the "longest" option is "b": it requires 23 bytes (21 bytes for the string and 2 bytes for the integer). Options "n" and "m" require 4 and 5 bytes respectively (see table).

    name, publisher item Variant part

    Binary files

    Binary files store information in the form in which it is presented in the computer's memory, and therefore are inconvenient for humans. Looking at such a file, it is impossible to understand what is written in it; it cannot be created or corrected manually - in some text editor - etc. However, all these inconveniences are compensated by the speed of working with data.

    In addition, text files are classified as sequential access structures, while binary files are classified as direct access structures. This means that at any time you can access anyone, not just the current element of the binary file.

    Typed files

    Variables of structured data types (except string) cannot be read from a text file. For example, if you need to enter data from a text file to fill the toy record with information about toys available for sale (product name, product price and age range for which the toy is intended):

    age: set of 0..18; (specified in the file by boundaries)

    then you will have to write the following code:

    c:char; i,j,min,max: integer;

    a: array of toys;

    begin assign(f,input); reset(f);

    for i:=1 to 100 do if not eof(f)

    then with a[i] do

    begin readln(f,name,price,min,max); age:=;

    for j:= min to max do age:=age+[j];

    As you can see, such element-by-element reading is very inconvenient and labor-intensive.

    A way out of this situation is offered typed files- their elements can belong to any basic or structured data type. The only restriction is that all elements must be of the same type. This apparent inconvenience is

    an indispensable condition for organizing direct access to the elements of a binary file: as in the case of arrays, if the length of each component of the structure is known exactly, then the address of any component can be calculated using a very simple formula:

    <начало_структуры> + <номер_компонента>*<длина_компонента>

    Description of typed files

    In the var section there are file variables designed to work with typed files, are described as follows:

    var<файловая_перем>: file of<тип_элементов_файла>;

    No file variable can be specified as a constant.

    Purpose of a typed file

    From now on until the end of the section, by the word "file" we will mean " binary typed file" (of course, unless otherwise specifically stated).

    Team assign(f,"<имя_файла>"); serves to establish a connection between the file variable f and the name of the file for which this variable will be responsible for working.

    Line "<имя_файла>" may contain the full path to the file. If the path is not specified, the file is considered to be located in the same directory as the program's executable module.

    Opening and closing a typed file

    Depending on what actions your program is going to perform with the file being opened, it can be opened in two ways:

    reset(f); - opening a file to read information from it and at the same time to write to it (if such a file does not exist, an attempt to open it will cause an error). The same command is used to return a pointer to the beginning of the file;

    rewrite(f); - opening a file to write information to it; if such a file does not exist, it will be created; if a file with the same name already exists, all information previously contained in it will disappear.

    Are closing typed files procedure close(f) , common to all file types.

    Reading from a typed file

    Reading from a file that is open for reading is done using the read() command. In parentheses, the name of the file variable is indicated first, and then the input list1) :

    You can only enter variables of the type corresponding to the declaration from a file, but this data type can also be structured. Let's say, if we return to the example given at the beginning of paragraph. " Typed files", it will become obvious that the use typed file instead of text will significantly reduce the text of the program:

    type toy = record name: string; price: real;

    age: set of 0..18; (defined by boundaries)

    var f: file of toy;

    a: array of toys; begin

    assign(f,input);

    for i:=1 to 100 do

    if not eof(f) then read(f,a[i]); close(f);

    Search in a typed file

    The function eof(f:file):boolean, already familiar to us, reports when the end of the file has been reached. All other "end search" functions (eoln(), seekeof() and seekeoln()) inherent to text files cannot be applied to typed files.

    But there are special subroutines that allow you to work with typed files as with direct access structures:

    1. The function filepos(f:file):longint will report the current position of the pointer in filef. If it points to the very end of a file containing N elements, then this function will return the result N . This is easy to explain: the elements of the file are numbered starting from zero, so the last element is numbered N-1. And numberN thus belongs to a “non-existent” element - a sign of the end of the file.

    2. The filesize(f:file):longint function will calculate the length of the file f .

    3. The seek(f:file,n:longint) procedure will move the pointer in file f to the beginning of record number N . If it turns out that n is greater than the actual length of the file, then the pointer will be moved beyond the actual end of the file.

    4. The procedure truncate(f:file) will trim the “tail” of the filef: all elements from the current to the end of the file will be removed from it. In fact, only the “end of file” sign will be rewritten to the place where the pointer pointed, and the physically “cut off” values ​​will remain in their original places - they will simply become “orphaned”.

    Writing to a Typed File

    You can save variables to a file that is open for writing using the write() command. As with reading, the file variable is listed first, followed by the output list:

    write(f,a,b,c); - write to file f (previously opened for writing with the commands rewrite (f) or reset (f) ) variables a , b , c .

    Output to typed file Only variables that match the data type description are allowed. Unnamed and untyped constants cannot be printed to

    typed file.

    Typed files are considered as both direct and sequential access structures. This means that writing is possible not only at the very end of the file, but also at any other element. The value written will replace the previous value in this element (the old value will be “overwritten”).

    For example, if you need to replace the fifth element of a file with the value stored in the variable a, then you would write the following program excerpt:

    seek(f,5); (the pointer will be set to the beginning of the 5th element)

    write(f,a); (the pointer will be set to the beginning of the 6th element)