【轉貼】Here
開機後,先進入dos:
C:\>Debug -A100(開始逐行編輯) 1375:0100 mov ax, 4F15 1375:0103 mox bx, 01 1375:0106 int 10 1375:0108 int 3 1375:0109(退出編輯) -g(執行) ax=004F(int10 成功) -d 0(顯示讀出內容)
前戲:
- 先看,EDID
- 重點: ax=0x4F15,bx=0x01,int=0x10,cx=0~2 ( 好像都可以?! )
- libx86 - a hardware-independent library for executing real-mode x86 code
- 安裝:libx86-dev
#include <stdio.h> #include <stdlib.h> #include <unistd.h> #include <string.h> #include <libx86.h> int read_edid(void) { struct LRMI_regs regs; unsigned char *edid = NULL; if (!LRMI_init()) return -1; if ((edid = LRMI_alloc_real(128)) == NULL) return -1; memset(edid, 0x30, 128); memset(®s, 0, sizeof(regs)); regs.es = (unsigned int)edid >> 4; regs.edi = 0; regs.eax = 0x4f15; regs.ebx = 0x01; ioperm(0,0x400,1); // 需root權限 iopl(3); /* printf("edi=0x%x\n", regs.edi); printf("esi=0x%x\n", regs.esi); printf("ebp=0x%x\n", regs.ebp); printf("reserved=0x%x\n", regs.reserved); printf("ebx=0x%x\n", regs.ebx); printf("edx=0x%x\n", regs.edx); printf("ecx=0x%x\n", regs.ecx); printf("eax=0x%x\n", regs.eax); printf("flags=0x%x\n", regs.flags); printf("es=0x%x\n", regs.es); printf("ds=0x%x\n", regs.ds); printf("fs=0x%x\n", regs.fs); printf("gs=0x%x\n", regs.gs); printf("ip=0x%x\n", regs.ip); printf("cs=0x%x\n", regs.cs); printf("sp=0x%x\n", regs.sp); printf("ss=0x%x\n", regs.ss); */ LRMI_int( 0x10, ®s ); /* printf("---After LRMI_int---\n"); printf("edi=0x%x\n", regs.edi); printf("esi=0x%x\n", regs.esi); printf("ebp=0x%x\n", regs.ebp); printf("reserved=0x%x\n", regs.reserved); printf("ebx=0x%x\n", regs.ebx); printf("edx=0x%x\n", regs.edx); printf("ecx=0x%x\n", regs.ecx); printf("eax=0x%x\n", regs.eax); //值會改變 printf("flags=0x%x\n", regs.flags); //值會改變 printf("es=0x%x\n", regs.es); printf("ds=0x%x\n", regs.ds); printf("fs=0x%x\n", regs.fs); printf("gs=0x%x\n", regs.gs); printf("ip=0x%x\n", regs.ip); printf("cs=0x%x\n", regs.cs); printf("sp=0x%x\n", regs.sp); printf("ss=0x%x\n", regs.ss); */ fwrite(edid,128,1,stdout); return 0; } int main ( int argc, char *argv[]) { read_edid(); return 0; } Compile: gcc test.c -o test -lx86 run: ./test > edid.dat ref: 1. Here 2. Here
沒有留言:
張貼留言