Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend TZYInstructionOperand to support implicit disp #31

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions Data/instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -8662,6 +8662,7 @@
"width32": 8,
"width64": 16,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -8716,6 +8717,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -8771,6 +8773,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -8826,6 +8829,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -8876,6 +8880,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -8933,6 +8938,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -8990,6 +8996,7 @@
"width32": 8,
"width64": 16,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66020,6 +66027,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66057,6 +66065,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66094,6 +66103,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66131,6 +66141,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66165,6 +66176,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66200,6 +66212,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66235,6 +66248,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66270,6 +66284,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66305,6 +66320,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66340,6 +66356,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66375,6 +66392,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66410,6 +66428,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66450,6 +66469,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66489,6 +66509,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66528,6 +66549,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66572,6 +66594,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66608,6 +66631,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66644,6 +66668,7 @@
"width32": 4,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66718,6 +66743,7 @@
"width16": 16,
"width32": 32,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66791,6 +66817,7 @@
"width16": 16,
"width32": 32,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66825,6 +66852,7 @@
"width32": 2,
"width64": 2,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66880,6 +66908,7 @@
"width32": 2,
"width64": 2,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66935,6 +66964,7 @@
"width32": 4,
"width64": 4,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -66990,6 +67020,7 @@
"width32": 8,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down Expand Up @@ -67045,6 +67076,7 @@
"width32": 8,
"width64": 8,
"visible": false,
"implictdisp": true,
"ignore_seg_override": true
}
],
Expand Down
5 changes: 3 additions & 2 deletions Zydis/Generator/Zydis.Generator.Tables.pas
Original file line number Diff line number Diff line change
Expand Up @@ -814,8 +814,9 @@ class procedure TZYOperandTableGenerator.Generate(Generator: TZYBaseGenerator;
begin
{ op } Writer.StructBegin;
{ mem } Writer.StructBegin('mem');
{ seg } Writer.WriteDec(Ord(Item.MemorySegment));
{ base } Writer.WriteStr('ZYDIS_IMPLMEM_BASE_' +
{ implicitdisp } Writer.WriteDec(Ord(Item.HasImplictDisp));
{ seg } Writer.WriteDec(Ord(Item.MemorySegment));
{ base } Writer.WriteStr('ZYDIS_IMPLMEM_BASE_' +
TZYBaseRegister.ZydisStrings[Item.MemoryBase]);
{ op } Writer.StructEnd;
{ mem } Writer.StructEnd;
Expand Down
2 changes: 1 addition & 1 deletion Zydis/Zydis.Enums.pas
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ TZYEnumRegister = record
// Misc registers
'mxcsr', 'pkru', 'xcr0', 'gdtr',
'ldtr', 'idtr', 'tr', 'bndcfg',
'bndstatus', 'uif' , 'ia32_kernel_gsbase'
'bndstatus', 'uif' , 'ia32_kernel_gs_base'
);
end;
TZYRegister = TZYEnumRegister.Enum;
Expand Down
14 changes: 14 additions & 0 deletions Zydis/Zydis.InstructionEditor.pas
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ TZYInstructionOperand = class sealed(TZYLinkedJSONOPersistent<TZYInstructionOp
FScaleFactor: TZYScaleFactor;
FWidth: array[1..3] of TZYSemanticOperandWidth;
FVisible: Boolean;
FHasImplictDisp : Boolean;
FIsMultisource4: Boolean;
FIgnoreSegmentOverride: Boolean;
strict private
Expand All @@ -402,6 +403,7 @@ TZYInstructionOperand = class sealed(TZYLinkedJSONOPersistent<TZYInstructionOp
procedure SetScaleFactor(const Value: TZYScaleFactor); inline;
procedure SetWidth(Index: Integer; const Value: TZYSemanticOperandWidth); inline;
procedure SetVisible(const Value: Boolean); inline;
procedure SetHasImplictDisp(const Value: Boolean); inline;
procedure SetIsMultisource4(const Value: Boolean); inline;
procedure SetIgnoreSegmentOverride(const Value: Boolean); inline;
protected
Expand Down Expand Up @@ -432,6 +434,7 @@ TZYInstructionOperand = class sealed(TZYLinkedJSONOPersistent<TZYInstructionOp
property Width32: TZYSemanticOperandWidth index 2 read GetWidth write SetWidth default 0;
property Width64: TZYSemanticOperandWidth index 3 read GetWidth write SetWidth default 0;
property Visible: Boolean read FVisible write SetVisible default true;
property HasImplictDisp: Boolean read FHasImplictDisp write SetHasImplictDisp default true;
property Visibility: TZYOperandVisibility read GetVisibility;
property IsMultisource4: Boolean read FIsMultisource4 write SetIsMultisource4 default false;
property IgnoreSegmentOverride: Boolean read FIgnoreSegmentOverride write SetIgnoreSegmentOverride default false;
Expand Down Expand Up @@ -2013,6 +2016,7 @@ procedure TZYInstructionOperand.AssignTo(Dest: TPersistent);
D.SetWidth(I, FWidth[I]);
end;
D.SetVisible(FVisible);
D.SetHasImplictDisp(FHasImplictDisp);
D.SetIsMultisource4(FIsMultisource4);
D.SetIgnoreSegmentOverride(FIgnoreSegmentOverride);
finally
Expand Down Expand Up @@ -2123,6 +2127,7 @@ procedure TZYInstructionOperand.LoadFromJSON(const JSON: IJSONObjectReader);
SetWidth(2, JSON.ReadInteger('width32', 0));
SetWidth(3, JSON.ReadInteger('width64', 0));
SetVisible(JSON.ReadBoolean('visible', true));
SetHasImplictDisp(JSON.ReadBoolean('implictdisp', false));
SetIsMultisource4(JSON.ReadBoolean('is_multisource4', false));
SetIgnoreSegmentOverride(JSON.ReadBoolean('ignore_seg_override', false));
finally
Expand Down Expand Up @@ -2325,6 +2330,15 @@ procedure TZYInstructionOperand.SetVisible(const Value: Boolean);
end;
end;

procedure TZYInstructionOperand.SetHasImplictDisp(const Value: Boolean);
begin
if (FHasImplictDisp <> Value) then
begin
FHasImplictDisp := Value;
Update;
end;
end;

procedure TZYInstructionOperand.SetWidth(Index: Integer; const Value: TZYSemanticOperandWidth);
begin
if (FWidth[Index] <> Value) then
Expand Down