Example #1
0
    def invoke(self, arg, from_tty):
        args = UdkCommandHelper.checkParameterEx(arg, 0, 2)
        if args == None:
            return

        if len(args) < 2:
            subindex = 0
        else:
            try:
                subindex = int(args[1], 16)
            except:
                print(ARGUMENT_INVALID_SUBINDEX)
                return
        if len(args) < 1:
            index = 1
        else:
            try:
                index = int(args[0], 16)
            except:
                print(ARGUMENT_INVALID_INDEX)
                return
        response = UdkCommandHelper.sendUdkExtensionPacket("cpuid,%08x,%08x" %
                                                           (index, subindex))
        try:
            print(CPUID_INPUT % (index, subindex))
            (eax, ebx, ecx, edx) = [int(v, 16) for v in response.split(",")]
            print(CPUID_OUTPUT % (eax, ebx, ecx, edx))
        except Exception:
            print(FAILED_TO_EXECUTE_COMMAND % response)
Example #2
0
 def invoke(self, arg, from_tty):
     args = UdkCommandHelper.checkParameterEx(arg, 0, 1)
     if args != None:
         self.dont_repeat()
         if len(args) == 0:
             cur = gdb.selected_frame().pc()
         else:
             try:
                 cur = int(args[0], 16)
             except:
                 print(ARGUMENT_HEX_EXPECTED)
                 return
         print(LOADING_SYMBOL % cur)
         self._imageloader.loadsymbol(cur, True)
Example #3
0
    def invoke(self, arg, from_tty):
        self.dont_repeat()
        args = list(
            map(str.lower,
                UdkCommandHelper.checkParameterEx(arg, 0, 0xffffffff)))
        if args == None:
            return

        print("ENTRY\tBASE\tNAME")
        print("====================================")
        for (image_entry, image_base, image_name) in self._query():
            if len(args) == 0 or image_name.lower() in args:
                print("%s\t%s\t%s" % (image_entry, image_base, image_name))
        print("")
Example #4
0
 def invoke(self, arg, from_tty):
     args = UdkCommandHelper.checkParameterEx(arg, 1, 2)
     if args != None:
         if len(args) == 1:
             index = int(args[0], 16)
             value = UdkExtension.ReadMsr(index)
             if value == None:
                 print(FAILED_TO_EXECUTE_COMMAND % response)
             else:
                 print("%016x" % value)
         else:
             index = int(args[0], 16)
             value = int(args[1], 16)
             if not UdkExtension.WriteMsr(index, value):
                 print(FAILED_TO_EXECUTE_COMMAND % response)
Example #5
0
    def invoke(self, arg, from_tty):
        args = UdkCommandHelper.checkParameterEx(arg, 2, 3)
        if args == None:
            return

        try:
            (port, size) = self.parse_port(args)
        except:
            return

        if len(args) == 2:
            value = UdkExtension.ReadIo(port, size)
            print("%0*x" % (size * 2, value))
        else:
            value = int(args[2], 16)
            if not UdkExtension.WriteIo(port, size, value):
                print(FAILED_TO_EXECUTE_COMMAND % response)
Example #6
0
    def list(self, arg):
        args = UdkCommandHelper.checkParameterEx(arg, 0, 1)
        if args == None:
            return

        if len(args) == 1:
            try:
                args[0] = int(args[0], 10)
            except:
                args[0] = 0

            if args[0] == 0:
                print(ARGUMENT_MUST_BE_NUMBER_1_BASED)
                return

        print("Num\tPort\tSize")
        for index, (port, size) in list(self._watchpoints.items()):
            if len(args) == 0 or args[0] == index:
                print("%d\t0x%x\t%d" % (index, port, size))
Example #7
0
    def delete(self, arg):
        args = UdkCommandHelper.checkParameterEx(arg, 0, 1)
        if args == None:
            return

        if len(args) == 1:
            try:
                args[0] = int(args[0], 10)
            except:
                args[0] = 0

            if args[0] == 0:
                print(ARGUMENT_MUST_BE_NUMBER_1_BASED)
                return

        for index, (port, size) in list(self._watchpoints.items()):
            if len(args) == 0 or args[0] == index:
                response = UdkCommandHelper.sendUdkExtensionPacket(
                    "z5,%x,%x" % (port, size))
                if response != "OK":
                    print(FAILED_TO_EXECUTE_COMMAND % response)
                else:
                    del self._watchpoints[index]
Example #8
0
    def invoke(self, arg, from_tty):
        self.dont_repeat()
        args = UdkCommandHelper.checkParameterEx(arg, 1, 0xffffffff)
        if args == None:
            return

        Help = False
        Time = False
        if args[0] == '/h':
            Help = True
            del args[0]
        elif args[0] == '/t':
            Time = True
            del args[0]

        if '.' in args[0]:
            (module, function) = args[0].split('.')
        else:
            (module, function) = (args[0], "invoke")
        module = self._import(module)
        try:
            function = module.__dict__[function]
        except:
            print(FAILED_TO_LOCATE_FUNCTION % (function, module.__name__))
            return

        if Help:
            print(function.__doc__)
            return
        else:
            Start = datetime.datetime.now()
            try:
                function(" ".join(args[1:]))
            except:
                traceback.print_exc()
            if Time:
                print(EXECUTION_TIME % (str(datetime.datetime.now() - Start)))