{"action":"created","issue":{"url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/210","labels_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/210/labels{/name}","comments_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/210/comments","events_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/210/events","html_url":"https://github.com/unicorn-engine/unicorn/issues/210","id":112551654,"number":210,"title":"Changing PC from within an UC_HOOK_CODE doesn't work","user":{"login":"hugoreinaldo","id":291565,"avatar_url":"https://avatars.githubusercontent.com/u/291565?v=3","gravatar_id":"","url":"https://api.github.com/users/hugoreinaldo","html_url":"https://github.com/hugoreinaldo","followers_url":"https://api.github.com/users/hugoreinaldo/followers","following_url":"https://api.github.com/users/hugoreinaldo/following{/other_user}","gists_url":"https://api.github.com/users/hugoreinaldo/gists{/gist_id}","starred_url":"https://api.github.com/users/hugoreinaldo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hugoreinaldo/subscriptions","organizations_url":"https://api.github.com/users/hugoreinaldo/orgs","repos_url":"https://api.github.com/users/hugoreinaldo/repos","events_url":"https://api.github.com/users/hugoreinaldo/events{/privacy}","received_events_url":"https://api.github.com/users/hugoreinaldo/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/unicorn-engine/unicorn/labels/enhancement","name":"enhancement","color":"84b6eb"},{"url":"https://api.github.com/repos/unicorn-engine/unicorn/labels/help%20wanted","name":"help wanted","color":"159818"},{"url":"https://api.github.com/repos/unicorn-engine/unicorn/labels/TODO","name":"TODO","color":"fbca04"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":11,"created_at":"2015-10-21T09:52:05Z","updated_at":"2016-01-06T18:01:49Z","closed_at":null,"body":"Is there a way to change the program counter from within an UC_HOOK_CODE ? None of the following examples seem to work: \r\n\r\n    def hook_code(uc, address, size, userdata):\r\n        uc.reg_write(arm_const.UC_ARM_REG_PC, 0x00)\r\n\r\n    def hook_code(uc, address, size, userdata):\r\n        uc.mem_write(address+size, 0x00)\r\n"},"comment":{"url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/comments/169405395","html_url":"https://github.com/unicorn-engine/unicorn/issues/210#issuecomment-169405395","issue_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/210","id":169405395,"user":{"login":"aquynh","id":5965536,"avatar_url":"https://avatars.githubusercontent.com/u/5965536?v=3","gravatar_id":"","url":"https://api.github.com/users/aquynh","html_url":"https://github.com/aquynh","followers_url":"https://api.github.com/users/aquynh/followers","following_url":"https://api.github.com/users/aquynh/following{/other_user}","gists_url":"https://api.github.com/users/aquynh/gists{/gist_id}","starred_url":"https://api.github.com/users/aquynh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aquynh/subscriptions","organizations_url":"https://api.github.com/users/aquynh/orgs","repos_url":"https://api.github.com/users/aquynh/repos","events_url":"https://api.github.com/users/aquynh/events{/privacy}","received_events_url":"https://api.github.com/users/aquynh/received_events","type":"User","site_admin":false},"created_at":"2016-01-06T18:01:49Z","updated_at":"2016-01-06T18:01:49Z","body":"yes in general the way to go when PC is modified from inside a callback (using uc_reg_write()) is:\r\n\r\n- signal to quit the current BB immediately\r\n- upon exit, flush a page in the JIT cache where the new PC belongs to\r\n- let the execution continue\r\n\r\nthis is not really hard to implement, and i think you can do it :-)"}}