@@ -1261,22 +1261,39 @@ impl Emu {
1261
1261
*/
1262
1262
1263
1263
if self.cfg.trace_mem {
1264
+ // Record the read from stack memory
1264
1265
let name = match self.maps.get_addr_name(self.regs.get_esp()) {
1265
1266
Some(n) => n,
1266
1267
None => "not mapped".to_string(),
1267
1268
};
1268
- let memory_operation = MemoryOperation {
1269
+ let read_operation = MemoryOperation {
1269
1270
pos: self.pos,
1270
1271
rip: self.regs.rip,
1271
1272
op: "read".to_string(),
1272
1273
bits: 32,
1273
1274
address: self.regs.get_esp(),
1274
- old_value: 0, // not needed for read?
1275
+ old_value: 0, // not needed for read
1275
1276
new_value: value as u64,
1276
1277
name: name.clone(),
1277
1278
};
1278
- self.memory_operations.push(memory_operation);
1279
- println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'", self.pos, self.regs.rip, 32, self.regs.get_esp(), value, name);
1279
+ self.memory_operations.push(read_operation);
1280
+ println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'",
1281
+ self.pos, self.regs.rip, 32, self.regs.get_esp(), value, name);
1282
+
1283
+ // Record the write to register
1284
+ let write_operation = MemoryOperation {
1285
+ pos: self.pos,
1286
+ rip: self.regs.rip,
1287
+ op: "write".to_string(),
1288
+ bits: 32,
1289
+ address: self.regs.get_esp(),
1290
+ old_value: self.maps.read_dword(self.regs.get_esp()).unwrap_or(0) as u64,
1291
+ new_value: value as u64, // new value being written
1292
+ name: "register".to_string(),
1293
+ };
1294
+ self.memory_operations.push(write_operation);
1295
+ println!("\tmem_trace: pos = {} rip = {:x} op = write bits = {} address = 0x{:x} value = 0x{:x} name = 'register'",
1296
+ self.pos, self.regs.rip, 32, self.regs.get_esp(), value);
1280
1297
}
1281
1298
1282
1299
self.regs.set_esp(self.regs.get_esp() + 4);
@@ -1324,22 +1341,39 @@ impl Emu {
1324
1341
};
1325
1342
1326
1343
if self.cfg.trace_mem {
1344
+ // Record the read from stack memory
1327
1345
let name = match self.maps.get_addr_name(self.regs.rsp) {
1328
1346
Some(n) => n,
1329
1347
None => "not mapped".to_string(),
1330
1348
};
1331
- let memory_operation = MemoryOperation {
1349
+ let read_operation = MemoryOperation {
1332
1350
pos: self.pos,
1333
1351
rip: self.regs.rip,
1334
1352
op: "read".to_string(),
1335
- bits: 32,
1353
+ bits: 64, // Changed from 32 to 64 for 64-bit operations
1336
1354
address: self.regs.rsp,
1337
- old_value: 0, // not needed for read?
1355
+ old_value: 0, // not needed for read
1338
1356
new_value: value as u64,
1339
1357
name: name.clone(),
1340
1358
};
1341
- self.memory_operations.push(memory_operation);
1342
- println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'", self.pos, self.regs.rip, 32, self.regs.rsp, value, name);
1359
+ self.memory_operations.push(read_operation);
1360
+ println!("\tmem_trace: pos = {} rip = {:x} op = read bits = {} address = 0x{:x} value = 0x{:x} name = '{}'",
1361
+ self.pos, self.regs.rip, 64, self.regs.rsp, value, name);
1362
+
1363
+ // Record the write to register
1364
+ let write_operation = MemoryOperation {
1365
+ pos: self.pos,
1366
+ rip: self.regs.rip,
1367
+ op: "write".to_string(),
1368
+ bits: 64, // Changed from 32 to 64 for 64-bit operations
1369
+ address: self.regs.rsp,
1370
+ old_value: self.maps.read_qword(self.regs.rsp).unwrap_or(0) as u64,
1371
+ new_value: value as u64, // new value being written
1372
+ name: "register".to_string(),
1373
+ };
1374
+ self.memory_operations.push(write_operation);
1375
+ println!("\tmem_trace: pos = {} rip = {:x} op = write bits = {} address = 0x{:x} value = 0x{:x} name = 'register'",
1376
+ self.pos, self.regs.rip, 64, self.regs.rsp, value);
1343
1377
}
1344
1378
1345
1379
self.regs.rsp += 8;
0 commit comments