How to call kernel code in libc ? (windows or linux)
I mean, how the kernel expose its function to user lan开发者_StackOverflow中文版d application.
Kernel functions are called using syscalls, which usually take form of filling some registers (type of syscall, parameters, ...) and doing a software interrupt (int 0x80) or sysenter instruction (if your architecture supports it).
If you're doing this on Linux, you might want to see some Linux syscall documentation, like one here: http://bluemaster.iu.hio.no/edu/dark/lin-asm/syscalls.html
There surely exists some similar documentation for other kernels (windows').
Assuming you are talking about Linux, you put your arguments in registers and call interrupt 0x80. The name for this is "system call" See these links:
- http://www.ibm.com/developerworks/linux/library/l-system-calls/
- http://www.linuxjournal.com/article/4048
Windows is probably similar, this looks like a good article:
http://www.codeguru.com/cpp/w-p/system/devicedriverdevelopment/article.php/c8035
etc... google
精彩评论