How to read and write register value from core.cc

138 views
Skip to first unread message

Shaikhul Hadi

unread,
Aug 19, 2021, 9:49:51 PM8/19/21
to Sniper simulator
Hi,
I want to read a register value (rdx), perform some action based on the value, and then update the register value of the register (rdx). Does anyone have any suggestions on how to do so? 

I have come across two functions in pin (PIN_SetContextReg() and PIN_GetContextReg() ) but this function could not be called directly from core.cc . If anyone has any idea how could I use that, that would be great.  


Best 
Shaikhul

Trevor E. Carlson

unread,
Aug 19, 2021, 9:56:19 PM8/19/21
to snip...@googlegroups.com, shaikh...@gmail.com
Shaikhul,

Why not use the magic instructions, and the sim_api.h to communicate this data to the Sniper backend? When this instruction is called, the state can be packaged up, and sent to Sniper for interpretation. Then, the return value is stored back into the program. We already use this to query the status of the hardware or simulator, directly from the application (like the frequency). In fact, there are functions that can check whether you are running inside the simulator, and can take specific actions if that is the case.

Updating data from core.cc back into the application will be very difficult, or might not even be possible. This is because the backend (timing simulator) runs behind the frontend. If you try to push a change from the backend to the frontend, the frontend will already have executed past that point.

Trevor

--
--
--
You received this message because you are subscribed to the Google
Groups "Sniper simulator" group.
To post to this group, send email to snip...@googlegroups.com
To unsubscribe from this group, send email to
snipersim+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/snipersim?hl=en

---
You received this message because you are subscribed to the Google Groups "Sniper simulator" group.
To unsubscribe from this group and stop receiving emails from it, send an email to snipersim+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/snipersim/e0e14712-b64c-476e-bab0-4163408a82c4n%40googlegroups.com.

Shaikhul Hadi

unread,
Aug 22, 2021, 11:29:19 PM8/22/21
to Sniper simulator
In magic instruction , you could pass two arguments (in registers rbx and rcx) and only return one UInt64 value. 
I'm working to implement a magic instruction that operate based on  three arguments value and updates the value of one argument based on some calculations and returns true or false based on whether a conditional check succeeds or not. As I'm limited to two arguments from magic instruction, I'm thinking about reading the third argument directly from the register (in this case register rdx) and updating the value of the register rdx directly from the hooked function that is defined in core.cc and return true/false from magic function . 
[ SideNote:  If anyone have any other alternative ideas on how I could work with three argument based magic instructions and update one particular argument value, please let me know. Thanks ]

Best
Shaikhul

Minh Sơn Lê

unread,
Oct 20, 2022, 8:26:04 AM10/20/22
to Sniper simulator
Hello Shaikhul,
Could you work with three arguments-based magic instructions?
Can you tell me how to do that if you could do that?

Thank you!

Vào lúc 12:29:19 UTC+9 ngày Thứ Hai, 23 tháng 8, 2021, shaikh...@gmail.com đã viết:
Reply all
Reply to author
Forward
0 new messages