luaur_code_gen/methods/
assembly_builder_x_64_nop.rs1use crate::records::assembly_builder_x_64::AssemblyBuilderX64;
2
3impl AssemblyBuilderX64 {
4 pub fn nop(&mut self, mut length: u32) {
5 while length != 0 {
6 let step = if length > 9 { 9 } else { length };
7 length -= step;
8
9 match step {
10 1 => {
11 if self.log_text {
12 self.log_append(format_args!(" nop\n"));
13 }
14 self.place(0x90);
15 }
16 2 => {
17 if self.log_text {
18 self.log_append(format_args!(" xchg ax, ax ; {}-byte nop\n", step));
19 }
20 self.place(0x66);
21 self.place(0x90);
22 }
23 3 => {
24 if self.log_text {
25 self.log_append(format_args!(
26 " nop dword ptr[rax] ; {}-byte nop\n",
27 step
28 ));
29 }
30 self.place(0x0f);
31 self.place(0x1f);
32 self.place(0x00);
33 }
34 4 => {
35 if self.log_text {
36 self.log_append(format_args!(
37 " nop dword ptr[rax] ; {}-byte nop\n",
38 step
39 ));
40 }
41 self.place(0x0f);
42 self.place(0x1f);
43 self.place(0x40);
44 self.place(0x00);
45 }
46 5 => {
47 if self.log_text {
48 self.log_append(format_args!(
49 " nop dword ptr[rax+rax] ; {}-byte nop\n",
50 step
51 ));
52 }
53 self.place(0x0f);
54 self.place(0x1f);
55 self.place(0x44);
56 self.place(0x00);
57 self.place(0x00);
58 }
59 6 => {
60 if self.log_text {
61 self.log_append(format_args!(
62 " nop word ptr[rax+rax] ; {}-byte nop\n",
63 step
64 ));
65 }
66 self.place(0x66);
67 self.place(0x0f);
68 self.place(0x1f);
69 self.place(0x44);
70 self.place(0x00);
71 self.place(0x00);
72 }
73 7 => {
74 if self.log_text {
75 self.log_append(format_args!(
76 " nop dword ptr[rax] ; {}-byte nop\n",
77 step
78 ));
79 }
80 self.place(0x0f);
81 self.place(0x1f);
82 self.place(0x80);
83 self.place(0x00);
84 self.place(0x00);
85 self.place(0x00);
86 self.place(0x00);
87 }
88 8 => {
89 if self.log_text {
90 self.log_append(format_args!(
91 " nop dword ptr[rax+rax] ; {}-byte nop\n",
92 step
93 ));
94 }
95 self.place(0x0f);
96 self.place(0x1f);
97 self.place(0x84);
98 self.place(0x00);
99 self.place(0x00);
100 self.place(0x00);
101 self.place(0x00);
102 self.place(0x00);
103 }
104 9 => {
105 if self.log_text {
106 self.log_append(format_args!(
107 " nop word ptr[rax+rax] ; {}-byte nop\n",
108 step
109 ));
110 }
111 self.place(0x66);
112 self.place(0x0f);
113 self.place(0x1f);
114 self.place(0x84);
115 self.place(0x00);
116 self.place(0x00);
117 self.place(0x00);
118 self.place(0x00);
119 self.place(0x00);
120 }
121 _ => {}
122 }
123
124 self.commit();
125 }
126 }
127}