/* XXX: why is this routine from libc redefined here? */
/* NOTE: the redefined version ignores the count param, count is hardcoded as 16 */
static int LDT_Modify( int func, struct modify_ldt_ldt_s *ptr,
/* XXX: why is this routine from libc redefined here? */
/* NOTE: the redefined version ignores the count param, count is hardcoded as 16 */
static int LDT_Modify( int func, struct modify_ldt_ldt_s *ptr,
- "movl %2,%%ebx\n\t"
- "int $0x80\n\t"
- "popl %%ebx"
- : "=a" (res)
- : "0" (__NR_modify_ldt),
- "r" (func),
- "c" (ptr),
- "d"(16)//sizeof(*ptr) from kernel point of view
- :"esi" );
+ "movl %2,%%ebx\n\t"
+ "int $0x80\n\t"
+ "popl %%ebx"
+ : "=a" (res)
+ : "0" (__NR_modify_ldt),
+ "r" (func),
+ "c" (ptr),
+ "d"(16)//sizeof(*ptr) from kernel point of view
+ :"esi" );
static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
{
*buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
static void LDT_EntryToBytes( unsigned long *buffer, const struct modify_ldt_ldt_s *content )
{
*buffer++ = ((content->base_addr & 0x0000ffff) << 16) |
- ((content->base_addr & 0x00ff0000)>>16) |
- (content->limit & 0xf0000) |
- (content->contents << 10) |
- ((content->read_exec_only == 0) << 9) |
- ((content->seg_32bit != 0) << 22) |
- ((content->limit_in_pages != 0) << 23) |
- 0xf000;
+ ((content->base_addr & 0x00ff0000)>>16) |
+ (content->limit & 0xf0000) |
+ (content->contents << 10) |
+ ((content->read_exec_only == 0) << 9) |
+ ((content->seg_32bit != 0) << 22) |
+ ((content->limit_in_pages != 0) << 23) |
+ 0xf000;
ldt_fs->fd = open("/dev/zero", O_RDWR);
if(ldt_fs->fd<0){
perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
ldt_fs->fd = open("/dev/zero", O_RDWR);
if(ldt_fs->fd<0){
perror( "Cannot open /dev/zero for READ+WRITE. Check permissions! error: ");
}
fs_seg=
ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
}
fs_seg=
ldt_fs->fs_seg = mmap(NULL, getpagesize(), PROT_READ | PROT_WRITE, MAP_PRIVATE,
}
*(void**)((char*)ldt_fs->fs_seg+0x18) = ldt_fs->fs_seg;
memset(&array, 0, sizeof(array));
}
*(void**)((char*)ldt_fs->fs_seg+0x18) = ldt_fs->fs_seg;
memset(&array, 0, sizeof(array));
- struct ssd ssd;
- ssd.sel = LDT_SEL(TEB_SEL_IDX);
- ssd.bo = array.base_addr;
- ssd.ls = array.limit - array.base_addr;
- ssd.acc1 = ((array.read_exec_only == 0) << 1) |
- (array.contents << 2) |
- 0xf0; /* P(resent) | DPL3 | S */
- ssd.acc2 = 0x4; /* byte limit, 32-bit segment */
- if (sysi86(SI86DSCR, &ssd) < 0) {
- perror("sysi86(SI86DSCR)");
- printf("Couldn't install fs segment, expect segfault\n");
- }
+ struct ssd ssd;
+ ssd.sel = LDT_SEL(TEB_SEL_IDX);
+ ssd.bo = array.base_addr;
+ ssd.ls = array.limit - array.base_addr;
+ ssd.acc1 = ((array.read_exec_only == 0) << 1) |
+ (array.contents << 2) |
+ 0xf0; /* P(resent) | DPL3 | S */
+ ssd.acc2 = 0x4; /* byte limit, 32-bit segment */
+ if (sysi86(SI86DSCR, &ssd) < 0) {
+ perror("sysi86(SI86DSCR)");
+ printf("Couldn't install fs segment, expect segfault\n");
+ }