Hello everyone,
I have been trying to make a C (or C++) pointer that refers to an offset in SS and not DS.
Can anyone help me plz?
Regards,
Mostafa.
How to make a C pointer refers to an offset in SS?
- xenos
- Member
- Posts: 1121
- Joined: Thu Aug 11, 2005 11:00 pm
- Libera.chat IRC: xenos1984
- Location: Tartu, Estonia
- Contact:
Re: How to make a C pointer refers to an offset in SS?
GCC (and many other C / C++ compilers) don't support segmentation at all. They simply assume that DS = SS, so it doesn't matter whether the offset belongs to DS or SS
If you really want a segmented memory model with DS != SS, I think you can use the Watcom compiler - but I am not absolutely sure. I remember that I once used it with a segmented memory, but that was a few years ago and I probably had DS = SS.
If you really want a segmented memory model with DS != SS, I think you can use the Watcom compiler - but I am not absolutely sure. I remember that I once used it with a segmented memory, but that was a few years ago and I probably had DS = SS.
- iocoder
- Member
- Posts: 208
- Joined: Sun Oct 18, 2009 5:47 pm
- Libera.chat IRC: iocoder
- Location: Alexandria, Egypt | Ottawa, Canada
- Contact:
Re: How to make a C pointer refers to an offset in SS?
Thanks XenOS for your reply,
I think i will have to write a little bit of assembly codes to make pointers read and write to SS offsets. The cause for what i do is that when a program calls System Call INT, System Call changes DS and ES to 0x10 (Kernel's Data Segment) and it keeps SS (in order to allow running tasks to call system call in the same time, so no violation will happen).
If System call wants to call a function in kernel, it makes vriables (which are made into SS) and calls the function, something like this function:
This one needs to return irqs, cs, ds, off, and cls. so it does this:
all these data are written to DS, so System Call will not recieve anything! I think i shall make a function like 'stack_read' and 'stack_write', and 'devman_getinfo' will be like this:
Regards,
Mostafa
I think i will have to write a little bit of assembly codes to make pointers read and write to SS offsets. The cause for what i do is that when a program calls System Call INT, System Call changes DS and ES to 0x10 (Kernel's Data Segment) and it keeps SS (in order to allow running tasks to call system call in the same time, so no violation will happen).
If System call wants to call a function in kernel, it makes vriables (which are made into SS) and calls the function, something like this function:
Code: Select all
void devman_getinfo(unsigned char id, unsigned short *irqs, unsigned short *cs, unsigned short *ds,
unsigned int *off, unsigned int *cls) {
Code: Select all
irqs[0] = devman_devices[id].irq[0] + (devman_devices[id].irq[1]<<8);
cs [0] = devman_devices[id].cs;
ds [0] = devman_devices[id].ds;
off [0] = devman_devices[id].entry;
cls [0] = devman_devices[id].cls;
Code: Select all
void devman_getinfo(unsigned char id, unsigned short *irqs, unsigned short *cs, unsigned short *ds,
unsigned int *off, unsigned int *cls) {
stack_write(devman_devices[id].irq[0] + (devman_devices[id].irq[1]<<8), irqs);
stack_write(devman_devices[id].cs, cs);
stack_write(devman_devices[id].ds, ds);
stack_write(devman_devices[id].entry, off);
stack_write(devman_devices[id].cls, cls);
}
Mostafa