{"action":"created","issue":{"url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/522","repository_url":"https://api.github.com/repos/unicorn-engine/unicorn","labels_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/522/labels{/name}","comments_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/522/comments","events_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/522/events","html_url":"https://github.com/unicorn-engine/unicorn/issues/522","id":148563857,"number":522,"title":"GDT not fully working","user":{"login":"sparktrend","id":16696545,"avatar_url":"https://avatars.githubusercontent.com/u/16696545?v=3","gravatar_id":"","url":"https://api.github.com/users/sparktrend","html_url":"https://github.com/sparktrend","followers_url":"https://api.github.com/users/sparktrend/followers","following_url":"https://api.github.com/users/sparktrend/following{/other_user}","gists_url":"https://api.github.com/users/sparktrend/gists{/gist_id}","starred_url":"https://api.github.com/users/sparktrend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparktrend/subscriptions","organizations_url":"https://api.github.com/users/sparktrend/orgs","repos_url":"https://api.github.com/users/sparktrend/repos","events_url":"https://api.github.com/users/sparktrend/events{/privacy}","received_events_url":"https://api.github.com/users/sparktrend/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2016-04-15T06:12:53Z","updated_at":"2016-04-19T10:31:30Z","closed_at":null,"body":"Hi Guys,\r\nI have trouble getting GDT up and running. I call Setup() function in the following class:\r\n\r\nhttps://gist.github.com/sparktrend/4e0f3234449a4524b5a6f30b38d5ebea\r\n\r\nThis is a slightly corrected version of the sample in regress/x86_gdt.py of the package. I changed the 'access' bit field definition to deal with stack segment and code segment. I can't post the full code because it's really long, but essentially I just call Setup(teb) function after initializing memory map. Basically there are two symptoms:\r\n\r\n**1 If I enable all selector creations in Setup(), the system triggers segmentation fault 11.**\r\nI figured the last line (stack segment selector) causes this trouble. Disabling the ss selector creation, no segmentation fault gets triggered.\r\n\r\n**2 If I disable ss selector creation, I have the following error:**\r\n_1301012: \tcall\t0x1301002 INVALID MEM-WRITE **0xfd8c/4** *=0x1301017\r\nERROR: Invalid memory write (UC_ERR_WRITE_UNMAPPED)_\r\n\r\nESP at the time of exception was 0x3dfd90. This 'call' instruction attempts to push the return address (0x1301017) onto '**0xfd8c**' where it, in fact, should have accessed ESP-4, which is 0x3dfd8c.\r\n\r\nWhat do you think causes these symptoms?\r\n\r\nBTW, what is the expected behaviour when you don't set the selectors?\r\n\r\nMuch appreciated,\r\nSean\r\n\r\n \r\n"},"comment":{"url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/comments/211848090","html_url":"https://github.com/unicorn-engine/unicorn/issues/522#issuecomment-211848090","issue_url":"https://api.github.com/repos/unicorn-engine/unicorn/issues/522","id":211848090,"user":{"login":"sparktrend","id":16696545,"avatar_url":"https://avatars.githubusercontent.com/u/16696545?v=3","gravatar_id":"","url":"https://api.github.com/users/sparktrend","html_url":"https://github.com/sparktrend","followers_url":"https://api.github.com/users/sparktrend/followers","following_url":"https://api.github.com/users/sparktrend/following{/other_user}","gists_url":"https://api.github.com/users/sparktrend/gists{/gist_id}","starred_url":"https://api.github.com/users/sparktrend/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sparktrend/subscriptions","organizations_url":"https://api.github.com/users/sparktrend/orgs","repos_url":"https://api.github.com/users/sparktrend/repos","events_url":"https://api.github.com/users/sparktrend/events{/privacy}","received_events_url":"https://api.github.com/users/sparktrend/received_events","type":"User","site_admin":false},"created_at":"2016-04-19T10:31:30Z","updated_at":"2016-04-19T10:31:30Z","body":"I changed to A_PRIV_0 and S_PRIV_0 for all segment registers. It works like a charm!\r\n\r\nThanks heaps, cseagle."}}