Skip to content

Errata: function rScan pseudocode implementation #18

@snowman

Description

@snowman

In "Chapter 1, Listing 1-1 pseudocode"

   list<int> pointerScan(target, maxAdd, maxDepth) {
➊    for address = BASE, 0x7FFFFFF, 4 {
           ret = rScan(address, target, maxAdd, maxDepth, 1)
           if (ret.len > 0) {
               ret.pushFront(address)
               return ret
           }
      }
      return {}
   }
   list<int> rScan(address, target, maxAdd, maxDepth, curDepth) {
➋      for offset = 0, maxAdd, 4 {
            value = read(address + offset)
➌          if (value == target)
                return list<int>(offset)
        }
➍      if (curDepth < maxDepth) {
            curDepth++for offset = 0, maxAdd, 4 {
                ret = rScan(address + offset, target, maxAdd, maxDepth, curDepth)
➏              if (ret.len > 0) {
                    ret.pushFront(offset)
➐                  return ret
                }
            }
        }
        return {}
   }

In the middle of line 5 and 6, shouldn't the line correct to
ret = rScan(read(address + offset), target, maxAdd, maxDepth, curDepth) by replacing address + offset into read(address + offset)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions