@@ -157,11 +157,54 @@ file and create signatures based on those results.
157157.. c :function :: mode(offset, size)
158158
159159 .. versionadded :: 4.2.0
160-
160+
161161 Returns the most common byte, starting at *offset * and looking at the next
162162 *size * bytes. When scanning a
163163 running process the *offset * argument should be a virtual address within
164164 the process address space. The returned value is a float.
165165 *offset * and *size * are optional; if left empty, the complete file is searched.
166166
167167 *Example: math.mode(0, filesize) == 0xFF *
168+
169+ .. c :function :: to_string(int )
170+
171+ .. versionadded :: 4.3.0
172+
173+ Convert the given integer to a string. Note: integers in YARA are signed.
174+
175+ *Example: math.to_string(10) == "10" *
176+ *Example: math.to_string(-1) == "-1" *
177+
178+ .. c :function :: to_string(int , base)
179+
180+ .. versionadded :: 4.3.0
181+
182+ Convert the given integer to a string in the given base. Supported bases are
183+ 10, 8 and 16. Note: integers in YARA are signed.
184+
185+ *Example: math.to_string(32, 16) == "20" *
186+ *Example: math.to_string(-1, 16) == "ffffffffffffffff" *
187+
188+ .. c :function :: to_int(string)
189+
190+ .. versionadded :: 4.3.0
191+
192+ Convert the given string to a signed integer. If the string starts with "0x"
193+ it is treated as base 16. If the string starts with "0" it is treated base
194+ 8. Leading '+' or '-' is also supported.
195+
196+ *Example: math.to_int("1234") == 1234 *
197+ *Example: math.to_int("-10") == -10 *
198+ *Example: math.to_int("-010" == -8 *
199+
200+ .. c :function :: to_int(string, base)
201+
202+ .. versionadded :: 4.3.0
203+
204+ Convert the given string, interpreted with the given base, to a signed
205+ integer. Base must be 0 or between 2 and 32 inclusive. If it is zero then
206+ the string will be intrepreted as base 16 if it starts with "0x" or as base
207+ 8 if it starts with "0". Leading '+' or '-' is also supported.
208+
209+ *Example: math.to_int("011", 8) == "9" *
210+ *Example: math.to_int("-011", 0) == "-9" *
0 commit comments