Given a command line (sub)string, find and parse its first argument. Parsing rules (see MS CRT): File names =========== Quoted string -> non-quoted string (quotes are not copied)
Regular argument ================ 2N backslashes + " -> N backslashes + begin/end quoted string (quote is not copied) 2N+1 backslashes + " -> N backslashes + literal " " + " in a quoted string -> single literal " all other combinations of symbols are copied as is
- Parameters:
-
[in] | cmdPtr | pointer to the command line (sub)string |
[in] | isFile | TRUE - use parsing rules for file name FALSE - use parsing rules for regular argument |
[out] | buf | buffer that receives argument after parsing. If this parameter is NULL, the argument is not copied. If the buffer is too small, the terminating NULL is not copied into the buffer. |
[in] | bufSize | size of the buffer; ignored if <buf> is NULL. |
[out] | pArgSize | pointer to variable that receives size of the argument to be copied into the buffer, not including terminating NULL. If this parameter is NULL, the argument size is not returned. Otherwise, the size value is returned even if <buf> is NULL. |
[out] | pNextPtr | pointer to variable that receives pointer to the command line substring following the found attribute. If this parameter is NULL, the pointer is not returned. |
- Returns:
- pointer to the first argument found in the specified command line (sub)string or NULL.
Given pin's command line, return substring containing application's command line. - Parameters:
-
[in] | pinCmdLine | command line of pin exe process. |
- Returns:
- pointer to substring containing application's command line; NULL, if application's command line is not found
Split string into 2 sub strings. Example1: prefix = SplitString(input = "aaa bbb ccc", " ") -> prefix = "aaa", input = "bbb ccc" Example2: prefix = SplitString(input = "aaa", " ") -> prefix = "aaa", input = ""
- Parameters:
-
| inout] | input - input string. remove prefix and set the new string into input. |
[in] | delimiter | - delimiter |
- Returns:
- prefix string
class that represents command line arguments
Empty Constructor
Constructor. Construct an object from argc, argv and delimiter Example1: argc = 6, argv = {ab bc cd de ef de}, delimiter = "de" => the object will contain: argc = 4, argv = {ab bc cd de} Example2: argc = 6, argv = {ab bc cd de ef de}, delimiter = NULL => the object will contain: argc = 6, argv = {ab bc cd de ef de} Example3: argc = 6, argv = {ab bc cd de ef de}, delimiter = "fg" => the object will contain: argc = 6, argv = {ab bc cd de ef de}
- Parameters:
-
[in] | argc | argc for the command line arguments object |
[in] | argv | argv for the command line arguments object |
[in] | delimiter | remove any argv argument AFTER the delimiter. If it was not found, nothing will be removed |
Constructor. Construct an object from a string using MS CRT Parsing rules (For more details see GetCmdArg() documentation)
NOTE: Use this function only for original application's command line
- Parameters:
-
[in] | commandLine | original application's command line represented as string |
Copy Constructor. Construct an object from another object
- Parameters:
-
[in] | source | source object |
Assignment operator
- Parameters:
-
[in] | source | source object |
- Returns:
- reference to current object
Append an object to current object (in the end of current object)
- Parameters:
-
[in] | right | object to be appended |
- Returns:
- reference to current object
Append an argument to current object (in the end of current object)
- Parameters:
-
[in] | arg | an argument to be appended |
- Returns:
- reference to current object
Find an argument by name
- Parameters:
-
[in] | argStr | - argument to be found |
- Returns:
- index of argument or -1 if not found
Looks for argument equal to argStr; remove "numOfArgs" arguments starting from the found argument
- Parameters:
-
[in] | argStr | - argument to be found, |
[in] | numOfArgs | - numer of arguments that should be removed starting from the found argument |
- Returns:
- TRUE if numOfArgs were removed from the list
Argc of current object the value life time is as long as the object was not changed (using operator=(), Append() or ~COMMAND_LINE_ARGUMENTS() will invalidate this data)
Argv of current object, the pointer life time is as long as the object was not changed (using operator=(), Append() or ~COMMAND_LINE_ARGUMENTS() will invalidate this data)
string with all command line arguments separated with \" \"
Destructor
Initialize the object using argc, argv and delimiter
Initialize the object using commandLine string
Deallocate all resources used by current object
Find array size using argc, argv and delimiter
Remove argument by index (0 <= index < m_argc)
< size of argv array
< CHAR* array
Set mode for printing of addresses, two formats are available either 0x12345678 or #1234_5678
ctype::isspace alternative (avoids complications from including ctype.h)
ctype::toupper alternative (avoids complications from including ctype.h)
print pointer
convert a UINT64 into a string using the hex address format
convert a UINT64 into a dec string. Padding can be specified as well
convert a UINT64 into a dec string. Padding can be specified as well
Convert an array of integers to string, separated by spaces.
convert a UINT64 into a dec string with 1000 separation . Padding can be specified as well
add new lines to string to make it fit given line width restrictions
convert a UINT64 into a hex string. Padding can be specified as well
convert a FLT into a string. Padding can be specified as well
convert a BOOL into a string.
convert a TRI into a string.
convert a string to a UINT32
convert a string to a UINT64
convert a string to a FLT64
Convert a string to an ADDRINT
popcount/bitcount code using the usual trick
read a line from file while maintaining a current line count skiping over blank and comment lines.
break a line into tokens separated by whitespace return them in 'array'
x
x
x
x
x
x
x
x
x
x
x
x
x
x
x
left justify string
convert ADDRINT to "void *"
convert "void *" to ADDRINT
convert "void *" to ADDRINT
Round integer of type <T> up to given alignment.
Specialization of the RoundUp function for pointer type
Round integer of type <T> up to given alignment. The alignment must be power of two.
Specialization of the RoundUpPowerOf2 function for pointer type
Round integer of type <T> down to given alignment.
Specialization of the RoundDown function for pointer type
Round integer of type <T> down to given alignment. The alignment must be power of two.
Specialization of the RoundDownPowerOf2 function for pointer type
Convert a pointer to an ADDRINT.
Convert an ADDRINT to a pointer.
convert "void *" to int
integer bit width check
Sign extend from origSize to extendedSize and check if it fits in a field of extendedSize
- Parameters:
-
[in] | value | - value to whose size we are checking |
[in] | origSize | - position of sign bit in value |
[in] | extendedSize | - size extend to this size, if 0 then extendedSize is origSize |
Wrapper for 3-arg SignedImmediateFits()
- Parameters:
-
| value | the value to whose size we are checking |
| origSize | where to look for the sign bit (typically 8,16,32 or 64) |
- Returns:
- true if sign extending from origSize to extendedSize will not change value
Internal helper for HashData().
Specialization for optimization (1 byte data size).
Specialization for optimization (2 byte data size).
Specialization for optimization (4 byte data size).
Specialization for optimization (8 byte data size).
Function to incrementally construct a hash value.
- Parameters:
-
[in] | prevHash | Previous hash value (or zero) |
[in] | data | New data item to include in hash value. |
- Returns:
- Returns the new hash value.
helper function for pin command line argument processing
another pin helper function for command line arguments
Determine if the fileName has the BaseName baseNameToCheckFor On Windows comparison is case-insensitive, others are case sensitive - Parameters:
-
[in] | fileName | The file name that is to be checked |
[in] | baseNameToCheckFor | Check if the file name has this name as it's filename
|
- Returns:
- true if the file name has specified baseNameToCheckFor as it's base name
Get the address of the page that addr is in
Return the entry point of a program (either that of the main image or of the dynamic loader)
Concatenate two strings with a path delimiter
Strip the path information
Create a temporary file name
- Returns:
- current stack pointer
Return offset, in bytes, of <ptr1> from <ptr2>
Return pointer whose offset, in bytes, from <ptr> is <offset>
Push data into stack and return updated value of top of stack the stack is growing to the lower addresses - Parameters:
-
[in] | stack | top of stack |
[in] | data | pointer to the data to be copied |
[in] | alignment | new value of top of stack suppose to be aligned on "alignment" value, in bytes. the value has to be power of 2 |
[in] | size | size of the data, in bytes |
- Returns:
- updated value of top of stack
Push ADDRINT value into stack and return updated value of top of stack - Parameters:
-
[in] | stack | top of stack |
[in] | value | value to be pushed |
- Returns:
- updated value of top of stack
Class that represents a memory range - interval of addresses in the virtual address space. - Note:
- The range that spans the entire address space can not be represented by this class. Whenever a function of this class should construct such range (logically), an empty range is returned instead.
Utility class intended to help in implementing functions that perform their action only "once", when called for the first time. The functions are assumed to return BOOL or VOID. - Note:
- the class is not multithread safe. USAGE: ONCE_STATE fooState; BOOL foo() { if (!fooState.Enter()) {return fooState.IsSuccess();} ..... return fooState.Exit(FALSE); ..... return fooState.Exit(TRUE); }
< initial state - function never executed
< function is currently running
< function executed successfully
< function executed but failed
Total net bytes allocated by RawMmap and RawMunmap. This must be global because another stats are normalized to this value. The actual value is kept as a local variable in sysfuncs_* and updated by UpdateRawMmapBytes to avoid accessing this variable before the constructor has run.
Total net bytes reserved.
Unattributed allocations
Get StatRawMmapBytes - the number of bytes allocated by Pin. Note that this returns bytes currently allocated, not all bytes that have ever been allocated. Basically, this value will rise and fall during execution.
Update StatRawMmapBytes from a local variable. We can't update the stat directly in RawMmap because it might be called before the constructor for the stat has been executed.
A function calling all malloc-related functions. Calling PullinPinMalloc() in pin and pinclient forces the dynamic loader to pull in the Pin's malloc. |