Skip to content

Commit 807af68

Browse files
committed
Examples: adjust to ZydisDecoderDecodeFull changes
1 parent 71fe85a commit 807af68

File tree

6 files changed

+13
-19
lines changed

6 files changed

+13
-19
lines changed

examples/Disassemble.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ int main()
6161
ZyanUSize offset = 0;
6262
const ZyanUSize length = sizeof(data);
6363
ZydisDecodedInstruction instruction;
64-
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
64+
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
6565
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(&decoder, data + offset, length - offset,
66-
&instruction, operands, ZYDIS_MAX_OPERAND_COUNT_VISIBLE,
67-
ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY)))
66+
&instruction, operands)))
6867
{
6968
// Print current instruction pointer.
7069
printf("%016" PRIX64 " ", runtime_address);

examples/Formatter01.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,10 @@ static void DisassembleBuffer(ZydisDecoder* decoder, ZyanU8* data, ZyanUSize len
115115
ZyanU64 runtime_address = 0x007FFFFFFF400000;
116116

117117
ZydisDecodedInstruction instruction;
118-
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
118+
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
119119
char buffer[256];
120120

121-
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(decoder, data, length, &instruction, operands,
122-
ZYDIS_MAX_OPERAND_COUNT_VISIBLE, ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY)))
121+
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(decoder, data, length, &instruction, operands)))
123122
{
124123
ZYAN_PRINTF("%016" PRIX64 " ", runtime_address);
125124

examples/Formatter02.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,11 @@ static void DisassembleBuffer(ZydisDecoder* decoder, ZyanU8* data, ZyanUSize len
211211
ZyanU64 runtime_address = 0x007FFFFFFF400000;
212212

213213
ZydisDecodedInstruction instruction;
214-
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
214+
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
215215
ZydisCustomUserData user_data;
216216
char buffer[256];
217217

218-
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(decoder, data, length, &instruction, operands,
219-
ZYDIS_MAX_OPERAND_COUNT_VISIBLE, ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY)))
218+
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(decoder, data, length, &instruction, operands)))
220219
{
221220
ZYAN_PRINTF("%016" PRIX64 " ", runtime_address);
222221

examples/Formatter03.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,10 @@ static void DisassembleBuffer(ZydisDecoder* decoder, ZyanU8* data, ZyanUSize len
7171
ZyanU64 runtime_address = 0x007FFFFFFF400000;
7272

7373
ZydisDecodedInstruction instruction;
74-
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
74+
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
7575
char buffer[256];
7676

77-
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(decoder, data, length, &instruction, operands,
78-
ZYDIS_MAX_OPERAND_COUNT_VISIBLE, ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY)))
77+
while (ZYAN_SUCCESS(ZydisDecoderDecodeFull(decoder, data, length, &instruction, operands)))
7978
{
8079
const ZydisFormatterToken* token;
8180
if (ZYAN_SUCCESS(ZydisFormatterTokenizeInstruction(&formatter, &instruction, operands,

examples/RewriteCode.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,8 @@ int main(int argc, char** argv)
8989

9090
// Attempt to decode the given bytes as an X86-64 instruction.
9191
ZydisDecodedInstruction instr;
92-
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
93-
ZyanStatus status = ZydisDecoderDecodeFull(&decoder, bytes, num_bytes, &instr, operands,
94-
ZYDIS_MAX_OPERAND_COUNT_VISIBLE, ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY);
92+
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
93+
ZyanStatus status = ZydisDecoderDecodeFull(&decoder, bytes, num_bytes, &instr, operands);
9594
if (ZYAN_FAILED(status))
9695
{
9796
fprintf(stderr, "Failed to decode instruction: %02" PRIx32, status);
@@ -157,7 +156,7 @@ int main(int argc, char** argv)
157156

158157
// Decode and print the new instruction. We re-use the old buffers.
159158
ExpectSuccess(ZydisDecoderDecodeFull(&decoder, new_bytes, new_instr_length, &instr,
160-
operands, ZYDIS_MAX_OPERAND_COUNT_VISIBLE, ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY));
159+
operands));
161160
ExpectSuccess(ZydisFormatterFormatInstruction(&fmt, &instr, operands,
162161
instr.operand_count_visible, fmt_buf, sizeof(fmt_buf), 0, NULL));
163162
printf("New instruction: %s\n", fmt_buf);

examples/ZydisWinKernel.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,15 +159,14 @@ DriverEntry(
159159

160160
SIZE_T readOffset = 0;
161161
ZydisDecodedInstruction instruction;
162-
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT_VISIBLE];
162+
ZydisDecodedOperand operands[ZYDIS_MAX_OPERAND_COUNT];
163163
ZyanStatus status;
164164
CHAR printBuffer[128];
165165

166166
// Start the decode loop
167167
while ((status = ZydisDecoderDecodeFull(&decoder,
168168
(PVOID)(imageBase + entryPointRva + readOffset), length - readOffset, &instruction,
169-
operands, ZYDIS_MAX_OPERAND_COUNT_VISIBLE, ZYDIS_DFLAG_VISIBLE_OPERANDS_ONLY)) !=
170-
ZYDIS_STATUS_NO_MORE_DATA)
169+
operands)) != ZYDIS_STATUS_NO_MORE_DATA)
171170
{
172171
NT_ASSERT(ZYAN_SUCCESS(status));
173172
if (!ZYAN_SUCCESS(status))

0 commit comments

Comments
 (0)