diff --git a/bddisasm/bddisasm.c b/bddisasm/bddisasm.c index 24e9fc5..e1f73df 100644 --- a/bddisasm/bddisasm.c +++ b/bddisasm/bddisasm.c @@ -2086,7 +2086,7 @@ NdParseOperand( operand->Type = ND_OP_REG; operand->Info.Register.Type = ND_REG_MSR; operand->Info.Register.Size = ND_SIZE_64BIT; - operand->Info.Register.Reg = NDR_IA32_GS_BASE; + operand->Info.Register.Reg = NDR_IA32_KERNEL_GS_BASE; break; case ND_OPT_XCR: @@ -2135,8 +2135,6 @@ NdParseOperand( operand->Type = ND_OP_ADDR; operand->Info.Address.BaseSeg = Instrux->Address.Cs; operand->Info.Address.Offset = Instrux->Address.Ip; - - Offset = Instrux->Length; break; case ND_OPT_B: @@ -2367,8 +2365,6 @@ NdParseOperand( { operand->Info.Immediate.Imm = imm; } - - Offset = Instrux->Length; } break; @@ -2396,8 +2392,6 @@ NdParseOperand( operand->Size = Instrux->WordLength; operand->Info.RelativeOffset.Rel = ND_SIGN_EX(size, Instrux->RelativeOffset); - Offset = Instrux->Length; - break; case ND_OPT_N: @@ -2457,8 +2451,6 @@ NdParseOperand( operand->Info.Memory.Disp = Instrux->Moffset; operand->Info.Memory.HasSeg = true; operand->Info.Memory.Seg = NdGetSegOverride(Instrux, NDR_DS); - - Offset = Instrux->Length; } break; @@ -2784,7 +2776,6 @@ memory: operand->Info.Register.Reg &= 0x7; } - Offset = Instrux->Length; break; case ND_OPT_U: @@ -4662,6 +4653,11 @@ NdToText( return ND_STATUS_INVALID_INSTRUX; } + if (!ND_SUCCESS(status)) + { + return status; + } + res = nd_strcat_s(Buffer, BufferSize, temp); RET_EQ(res, NULL, ND_STATUS_BUFFER_OVERFLOW); } diff --git a/bddisasm_test/basic/branch_32.result b/bddisasm_test/basic/branch_32.result index 8c22e58..df8a93e 100644 --- a/bddisasm_test/basic/branch_32.result +++ b/bddisasm_test/basic/branch_32.result @@ -799,9 +799,9 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 372, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 373, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 374, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000174, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000175, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000176, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 2, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 4, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 1, RegCount: 1 diff --git a/bddisasm_test/basic/branch_64.result b/bddisasm_test/basic/branch_64.result index 23beb59..6aa86c6 100644 --- a/bddisasm_test/basic/branch_64.result +++ b/bddisasm_test/basic/branch_64.result @@ -579,9 +579,9 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741694, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741692, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000082, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000084, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Segment, RegSize: 8, RegId: 2, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 diff --git a/bddisasm_test/basic/misc_64.result b/bddisasm_test/basic/misc_64.result index e8b9b1c..c59ecec 100644 --- a/bddisasm_test/basic/misc_64.result +++ b/bddisasm_test/basic/misc_64.result @@ -708,7 +708,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741568, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000100, RegCount: 1 000000000000007A f3480faec0 RDFSBASE rax DSIZE: 64, ASIZE: 64, VLEN: - @@ -724,7 +724,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: M, RegType: General Purpose, RegSize: 8, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741568, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000100, RegCount: 1 000000000000007F f30faec8 RDGSBASE eax DSIZE: 32, ASIZE: 64, VLEN: - @@ -740,7 +740,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 0000000000000083 f3480faec8 RDGSBASE rax DSIZE: 64, ASIZE: 64, VLEN: - @@ -756,7 +756,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: M, RegType: General Purpose, RegSize: 8, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 0000000000000088 f30faed0 WRFSBASE eax DSIZE: 32, ASIZE: 64, VLEN: - @@ -772,7 +772,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741568, RegCount: 1 + Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000100, RegCount: 1 000000000000008C f3480faed0 WRFSBASE rax DSIZE: 64, ASIZE: 64, VLEN: - @@ -788,7 +788,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: M, RegType: General Purpose, RegSize: 8, RegId: 0, RegCount: 1 - Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741568, RegCount: 1 + Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000100, RegCount: 1 0000000000000091 f30faed8 WRGSBASE eax DSIZE: 32, ASIZE: 64, VLEN: - @@ -804,7 +804,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 0000000000000095 f3480faed8 WRGSBASE rax DSIZE: 64, ASIZE: 64, VLEN: - @@ -820,7 +820,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: M, RegType: General Purpose, RegSize: 8, RegId: 0, RegCount: 1 - Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 000000000000009A 660f38f003 MOVBE ax, word ptr [rbx] DSIZE: 16, ASIZE: 64, VLEN: - diff --git a/bddisasm_test/basic/system_16.result b/bddisasm_test/basic/system_16.result index 4064338..7afe77c 100644 --- a/bddisasm_test/basic/system_16.result +++ b/bddisasm_test/basic/system_16.result @@ -320,7 +320,7 @@ Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: -1, RegCount: 1 + Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: 0xffffffff, RegCount: 1 000000000000003E 0f30 WRMSR DSIZE: 16, ASIZE: 16, VLEN: - @@ -338,7 +338,7 @@ Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: -1, RegCount: 1 + Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: 0xffffffff, RegCount: 1 0000000000000040 0f31 RDTSC DSIZE: 16, ASIZE: 16, VLEN: - @@ -354,7 +354,7 @@ BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 16, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000010, RegCount: 1 0000000000000042 0f01f9 RDTSCP DSIZE: 16, ASIZE: 16, VLEN: - @@ -372,8 +372,8 @@ Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 16, RegCount: 1 - Operand: 4, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741565, RegCount: 1 + Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000010, RegCount: 1 + Operand: 4, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000103, RegCount: 1 0000000000000045 0f00e8 VERW ax DSIZE: 16, ASIZE: 16, VLEN: - diff --git a/bddisasm_test/basic/system_32.result b/bddisasm_test/basic/system_32.result index d4cab18..9762753 100644 --- a/bddisasm_test/basic/system_32.result +++ b/bddisasm_test/basic/system_32.result @@ -320,7 +320,7 @@ Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: -1, RegCount: 1 + Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: 0xffffffff, RegCount: 1 000000000000003F 0f30 WRMSR DSIZE: 32, ASIZE: 32, VLEN: - @@ -338,7 +338,7 @@ Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: -1, RegCount: 1 + Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: 0xffffffff, RegCount: 1 0000000000000041 0f31 RDTSC DSIZE: 32, ASIZE: 32, VLEN: - @@ -354,7 +354,7 @@ BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 16, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000010, RegCount: 1 0000000000000043 0f01f9 RDTSCP DSIZE: 32, ASIZE: 32, VLEN: - @@ -372,8 +372,8 @@ Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 16, RegCount: 1 - Operand: 4, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741565, RegCount: 1 + Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000010, RegCount: 1 + Operand: 4, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000103, RegCount: 1 0000000000000046 0f00e8 VERW ax DSIZE: 32, ASIZE: 32, VLEN: - diff --git a/bddisasm_test/basic/system_64.result b/bddisasm_test/basic/system_64.result index 1b4d254..550cf02 100644 --- a/bddisasm_test/basic/system_64.result +++ b/bddisasm_test/basic/system_64.result @@ -350,7 +350,7 @@ Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: -1, RegCount: 1 + Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: 0xffffffff, RegCount: 1 000000000000004C 0f30 WRMSR DSIZE: 32, ASIZE: 64, VLEN: - @@ -368,7 +368,7 @@ Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: -1, RegCount: 1 + Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: E, RegType: Model Specific, RegSize: 8, RegId: 0xffffffff, RegCount: 1 000000000000004E 0f31 RDTSC DSIZE: 32, ASIZE: 64, VLEN: - @@ -384,7 +384,7 @@ BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 16, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000010, RegCount: 1 0000000000000050 0f01f9 RDTSCP DSIZE: 32, ASIZE: 64, VLEN: - @@ -402,8 +402,8 @@ Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 - Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 16, RegCount: 1 - Operand: 4, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741565, RegCount: 1 + Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0x00000010, RegCount: 1 + Operand: 4, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000103, RegCount: 1 0000000000000053 0f00e8 VERW ax DSIZE: 32, ASIZE: 64, VLEN: - diff --git a/bddisasm_test/special/invalid_32.result b/bddisasm_test/special/invalid_32.result index c189be9..d6fed1c 100644 --- a/bddisasm_test/special/invalid_32.result +++ b/bddisasm_test/special/invalid_32.result @@ -136,9 +136,9 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741694, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741692, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000082, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000084, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 2, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 @@ -266,7 +266,7 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 diff --git a/bddisasm_test/special/only_64.result b/bddisasm_test/special/only_64.result index 23c0fa6..0a88d47 100644 --- a/bddisasm_test/special/only_64.result +++ b/bddisasm_test/special/only_64.result @@ -55,8 +55,8 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 - Operand: 1, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 0, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 + Operand: 1, Acc: RW, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000102, RegCount: 1 000000000000000B 0f05 SYSCALL DSIZE: 64, ASIZE: 64, VLEN: - @@ -73,9 +73,9 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741694, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741692, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000082, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000084, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Segment, RegSize: 8, RegId: 2, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 @@ -99,7 +99,7 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 @@ -122,7 +122,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741568, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000100, RegCount: 1 0000000000000013 f30faec8 RDGSBASE eax DSIZE: 32, ASIZE: 64, VLEN: - @@ -138,7 +138,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 0000000000000017 f30faed0 WRFSBASE eax DSIZE: 32, ASIZE: 64, VLEN: - @@ -154,7 +154,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741568, RegCount: 1 + Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000100, RegCount: 1 000000000000001B f30faed8 WRGSBASE eax DSIZE: 32, ASIZE: 64, VLEN: - @@ -170,5 +170,5 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741567, RegCount: 1 + Operand: 1, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000101, RegCount: 1 diff --git a/bddisasm_test/special/regressions_32.result b/bddisasm_test/special/regressions_32.result index ab55cb7..cd185d5 100644 --- a/bddisasm_test/special/regressions_32.result +++ b/bddisasm_test/special/regressions_32.result @@ -95,9 +95,9 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741694, RegCount: 1 - Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741692, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000082, RegCount: 1 + Operand: 2, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000084, RegCount: 1 Operand: 3, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 2, RegCount: 1 Operand: 4, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 1, RegCount: 1 Operand: 5, Acc: -W, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 @@ -121,7 +121,7 @@ REP: no, REPcc: no, LOCK: no HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no - Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741695, RegCount: 1 + Operand: 0, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000081, RegCount: 1 Operand: 1, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: Segment, RegSize: 4, RegId: 2, RegCount: 1 Operand: 2, Acc: R-, Type: Register, Size: 4, RawSize: 4, Encoding: S, RegType: General Purpose, RegSize: 4, RegId: 1, RegCount: 1 Operand: 3, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: General Purpose, RegSize: 8, RegId: 11, RegCount: 1 @@ -144,7 +144,7 @@ HLE: no, XACQUIRE only: no, XRELEASE only: no BND: no, BHINT: no, DNT: no Operand: 0, Acc: -W, Type: Register, Size: 4, RawSize: 4, Encoding: M, RegType: General Purpose, RegSize: 4, RegId: 0, RegCount: 1 - Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: -1073741565, RegCount: 1 + Operand: 1, Acc: R-, Type: Register, Size: 8, RawSize: 8, Encoding: S, RegType: Model Specific, RegSize: 8, RegId: 0xc0000103, RegCount: 1 0000000000000015 f30f1b05a4274e6d BNDMK bnd0, dword ptr [0x6d4e27a4] DSIZE: 32, ASIZE: 32, VLEN: - diff --git a/bdshemu/bdshemu.c b/bdshemu/bdshemu.c index 9f1e5fd..991ac5a 100644 --- a/bdshemu/bdshemu.c +++ b/bdshemu/bdshemu.c @@ -1654,10 +1654,8 @@ ShemuEmulate( SHEMU_CONTEXT *Context ) { - NDSTATUS ndstatus; SHEMU_VALUE res = { 0 }, dst = { 0 }, src = { 0 }, rcx = { 0 }, aux = { 0 }; bool stop = false, cf; - uint64_t rip = 0; if (NULL == Context) { @@ -1696,6 +1694,9 @@ ShemuEmulate( while (Context->InstructionsCount++ < Context->MaxInstructionsCount) { + NDSTATUS ndstatus; + uint64_t rip; + // The stop flag has been set, this means we've reached a valid instruction, but that instruction cannot be // emulated (for example, SYSCALL, INT, system instructions, etc). if (stop) diff --git a/disasmtool/disasmtool.c b/disasmtool/disasmtool.c index b3ca60e..610e929 100644 --- a/disasmtool/disasmtool.c +++ b/disasmtool/disasmtool.c @@ -502,7 +502,7 @@ VOID str_strip( ) { DWORD lenInStr, lenOutStr, lenTokStr; - DWORD itInStr = 0, itTokStr = 0; + DWORD itInStr, itTokStr; lenTokStr = 0; lenOutStr = 0; @@ -723,7 +723,7 @@ print_instruction( printf(", sub-leaf: 0x%08x", Instrux->CpuidFlag.SubLeaf); } - printf(", reg: %s, bit: %d\n", regs[Instrux->CpuidFlag.Reg], Instrux->CpuidFlag.Bit); + printf(", reg: %s, bit: %u\n", regs[Instrux->CpuidFlag.Reg], Instrux->CpuidFlag.Bit); } if (Instrux->HasEvex) @@ -875,7 +875,7 @@ print_instruction( for (i = 0; i < Instrux->OperandsCount; i++) { - printf(" Operand: %d, Acc: %s, Type: %10s, Size: %2d, RawSize: %2d, Encoding: %s", i, + printf(" Operand: %u, Acc: %s, Type: %10s, Size: %2d, RawSize: %2d, Encoding: %s", i, Instrux->Operands[i].Access.Access == ND_ACCESS_READ ? "R-" : Instrux->Operands[i].Access.Access == ND_ACCESS_WRITE ? "-W" : Instrux->Operands[i].Access.Access == (ND_ACCESS_READ|ND_ACCESS_WRITE) ? "RW" : @@ -885,8 +885,8 @@ print_instruction( Instrux->Operands[i].Access.Access == (ND_ACCESS_READ | ND_ACCESS_COND_WRITE) ? "RCW" : Instrux->Operands[i].Access.Access == (ND_ACCESS_COND_READ|ND_ACCESS_WRITE) ? "CRW" : Instrux->Operands[i].Access.Access == ND_ACCESS_PREFETCH ? "P" : "--", - optype_to_string(Instrux->Operands[i].Type), Instrux->Operands[i].Size, - Instrux->Operands[i].RawSize, encoding_to_string(Instrux->Operands[i].Encoding) + optype_to_string(Instrux->Operands[i].Type), (int)Instrux->Operands[i].Size, + (int)Instrux->Operands[i].RawSize, encoding_to_string(Instrux->Operands[i].Encoding) ); if (ND_OP_MEM == Instrux->Operands[i].Type) @@ -968,7 +968,7 @@ print_instruction( if (Instrux->Operands[i].Info.Memory.HasDisp) { - printf("Displacement: 0x%016llx, ", Instrux->Operands[i].Info.Memory.Disp); + printf("Displacement: 0x%016llx, ", (unsigned long long)Instrux->Operands[i].Info.Memory.Disp); } if (Instrux->Operands[i].Info.Memory.IsVsib) @@ -983,11 +983,21 @@ print_instruction( if (ND_OP_REG == Instrux->Operands[i].Type) { - printf(", RegType: %16s, RegSize: %2d, RegId: %d, RegCount: %d\n", - regtype_to_string(Instrux->Operands[i].Info.Register.Type), - Instrux->Operands[i].Info.Register.Size, - Instrux->Operands[i].Info.Register.Reg, - Instrux->Operands[i].Info.Register.Count); + printf(", RegType: %16s, RegSize: %2u, ", + regtype_to_string(Instrux->Operands[i].Info.Register.Type), + Instrux->Operands[i].Info.Register.Size); + if (Instrux->Operands[i].Info.Register.Type == ND_REG_MSR) + { + printf("RegId: 0x%08x, RegCount: %u\n", + Instrux->Operands[i].Info.Register.Reg, + Instrux->Operands[i].Info.Register.Count); + } + else + { + printf("RegId: %u, RegCount: %u\n", + Instrux->Operands[i].Info.Register.Reg, + Instrux->Operands[i].Info.Register.Count); + } } else { @@ -1161,11 +1171,10 @@ handle_disasm( __in PDISASM_OPTIONS Options ) { - NDSTATUS status; INSTRUX instrux; ND_CONTEXT ctx = { 0 }; - QWORD icount = 0, istart = 0, iend = 0, start = 0, end = 0, itotal = 0; - SIZE_T rip = 0, fsize = Options->Size; + unsigned long long icount = 0, istart, iend, start, end, itotal = 0; + SIZE_T rip, fsize = Options->Size; PBYTE buffer = Options->Buffer; start = clock(); @@ -1182,6 +1191,8 @@ handle_disasm( rip = Options->Offset; while (rip < Options->Size) { + NDSTATUS status; + icount++; istart = __rdtsc(); @@ -1219,7 +1230,7 @@ handle_disasm( if (Options->Stats) { - printf("Disassembled %lld instructions in %lldms, %4.4f instructions/second, %4.6f clocks/instruction\n", + printf("Disassembled %llu instructions in %llums, %4.4f instructions/second, %4.6f clocks/instruction\n", icount, end - start, icount / (double)(end - start) * 1000, itotal / (double)icount); } } @@ -1402,12 +1413,12 @@ handle_shemu( if (fileName == NULL) { - decFileNameLength = strlen("hex_string_decoded.bin") + 1; + decFileNameLength = sizeof("hex_string_decoded.bin"); fNameDecoded = (char *)malloc(sizeof(char) * decFileNameLength); } else { - decFileNameLength = strlen(fileName) + strlen("_decoded.bin") + 1; + decFileNameLength = strlen(fileName) + sizeof("_decoded.bin"); fNameDecoded = (char *)malloc(sizeof(char) * decFileNameLength); } @@ -1520,7 +1531,8 @@ handle_shemu( shstatus = ShemuEmulate(&ctx); - printf("Emulation terminated with status 0x%08x, flags: 0x%llx, %d NOPs\n", shstatus, ctx.Flags, ctx.NopCount); + printf("Emulation terminated with status 0x%08x, flags: 0x%llx, %u NOPs\n", + shstatus, (unsigned long long)ctx.Flags, ctx.NopCount); if (ctx.Flags & SHEMU_FLAG_NOP_SLED) { printf(" SHEMU_FLAG_NOP_SLED\n"); @@ -1642,7 +1654,7 @@ int main( NdGetVersion(&major, &minor, &revision, &date, &time); - printf("Napoca Disassembler version %d.%d.%d, built on %s %s\n", major, minor, revision, date, time); + printf("Napoca Disassembler version %u.%u.%u, built on %s %s\n", major, minor, revision, date, time); printf("Usage: disasm -f file|-h hex-string -b[16|32|64] [-nv] [-iv] [-hl] [-s] [-c] [-shctxf contextfile] " "[-reg_name reg_val]\n"); printf(" -f file specify input file\n"); diff --git a/disasmtool_lix/disasmtool.cpp b/disasmtool_lix/disasmtool.cpp index 722a4c4..70d46ef 100644 --- a/disasmtool_lix/disasmtool.cpp +++ b/disasmtool_lix/disasmtool.cpp @@ -205,7 +205,7 @@ static void _set_text_color(Colors color) } -static struct timespec diff_time(struct timespec &end, struct timespec &start) +static struct timespec diff_time(struct timespec const &end, struct timespec const &start) { struct timespec result; @@ -313,7 +313,7 @@ void print_instruction(const size_t rip, INSTRUX *instrux, const options &opts) printf(", sub-leaf: 0x%08x", instrux->CpuidFlag.SubLeaf); } - printf(", reg: %s, bit %d\n", regs[instrux->CpuidFlag.Reg], instrux->CpuidFlag.Bit); + printf(", reg: %s, bit %u\n", regs[instrux->CpuidFlag.Reg], instrux->CpuidFlag.Bit); } printf(" FLAGS access: "); @@ -376,8 +376,8 @@ void print_instruction(const size_t rip, INSTRUX *instrux, const options &opts) printf(" Operand %d %s Type: %10s, Size: %2d, RawSize: %2d, Encoding: %s", i, instrux->Operands[i].Access.Read && instrux->Operands[i].Access.Write ? "RW" : instrux->Operands[i].Access.Write ? "-W" : instrux->Operands[i].Access.Read ? "R-" : "--", - op_type_to_str(instrux->Operands[i].Type).c_str(), instrux->Operands[i].Size, - instrux->Operands[i].RawSize, op_enc_to_str(instrux->Operands[i].Encoding).c_str()); + op_type_to_str(instrux->Operands[i].Type).c_str(), (int)instrux->Operands[i].Size, + (int)instrux->Operands[i].RawSize, op_enc_to_str(instrux->Operands[i].Encoding).c_str()); if (ND_OP_MEM == instrux->Operands[i].Type) { printf(", "); @@ -408,11 +408,21 @@ void print_instruction(const size_t rip, INSTRUX *instrux, const options &opts) } if (ND_OP_REG == instrux->Operands[i].Type) { - printf(", Type: %16s, Size: %2d, Reg: %d, Count: %d", - reg_type_to_str(instrux->Operands[i].Info.Register.Type).c_str(), - instrux->Operands[i].Info.Register.Size, - instrux->Operands[i].Info.Register.Reg, - instrux->Operands[i].Info.Register.Count); + printf(", RegType: %16s, RegSize: %2u, ", + reg_type_to_str(instrux->Operands[i].Info.Register.Type).c_str(), + instrux->Operands[i].Info.Register.Size); + if (instrux->Operands[i].Info.Register.Type == ND_REG_MSR) + { + printf("RegId: 0x%08x, RegCount: %u\n", + instrux->Operands[i].Info.Register.Reg, + instrux->Operands[i].Info.Register.Count); + } + else + { + printf("RegId: %u, RegCount: %u\n", + instrux->Operands[i].Info.Register.Reg, + instrux->Operands[i].Info.Register.Count); + } } printf("\n"); @@ -518,7 +528,7 @@ size_t disassemble(options &opts) long total_ns = result.tv_sec * NSEC_PER_SEC + result.tv_nsec; - printf("Disassembled %zu instructions took %ld.%09ld seconds, %ld ns / instr.\n", + printf("Disassembled %zu instructions took %ld.%09ld seconds, %lu ns / instr.\n", icount, result.tv_sec, result.tv_nsec, total_ns / icount); printf("Invalid: %zu/%zu (%.2f) bytes\n", miss_count, ibytes, (static_cast(miss_count) / static_cast(disasm_size)) * 100.0);