diff options
author | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 12:46:38 +0000 |
---|---|---|
committer | maruel@chromium.org <maruel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-05 12:46:38 +0000 |
commit | f0a51fb571f46531025fa09240bbc3e1af925e84 (patch) | |
tree | 558b4f0e737fda4b9ab60f252c9c23b8a4ca523e /tools/memory_watcher | |
parent | 6390be368205705f49ead3cec40396519f13b889 (diff) | |
download | chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.zip chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.gz chromium_src-f0a51fb571f46531025fa09240bbc3e1af925e84.tar.bz2 |
Fixes CRLF and trailing white spaces.
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10982 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/memory_watcher')
-rw-r--r-- | tools/memory_watcher/ia32_modrm_map.cc | 18 | ||||
-rw-r--r-- | tools/memory_watcher/ia32_opcode_map.cc | 60 | ||||
-rw-r--r-- | tools/memory_watcher/memory_watcher.cc | 4 | ||||
-rw-r--r-- | tools/memory_watcher/memory_watcher.h | 2 | ||||
-rw-r--r-- | tools/memory_watcher/mini_disassembler.cc | 50 | ||||
-rw-r--r-- | tools/memory_watcher/mini_disassembler.h | 14 | ||||
-rw-r--r-- | tools/memory_watcher/mini_disassembler_types.h | 14 | ||||
-rw-r--r-- | tools/memory_watcher/preamble_patcher.cc | 52 | ||||
-rw-r--r-- | tools/memory_watcher/preamble_patcher.h | 40 | ||||
-rw-r--r-- | tools/memory_watcher/preamble_patcher_with_stub.cc | 6 |
10 files changed, 130 insertions, 130 deletions
diff --git a/tools/memory_watcher/ia32_modrm_map.cc b/tools/memory_watcher/ia32_modrm_map.cc index eaae07c..c2f9625 100644 --- a/tools/memory_watcher/ia32_modrm_map.cc +++ b/tools/memory_watcher/ia32_modrm_map.cc @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -48,7 +48,7 @@ const ModrmEntry MiniDisassembler::s_ia16_modrm_map_[] = { /* r/m == 100 */ { false, false, OS_ZERO }, /* r/m == 101 */ { false, false, OS_ZERO }, /* r/m == 110 */ { true, false, OS_WORD }, - /* r/m == 111 */ { false, false, OS_ZERO }, + /* r/m == 111 */ { false, false, OS_ZERO }, // mod == 01 /* r/m == 000 */ { true, false, OS_BYTE }, /* r/m == 001 */ { true, false, OS_BYTE }, @@ -57,7 +57,7 @@ const ModrmEntry MiniDisassembler::s_ia16_modrm_map_[] = { /* r/m == 100 */ { true, false, OS_BYTE }, /* r/m == 101 */ { true, false, OS_BYTE }, /* r/m == 110 */ { true, false, OS_BYTE }, - /* r/m == 111 */ { true, false, OS_BYTE }, + /* r/m == 111 */ { true, false, OS_BYTE }, // mod == 10 /* r/m == 000 */ { true, false, OS_WORD }, /* r/m == 001 */ { true, false, OS_WORD }, @@ -66,7 +66,7 @@ const ModrmEntry MiniDisassembler::s_ia16_modrm_map_[] = { /* r/m == 100 */ { true, false, OS_WORD }, /* r/m == 101 */ { true, false, OS_WORD }, /* r/m == 110 */ { true, false, OS_WORD }, - /* r/m == 111 */ { true, false, OS_WORD }, + /* r/m == 111 */ { true, false, OS_WORD }, // mod == 11 /* r/m == 000 */ { false, false, OS_ZERO }, /* r/m == 001 */ { false, false, OS_ZERO }, @@ -87,7 +87,7 @@ const ModrmEntry MiniDisassembler::s_ia32_modrm_map_[] = { /* r/m == 100 */ { false, true, OS_ZERO }, /* r/m == 101 */ { true, false, OS_DOUBLE_WORD }, /* r/m == 110 */ { false, false, OS_ZERO }, - /* r/m == 111 */ { false, false, OS_ZERO }, + /* r/m == 111 */ { false, false, OS_ZERO }, // mod == 01 /* r/m == 000 */ { true, false, OS_BYTE }, /* r/m == 001 */ { true, false, OS_BYTE }, @@ -96,7 +96,7 @@ const ModrmEntry MiniDisassembler::s_ia32_modrm_map_[] = { /* r/m == 100 */ { true, true, OS_BYTE }, /* r/m == 101 */ { true, false, OS_BYTE }, /* r/m == 110 */ { true, false, OS_BYTE }, - /* r/m == 111 */ { true, false, OS_BYTE }, + /* r/m == 111 */ { true, false, OS_BYTE }, // mod == 10 /* r/m == 000 */ { true, false, OS_DOUBLE_WORD }, /* r/m == 001 */ { true, false, OS_DOUBLE_WORD }, @@ -105,7 +105,7 @@ const ModrmEntry MiniDisassembler::s_ia32_modrm_map_[] = { /* r/m == 100 */ { true, true, OS_DOUBLE_WORD }, /* r/m == 101 */ { true, false, OS_DOUBLE_WORD }, /* r/m == 110 */ { true, false, OS_DOUBLE_WORD }, - /* r/m == 111 */ { true, false, OS_DOUBLE_WORD }, + /* r/m == 111 */ { true, false, OS_DOUBLE_WORD }, // mod == 11 /* r/m == 000 */ { false, false, OS_ZERO }, /* r/m == 001 */ { false, false, OS_ZERO }, diff --git a/tools/memory_watcher/ia32_opcode_map.cc b/tools/memory_watcher/ia32_opcode_map.cc index df57b2a..aa10efa 100644 --- a/tools/memory_watcher/ia32_opcode_map.cc +++ b/tools/memory_watcher/ia32_opcode_map.cc @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -262,10 +262,10 @@ const Opcode s_first_opcode_byte[] = { /* 0xD5 */ { 0, IT_GENERIC, AM_I | OT_B, AM_NOT_USED, AM_NOT_USED, "aad", false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xD6 */ { 0, IT_UNUSED, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xD7 */ { 0, IT_GENERIC, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, "xlat", false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, - + // The following 8 lines would be references to the FPU tables, but we currently // do not support the FPU instructions in this disassembler. - + /* 0xD8 */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xD9 */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xDA */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, @@ -274,8 +274,8 @@ const Opcode s_first_opcode_byte[] = { /* 0xDD */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xDE */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xDF */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, - - + + /* 0xE0 */ { 0, IT_JUMP, AM_J | OT_B, AM_NOT_USED, AM_NOT_USED, "loopnz", false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xE1 */ { 0, IT_JUMP, AM_J | OT_B, AM_NOT_USED, AM_NOT_USED, "loopz", false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0xE2 */ { 0, IT_JUMP, AM_J | OT_B, AM_NOT_USED, AM_NOT_USED, "loop", false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, @@ -587,7 +587,7 @@ const Opcode s_opcode_byte_after_0f[] = { /* F3h */ { 0 }, /* 66h */ { 0, IT_GENERIC, AM_V | OT_DQ, AM_W | OT_DQ, AM_NOT_USED, "pcmpeqd" } }, /* 0x77 */ { 0, IT_GENERIC, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, "emms", false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, - + // The following six opcodes are escapes into the MMX stuff, which this disassembler does not support. /* 0x78 */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0x79 */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, @@ -595,7 +595,7 @@ const Opcode s_opcode_byte_after_0f[] = { /* 0x7B */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0x7C */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, /* 0x7D */ { 0, IT_UNKNOWN, AM_NOT_USED, AM_NOT_USED, AM_NOT_USED, 0, false, /* F2h */ { 0 }, /* F3h */ { 0 }, /* 66h */ { 0 } }, - + /* 0x7E */ { 0, IT_GENERIC, AM_E | OT_D, AM_P | OT_D, AM_NOT_USED, "movd", true, /* F2h */ { 0 }, /* F3h */ { 0, IT_GENERIC, AM_V | OT_Q, AM_W | OT_Q, AM_NOT_USED, "movq" }, @@ -1160,27 +1160,27 @@ const OpcodeTable MiniDisassembler::s_ia32_opcode_map_[]={ /* 1 */ {s_opcode_byte_after_0f, 0, 0xff, 0, 0xff}, // Start of tables for opcodes using ModR/M bits as extension /* 2 */ {s_opcode_byte_after_80, 3, 0x07, 0, 0x07}, - /* 3 */ {s_opcode_byte_after_81, 3, 0x07, 0, 0x07}, - /* 4 */ {s_opcode_byte_after_82, 3, 0x07, 0, 0x07}, - /* 5 */ {s_opcode_byte_after_83, 3, 0x07, 0, 0x07}, - /* 6 */ {s_opcode_byte_after_c0, 3, 0x07, 0, 0x07}, - /* 7 */ {s_opcode_byte_after_c1, 3, 0x07, 0, 0x07}, - /* 8 */ {s_opcode_byte_after_d0, 3, 0x07, 0, 0x07}, - /* 9 */ {s_opcode_byte_after_d1, 3, 0x07, 0, 0x07}, - /* 10 */ {s_opcode_byte_after_d2, 3, 0x07, 0, 0x07}, - /* 11 */ {s_opcode_byte_after_d3, 3, 0x07, 0, 0x07}, - /* 12 */ {s_opcode_byte_after_f6, 3, 0x07, 0, 0x07}, - /* 13 */ {s_opcode_byte_after_f7, 3, 0x07, 0, 0x07}, - /* 14 */ {s_opcode_byte_after_fe, 3, 0x07, 0, 0x01}, - /* 15 */ {s_opcode_byte_after_ff, 3, 0x07, 0, 0x07}, - /* 16 */ {s_opcode_byte_after_0f00, 3, 0x07, 0, 0x07}, - /* 17 */ {s_opcode_byte_after_0f01, 3, 0x07, 0, 0x07}, - /* 18 */ {s_opcode_byte_after_0f18, 3, 0x07, 0, 0x07}, - /* 19 */ {s_opcode_byte_after_0f71, 3, 0x07, 0, 0x07}, - /* 20 */ {s_opcode_byte_after_0f72, 3, 0x07, 0, 0x07}, - /* 21 */ {s_opcode_byte_after_0f73, 3, 0x07, 0, 0x07}, - /* 22 */ {s_opcode_byte_after_0fae, 3, 0x07, 0, 0x07}, - /* 23 */ {s_opcode_byte_after_0fba, 3, 0x07, 0, 0x07}, + /* 3 */ {s_opcode_byte_after_81, 3, 0x07, 0, 0x07}, + /* 4 */ {s_opcode_byte_after_82, 3, 0x07, 0, 0x07}, + /* 5 */ {s_opcode_byte_after_83, 3, 0x07, 0, 0x07}, + /* 6 */ {s_opcode_byte_after_c0, 3, 0x07, 0, 0x07}, + /* 7 */ {s_opcode_byte_after_c1, 3, 0x07, 0, 0x07}, + /* 8 */ {s_opcode_byte_after_d0, 3, 0x07, 0, 0x07}, + /* 9 */ {s_opcode_byte_after_d1, 3, 0x07, 0, 0x07}, + /* 10 */ {s_opcode_byte_after_d2, 3, 0x07, 0, 0x07}, + /* 11 */ {s_opcode_byte_after_d3, 3, 0x07, 0, 0x07}, + /* 12 */ {s_opcode_byte_after_f6, 3, 0x07, 0, 0x07}, + /* 13 */ {s_opcode_byte_after_f7, 3, 0x07, 0, 0x07}, + /* 14 */ {s_opcode_byte_after_fe, 3, 0x07, 0, 0x01}, + /* 15 */ {s_opcode_byte_after_ff, 3, 0x07, 0, 0x07}, + /* 16 */ {s_opcode_byte_after_0f00, 3, 0x07, 0, 0x07}, + /* 17 */ {s_opcode_byte_after_0f01, 3, 0x07, 0, 0x07}, + /* 18 */ {s_opcode_byte_after_0f18, 3, 0x07, 0, 0x07}, + /* 19 */ {s_opcode_byte_after_0f71, 3, 0x07, 0, 0x07}, + /* 20 */ {s_opcode_byte_after_0f72, 3, 0x07, 0, 0x07}, + /* 21 */ {s_opcode_byte_after_0f73, 3, 0x07, 0, 0x07}, + /* 22 */ {s_opcode_byte_after_0fae, 3, 0x07, 0, 0x07}, + /* 23 */ {s_opcode_byte_after_0fba, 3, 0x07, 0, 0x07}, /* 24 */ {s_opcode_byte_after_0fc7, 3, 0x07, 0, 0x01} }; diff --git a/tools/memory_watcher/memory_watcher.cc b/tools/memory_watcher/memory_watcher.cc index d5e11db..9b6e3ed 100644 --- a/tools/memory_watcher/memory_watcher.cc +++ b/tools/memory_watcher/memory_watcher.cc @@ -99,7 +99,7 @@ void MemoryWatcher::OnTrack(HANDLE heap, int32 id, int32 size) { AutoLock lock(block_map_lock_); - // Ideally, we'd like to verify that the block being added + // Ideally, we'd like to verify that the block being added // here is not already in our list of tracked blocks. However, // the lookup in our hash table is expensive and slows us too // much. Uncomment this line if you think you need it. @@ -175,7 +175,7 @@ void MemoryWatcher::OnUntrack(HANDLE heap, int32 id, int32 size) { void MemoryWatcher::SetLogName(char* log_name) { if (!log_name) return; - + log_name_ = log_name; } diff --git a/tools/memory_watcher/memory_watcher.h b/tools/memory_watcher/memory_watcher.h index f6281b5..d5a1d10 100644 --- a/tools/memory_watcher/memory_watcher.h +++ b/tools/memory_watcher/memory_watcher.h @@ -33,7 +33,7 @@ class MemoryWatcher : MemoryObserver { // MemoryObserver interface. virtual void OnTrack(HANDLE heap, int32 id, int32 size); virtual void OnUntrack(HANDLE heap, int32 id, int32 size); - + // Sets a name that appears in the generated file name. void SetLogName(char* log_name); diff --git a/tools/memory_watcher/mini_disassembler.cc b/tools/memory_watcher/mini_disassembler.cc index 6b1dec8..a5fcf54 100644 --- a/tools/memory_watcher/mini_disassembler.cc +++ b/tools/memory_watcher/mini_disassembler.cc @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -110,7 +110,7 @@ void MiniDisassembler::Initialize() { InstructionType MiniDisassembler::ProcessPrefixes(unsigned char* start_byte, unsigned int& size) { - InstructionType instruction_type = IT_GENERIC; + InstructionType instruction_type = IT_GENERIC; const Opcode& opcode = s_ia32_opcode_map_[0].table_[*start_byte]; switch (opcode.type_) { @@ -121,14 +121,14 @@ InstructionType MiniDisassembler::ProcessPrefixes(unsigned char* start_byte, operand_is_32_bits_ = !operand_default_is_32_bits_; nochangeoperand: case IT_PREFIX: - + if (0xF2 == (*start_byte)) got_f2_prefix_ = true; else if (0xF3 == (*start_byte)) got_f3_prefix_ = true; else if (0x66 == (*start_byte)) got_66_prefix_ = true; - + instruction_type = opcode.type_; size ++; // we got a prefix, so add one and check next byte @@ -146,7 +146,7 @@ InstructionType MiniDisassembler::ProcessOpcode(unsigned char* start_byte, const OpcodeTable& table = s_ia32_opcode_map_[table_index]; // Get our table unsigned char current_byte = (*start_byte) >> table.shift_; current_byte = current_byte & table.mask_; // Mask out the bits we will use - + // Check whether the byte we have is inside the table we have. if (current_byte < table.min_lim_ || current_byte > table.max_lim_) { instruction_type_ = IT_UNKNOWN; @@ -234,10 +234,10 @@ bool MiniDisassembler::ProcessOperand(int flag_operand) { case AM_F: // EFLAGS register case AM_X: // Memory addressed by the DS:SI register pair case AM_Y: // Memory addressed by the ES:DI register pair - case AM_IMPLICIT: // Parameter is implicit, occupies no space in + case AM_IMPLICIT: // Parameter is implicit, occupies no space in // instruction break; - + // There is a ModR/M byte but it does not necessarily need // to be decoded. case AM_C: // reg field of ModR/M selects a control register @@ -250,20 +250,20 @@ bool MiniDisassembler::ProcessOperand(int flag_operand) { case AM_V: // reg field of ModR/M selects a 128-bit XMM register have_modrm_ = true; break; - + // In these addressing modes, there is a ModR/M byte and it needs to be // decoded. No other (e.g. immediate) params than indicated in ModR/M. - case AM_E: // Operand is either a general-purpose register or memory, + case AM_E: // Operand is either a general-purpose register or memory, // specified by ModR/M byte case AM_M: // ModR/M byte will refer only to memory - case AM_Q: // Operand is either an MMX register or memory (complex + case AM_Q: // Operand is either an MMX register or memory (complex // evaluation), specified by ModR/M byte - case AM_W: // Operand is either a 128-bit XMM register or memory (complex + case AM_W: // Operand is either a 128-bit XMM register or memory (complex // eval), specified by ModR/M byte have_modrm_ = true; should_decode_modrm_ = true; break; - + // These addressing modes specify an immediate or an offset value // directly, so we need to look at the operand type to see how many // bytes. @@ -286,7 +286,7 @@ bool MiniDisassembler::ProcessOperand(int flag_operand) { case OT_DQ: // Double-quadword, regardless of operand-size attribute. operand_bytes_ += OS_DOUBLE_QUAD_WORD; break; - case OT_P: // 32-bit or 48-bit pointer, depending on operand-size + case OT_P: // 32-bit or 48-bit pointer, depending on operand-size // attribute. if (operand_is_32_bits_) operand_bytes_ += OS_48_BIT_POINTER; @@ -307,9 +307,9 @@ bool MiniDisassembler::ProcessOperand(int flag_operand) { operand_bytes_ += OS_DOUBLE_PRECISION_FLOATING; break; case OT_SS: - // Scalar element of a 128-bit packed single-precision + // Scalar element of a 128-bit packed single-precision // floating data. - // We simply return enItUnknown since we don't have to support + // We simply return enItUnknown since we don't have to support // floating point succeeded = false; break; @@ -322,19 +322,19 @@ bool MiniDisassembler::ProcessOperand(int flag_operand) { case OT_W: // Word, regardless of operand-size attribute. operand_bytes_ += OS_WORD; break; - + // Can safely ignore these. - case OT_A: // Two one-word operands in memory or two double-word + case OT_A: // Two one-word operands in memory or two double-word // operands in memory case OT_PI: // Quadword MMX technology register (e.g. mm0) case OT_SI: // Doubleword integer register (e.g., eax) break; - + default: break; } break; - + default: break; } @@ -342,7 +342,7 @@ bool MiniDisassembler::ProcessOperand(int flag_operand) { return succeeded; } -bool MiniDisassembler::ProcessModrm(unsigned char* start_byte, +bool MiniDisassembler::ProcessModrm(unsigned char* start_byte, unsigned int& size) { // If we don't need to decode, we just return the size of the ModR/M // byte (there is never a SIB byte in this case). @@ -372,7 +372,7 @@ bool MiniDisassembler::ProcessModrm(unsigned char* start_byte, // Invariant: modrm_entry points to information that we need to decode // the ModR/M byte. - + // Add to the count of operand bytes, if the ModR/M byte indicates // that some operands are encoded in the instruction. if (modrm_entry->is_encoded_in_instruction_) @@ -389,8 +389,8 @@ bool MiniDisassembler::ProcessModrm(unsigned char* start_byte, } } -bool MiniDisassembler::ProcessSib(unsigned char* start_byte, - unsigned char mod, +bool MiniDisassembler::ProcessSib(unsigned char* start_byte, + unsigned char mod, unsigned int& size) { // get the mod field from the 2..0 bits of the SIB byte unsigned char sib_base = (*start_byte) & 0x07; diff --git a/tools/memory_watcher/mini_disassembler.h b/tools/memory_watcher/mini_disassembler.h index 8af2c42..1a75c54 100644 --- a/tools/memory_watcher/mini_disassembler.h +++ b/tools/memory_watcher/mini_disassembler.h @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -51,8 +51,8 @@ namespace sidestep { // // The limitations include at least the following: // -# No support for coprocessor opcodes, MMX, etc. -// -# No machine-readable identification of opcodes or decoding of -// assembly parameters. The name of the opcode (as a string) is given, +// -# No machine-readable identification of opcodes or decoding of +// assembly parameters. The name of the opcode (as a string) is given, // however, to aid debugging. // // You may ask what this little disassembler actually does, then? The answer is @@ -115,8 +115,8 @@ class MiniDisassembler { // Sets the flag for whether we have ModR/M, and increments // operand_bytes_ if any are specifies by the opcode directly. // @return Number of opcode bytes. - InstructionType ProcessOpcode(unsigned char * start, - unsigned int table, + InstructionType ProcessOpcode(unsigned char * start, + unsigned int table, unsigned int& size); // Checks the type of the supplied operand. Increments diff --git a/tools/memory_watcher/mini_disassembler_types.h b/tools/memory_watcher/mini_disassembler_types.h index 3abc85d..d4fef2a 100644 --- a/tools/memory_watcher/mini_disassembler_types.h +++ b/tools/memory_watcher/mini_disassembler_types.h @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -81,7 +81,7 @@ enum OperandSize { // is a mask for the rest. The other enumeration values are named for the // names given to the addressing methods in the manual, e.g. enAm_D is for // the D addressing method. -// +// // The reason we use a full 4 bytes and a mask, is that we need to combine // these flags with the enOperandType to store the details // on the operand in a single integer. @@ -137,7 +137,7 @@ enum OperandType { OT_W = 0x0E000000, OT_SD = 0x0F000000, // scalar double-precision floating-point value OT_PD = 0x10000000, // double-precision floating point - // dummy "operand type" for address mode M - which doesn't specify + // dummy "operand type" for address mode M - which doesn't specify // operand type OT_ADDRESS_MODE_M = 0x80000000 }; @@ -147,7 +147,7 @@ enum OperandType { struct SpecificOpcode { // Index to continuation table, or 0 if this is the last // byte in the opcode. - int table_index_; + int table_index_; // The opcode type InstructionType type_; @@ -168,7 +168,7 @@ struct SpecificOpcode { struct Opcode { // Index to continuation table, or 0 if this is the last // byte in the opcode. - int table_index_; + int table_index_; // The opcode type InstructionType type_; diff --git a/tools/memory_watcher/preamble_patcher.cc b/tools/memory_watcher/preamble_patcher.cc index 2beb555..78dbc7e 100644 --- a/tools/memory_watcher/preamble_patcher.cc +++ b/tools/memory_watcher/preamble_patcher.cc @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -64,9 +64,9 @@ SideStepError PreamblePatcher::RawPatchWithStubAndProtections( return SIDESTEP_ACCESS_DENIED; } - SideStepError error_code = RawPatchWithStub(target_function, - replacement_function, - preamble_stub, + SideStepError error_code = RawPatchWithStub(target_function, + replacement_function, + preamble_stub, stub_size, bytes_needed); if (SIDESTEP_SUCCESS != error_code) { @@ -76,9 +76,9 @@ SideStepError PreamblePatcher::RawPatchWithStubAndProtections( // Restore the protection of the first MAX_PREAMBLE_STUB_SIZE bytes of // pTargetFunction to what they were before we started goofing around. - succeeded = ::VirtualProtect(reinterpret_cast<void*>(target_function), - MAX_PREAMBLE_STUB_SIZE, - old_target_function_protect, + succeeded = ::VirtualProtect(reinterpret_cast<void*>(target_function), + MAX_PREAMBLE_STUB_SIZE, + old_target_function_protect, &old_target_function_protect); if (!succeeded) { ASSERT(false, "Failed to restore protection to target function."); @@ -94,8 +94,8 @@ SideStepError PreamblePatcher::RawPatchWithStubAndProtections( // XP machines. I'm not sure why this is so, but it is, yet I want to keep the // call to the API here for correctness in case there is a difference in // some variants of Windows/hardware. - succeeded = ::FlushInstructionCache(::GetCurrentProcess(), - target_function, + succeeded = ::FlushInstructionCache(::GetCurrentProcess(), + target_function, MAX_PREAMBLE_STUB_SIZE); if (!succeeded) { ASSERT(false, "Failed to flush instruction cache."); @@ -116,9 +116,9 @@ SideStepError PreamblePatcher::RawPatch(void* target_function, return SIDESTEP_INVALID_PARAMETER; } - // @see MAX_PREAMBLE_STUB_SIZE for an explanation of how we arrives at + // @see MAX_PREAMBLE_STUB_SIZE for an explanation of how we arrives at // this size - unsigned char* preamble_stub = + unsigned char* preamble_stub = reinterpret_cast<unsigned char*>( MemoryHook::Alloc(sizeof(unsigned char) * MAX_PREAMBLE_STUB_SIZE)); if (!preamble_stub) { @@ -139,9 +139,9 @@ SideStepError PreamblePatcher::RawPatch(void* target_function, return SIDESTEP_ACCESS_DENIED; } - SideStepError error_code = RawPatchWithStubAndProtections(target_function, - replacement_function, - preamble_stub, + SideStepError error_code = RawPatchWithStubAndProtections(target_function, + replacement_function, + preamble_stub, MAX_PREAMBLE_STUB_SIZE, NULL); if (SIDESTEP_SUCCESS != error_code) { @@ -149,14 +149,14 @@ SideStepError PreamblePatcher::RawPatch(void* target_function, delete[] preamble_stub; return error_code; } - + *original_function_stub = reinterpret_cast<void*>(preamble_stub); - // NOTE: For hooking malloc/free, we don't want to use streams which - // allocate. Basically, we've hooked malloc, but not necessarily + // NOTE: For hooking malloc/free, we don't want to use streams which + // allocate. Basically, we've hooked malloc, but not necessarily // hooked free yet. To do anything which uses the heap could crash // with a mismatched malloc/free! - //LOG(INFO) << "PreamblePatcher::RawPatch successfully patched 0x" << + //LOG(INFO) << "PreamblePatcher::RawPatch successfully patched 0x" << // target_function; return SIDESTEP_SUCCESS; @@ -175,7 +175,7 @@ SideStepError PreamblePatcher::Unpatch(void* target_function, MiniDisassembler disassembler; unsigned int preamble_bytes = 0; while (preamble_bytes < 5) { - InstructionType instruction_type = + InstructionType instruction_type = disassembler.Disassemble( reinterpret_cast<unsigned char*>(original_function_stub) + preamble_bytes, preamble_bytes); @@ -234,17 +234,17 @@ SideStepError PreamblePatcher::Unpatch(void* target_function, // Restore the protection of the first MAX_PREAMBLE_STUB_SIZE bytes of // target to what they were before we started goofing around. - succeeded = ::VirtualProtect(reinterpret_cast<void*>(target), - MAX_PREAMBLE_STUB_SIZE, - old_target_function_protect, + succeeded = ::VirtualProtect(reinterpret_cast<void*>(target), + MAX_PREAMBLE_STUB_SIZE, + old_target_function_protect, &old_target_function_protect); // Flush the instruction cache to make sure the processor doesn't execute the // old version of the instructions (before our patch). // // See comment on FlushInstructionCache elsewhere in this file. - succeeded = ::FlushInstructionCache(::GetCurrentProcess(), - target, + succeeded = ::FlushInstructionCache(::GetCurrentProcess(), + target, MAX_PREAMBLE_STUB_SIZE); if (!succeeded) { ASSERT(false, "Failed to flush instruction cache."); diff --git a/tools/memory_watcher/preamble_patcher.h b/tools/memory_watcher/preamble_patcher.h index eafe88a..ccacb72 100644 --- a/tools/memory_watcher/preamble_patcher.h +++ b/tools/memory_watcher/preamble_patcher.h @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR @@ -46,7 +46,7 @@ // bytes of the function. Considering the worst case scenario, we need 4 // bytes + the max instruction size + 5 more bytes for our jump back to // the original code. With that in mind, 32 is a good number :) -#define MAX_PREAMBLE_STUB_SIZE (32) +#define MAX_PREAMBLE_STUB_SIZE (32) namespace sidestep { @@ -77,28 +77,28 @@ enum SideStepError { // See the TODO in preamble_patcher_with_stub.cc for instructions on what // we need to do before using it in production code; it's fairly simple // but unnecessary for now since we only intend to use it in unit tests. -// +// // To patch a function, use either of the typesafe Patch() methods. You // can unpatch a function using Unpatch(). -// +// // Typical usage goes something like this: // @code // typedef int (*MyTypesafeFuncPtr)(int x); // MyTypesafeFuncPtr original_func_stub; // int MyTypesafeFunc(int x) { return x + 1; } // int HookMyTypesafeFunc(int x) { return 1 + original_func_stub(x); } -// +// // void MyPatchInitializingFunction() { // original_func_stub = PreamblePatcher::Patch( // MyTypesafeFunc, HookMyTypesafeFunc); // if (!original_func_stub) { // // ... error handling ... // } -// +// // // ... continue - you have patched the function successfully ... // } // @endcode -// +// // Note that there are a number of ways that this method of patching can // fail. The most common are: // - If there is a jump (jxx) instruction in the first 5 bytes of @@ -113,7 +113,7 @@ enum SideStepError { // - If there is another thread currently executing within the bytes // that are copied to the preamble stub, it will crash in an undefined // way. -// +// // If you get any other error than the above, you're either pointing the // patcher at an invalid instruction (e.g. into the middle of a multi- // byte instruction, or not at memory containing executable instructions) @@ -286,9 +286,9 @@ class PreamblePatcher { // exactly the same calling convention and parameters as the original // function. // - // @param preamble_stub A pointer to a buffer where the preamble stub + // @param preamble_stub A pointer to a buffer where the preamble stub // should be copied. The size of the buffer should be sufficient to - // hold the preamble bytes. + // hold the preamble bytes. // // @param stub_size Size in bytes of the buffer allocated for the // preamble_stub @@ -298,19 +298,19 @@ class PreamblePatcher { // not interested. // // @return An error code indicating the result of patching. - static SideStepError RawPatchWithStubAndProtections(void* target_function, - void *replacement_function, - unsigned char* preamble_stub, - unsigned long stub_size, + static SideStepError RawPatchWithStubAndProtections(void* target_function, + void *replacement_function, + unsigned char* preamble_stub, + unsigned long stub_size, unsigned long* bytes_needed); // A helper function used by RawPatchWithStubAndProtections -- it does // everything but the VirtualProtect wsork. Defined in // preamble_patcher_with_stub.cc. - static SideStepError RawPatchWithStub(void* target_function, - void *replacement_function, - unsigned char* preamble_stub, - unsigned long stub_size, + static SideStepError RawPatchWithStub(void* target_function, + void *replacement_function, + unsigned char* preamble_stub, + unsigned long stub_size, unsigned long* bytes_needed); }; diff --git a/tools/memory_watcher/preamble_patcher_with_stub.cc b/tools/memory_watcher/preamble_patcher_with_stub.cc index d2ce6af..dc38872 100644 --- a/tools/memory_watcher/preamble_patcher_with_stub.cc +++ b/tools/memory_watcher/preamble_patcher_with_stub.cc @@ -1,10 +1,10 @@ /* Copyright (c) 2007, Google Inc. * All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: - * + * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above @@ -14,7 +14,7 @@ * * Neither the name of Google Inc. nor the names of its * contributors may be used to endorse or promote products derived from * this software without specific prior written permission. - * + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |