(self, arch, mode)
| 910 | # update Encoding control |
| 911 | # return True on success, False on failure |
| 912 | def _update_encoding(self, arch, mode): |
| 913 | try: |
| 914 | syntax = None |
| 915 | if arch == KS_ARCH_X86: |
| 916 | syntax_id = self.GetControlValue(self.c_syntax) |
| 917 | syntax = self.kp_asm.get_syntax_by_idx(syntax_id) |
| 918 | |
| 919 | address = self.GetControlValue(self.c_addr) |
| 920 | try: |
| 921 | idaapi.isEnabled(address) |
| 922 | except: |
| 923 | # invalid address value |
| 924 | address = 0 |
| 925 | |
| 926 | assembly = self.GetControlValue(self.c_assembly) |
| 927 | raw_assembly = self.kp_asm.ida_resolve(assembly, address) |
| 928 | self.SetControlValue(self.c_raw_assembly, raw_assembly) |
| 929 | |
| 930 | (encoding, count) = self.kp_asm.assemble(raw_assembly, address, arch=arch, |
| 931 | mode=mode, syntax=syntax) |
| 932 | |
| 933 | if encoding is None: |
| 934 | self.SetControlValue(self.c_encoding, ENCODING_ERR_OUTPUT) |
| 935 | self.SetControlValue(self.c_encoding_len, 0) |
| 936 | return False |
| 937 | else: |
| 938 | text = "" |
| 939 | for byte in encoding: |
| 940 | text += "%02X " % byte |
| 941 | text.strip() |
| 942 | if text == "": |
| 943 | # error? |
| 944 | self.SetControlValue(self.c_encoding, ENCODING_ERR_OUTPUT) |
| 945 | return False |
| 946 | else: |
| 947 | self.SetControlValue(self.c_encoding, text.strip()) |
| 948 | self.SetControlValue(self.c_encoding_len, len(encoding)) |
| 949 | return True |
| 950 | except Exception,e: |
| 951 | print (str(e)) |
| 952 | import traceback |
| 953 | traceback.print_exc() |
| 954 | self.SetControlValue(self.c_encoding, ENCODING_ERR_OUTPUT) |
| 955 | return False |
| 956 | |
| 957 | # callback to be executed when any form control changed |
| 958 | def OnFormChange(self, fid): |
no test coverage detected