How to use byte method of x86 Package

Best Syzkaller code snippet using x86.byte

cpu_x86.go

Source:cpu_x86.go Github

copy

Full Screen

...106func Name() string {107 if maxExtendedFunctionInformation < 0x80000004 {108 return ""109 }110 data := make([]byte, 0, 3*4*4)111 var eax, ebx, ecx, edx uint32112 eax, ebx, ecx, edx = cpuid(0x80000002, 0)113 data = appendBytes(data, eax, ebx, ecx, edx)114 eax, ebx, ecx, edx = cpuid(0x80000003, 0)115 data = appendBytes(data, eax, ebx, ecx, edx)116 eax, ebx, ecx, edx = cpuid(0x80000004, 0)117 data = appendBytes(data, eax, ebx, ecx, edx)118 // Trim leading spaces.119 for len(data) > 0 && data[0] == ' ' {120 data = data[1:]121 }122 // Trim tail after and including the first null byte.123 for i, c := range data {124 if c == '\x00' {125 data = data[:i]126 break127 }128 }129 return string(data)130}131func appendBytes(b []byte, args ...uint32) []byte {132 for _, arg := range args {133 b = append(b,134 byte((arg >> 0)),135 byte((arg >> 8)),136 byte((arg >> 16)),137 byte((arg >> 24)))138 }139 return b140}...

Full Screen

Full Screen

assembler.go

Source:assembler.go Github

copy

Full Screen

...7 "turtlego/src/pcode"8)9// Functions that will create code for different instruction sets.10// Returns code, data, and patches11type AssemblerFn func(pcode.Instruction) ([]byte, []byte, []backpatch.BackPatch)12type Assembler struct {13 outputFile string14 code []byte15 data []byte16 pcodeAddressToRealAddress map[int]int17 backPatches []backpatch.BackPatch18 output []byte19 pcodeX86map map[byte]AssemblerFn20 exitFnsMap map[byte]func() []byte21 pcode *pcode.Program22}23const (24 X86_64 byte = iota25)26func NewAssembler(pc *pcode.Program) *Assembler {27 a := &Assembler{}28 a.pcode = pc29 a.code = []byte{}30 a.data = []byte{}31 a.output = []byte{}32 a.pcodeAddressToRealAddress = make(map[int]int)33 a.pcodeX86map = map[byte]AssemblerFn{34 pcode.LOADINT: x86_64.MovRegImm,35 pcode.MOV_REG_REG: x86_64.MovRegReg,36 pcode.MOV_REG_ADDRESS_REG: x86_64.MovRegInAddrFromReg,37 pcode.MOV_REG_REG_ADDRESS: x86_64.MovRegFromRegInAddr,38 pcode.ADD_REG_INT_INT: x86_64.AddImmReg,39 pcode.ADD_REG_REG_INT: x86_64.AddRegReg,40 pcode.SUB_REG_INT_INT: x86_64.SubImmReg,41 pcode.SUB_REG_REG_INT: x86_64.SubRegReg,42 pcode.MUL_REG_INT_INT: x86_64.MulImmReg,43 pcode.PUSH_REG: x86_64.PushReg,44 pcode.POP: x86_64.PopReg,45 pcode.BUILTIN_CALL: x86_64.Builtin,46 pcode.PUSH_INT: x86_64.PushInt,47 pcode.CMP_REG_INT: x86_64.CmpRegInt,48 pcode.JMP: x86_64.Jump,49 pcode.JNZ: x86_64.JumpIfNotZero,50 pcode.JMZ: x86_64.JumpIfZero,51 pcode.NOP: x86_64.Nop,52 pcode.MUL_REG_REG_INT: x86_64.MulRegReg,53 pcode.DIV_REG_REG_INT: x86_64.DivRegReg,54 pcode.DIV_REG_INT_INT: x86_64.DivImmReg,55 pcode.BOOL_OR_REG_IMM: x86_64.OrRegImm,56 pcode.BOOL_OR_REG_REG: x86_64.OrRegReg,57 pcode.BOOL_AND_REG_REG: x86_64.AndRegReg,58 pcode.BOOL_AND_REG_IMM: x86_64.AndRegImm,59 //These functions are all generated using a higher-order function60 //The function that creates these functions returns a compatiable61 //type with AssemblerFn, but it must be converted here to be in the map62 pcode.EQ_REG_REG: AssemblerFn(x86_64.EqRegReg),63 pcode.EQ_REG_IMM: AssemblerFn(x86_64.EqRegImm),64 pcode.NE_REG_IMM: AssemblerFn(x86_64.NeRegImm),65 pcode.NE_REG_REG: AssemblerFn(x86_64.NeRegReg),66 pcode.LT_REG_IMM: AssemblerFn(x86_64.LtRegImm),67 pcode.LT_REG_REG: AssemblerFn(x86_64.LtRegReg),68 pcode.LE_REG_IMM: AssemblerFn(x86_64.LeRegImm),69 pcode.LE_REG_REG: AssemblerFn(x86_64.LeRegReg),70 pcode.GE_REG_IMM: AssemblerFn(x86_64.GeRegImm),71 pcode.GE_REG_REG: AssemblerFn(x86_64.GeRegReg),72 pcode.GT_REG_IMM: AssemblerFn(x86_64.GtRegImm),73 pcode.GT_REG_REG: AssemblerFn(x86_64.GtRegReg),74 pcode.MK_HEAP: x86_64.MkHeap,75 pcode.ALLOC: x86_64.Alloc,76 }77 a.exitFnsMap = map[byte]func() []byte{78 X86_64: x86_64.ExitX86,79 }80 return a81}82func (a *Assembler) Assemble(instructionSet byte) {83 for pcodeAddress, instruction := range a.pcode.Instructions {84 fn, ok := a.pcodeX86map[instruction.Opcode] //TODO: Expand for other architectures85 if !ok {86 a.raiseError("Generation", "x86 code generation at: "+pcode.InstructionMnemonicMap[instruction.Opcode])87 }88 newCode, newData, backpatches := fn(*instruction)89 a.pcodeAddressToRealAddress[pcodeAddress] = len(a.code)90 //fmt.Printf("%d %x\n", pcodeAddress, 0x400000+len(a.code)+0x40+(2*0x38))91 for _, patch := range backpatches {92 patch.LocationOfAddressToPatch += len(a.code)93 patch.LocationOfInstructionPatched += len(a.code)94 a.backPatches = append(a.backPatches, patch)95 }96 a.code = append(a.code, newCode...)...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful