#include "display.h"
#include "mem.h"
#include "keys.h"
#include <i86.h>
#include <bios.h>
#include <ctype.h>
//union buf_tag buffer;
union point_tag {
unsigned char *pb;
unsigned short *pw;
unsigned long *pd;
unsigned long d;
} pmem;
int memory_dump()
{
int index = -1;
int enterpress = 1;
int exit = -2;
UINT32 memaddr = 0;
UINT32 findaddr = 0;
UINT32 searchstart = 0;
UINT32 searchend = 0xFFFFF;
UINT8 searchalign = 4;
unsigned char offset = 0;
char searchstring[17] = {0};
char searchhex[16] = {0};
int searchstrindex = 0;
int hexsearch = 0;
int showallcode = 0;
int i, j, n, m;
UINT8 color;
int keycode;
int keys = 0;
enum TYPE showtype = BYTE1;
UINT8 buffer_byte=0;
UINT16 buffer_word=0;
UINT32 buffer_dword=0;
//int addrselect = LIGHTGREEN;
//enum TYPE showtype = BYTE1;
//show X Y role for Data area.
for( i = 0 ; i<16; i++)
color_printf( 3, 4+3*i, B_BLUE+F_LIGHT_RED, "%2.2X" ,i );
for( i = 0 ; i<16; i++)
color_printf( 4+i, 1, B_BLUE+F_LIGHT_RED, "%2.2X" ,i*16 );
//show address enter place.
color_printf( 22, 15, B_BLUE+F_LIGHT_WHITE, "Address: ");
//show ascii code.
color_printf( 3, 55, B_BLUE+F_LIGHT_RED,"ASCII Code");
//show search area
color_printf( 3, 71, B_BLUE+F_LIGHT_RED,"Search");
color_printf( 4, 69, B_BLUE+F_WHITE,"Start:");
color_printf( 6, 69, B_BLUE+F_WHITE,"End:");
color_printf( 8, 69, B_BLUE+F_WHITE,"Align:");
for(i=0;i<80;i++)
color_printf( 24, i, B_WHITE + F_BLACK, " ");
color_printf( 24, 0, B_WHITE + F_BLACK, " 'ESC'->Menu Ctrl+E->Enter Address Ctrl+S->Searsh String Ctrl+X->Searsh Hex");
color_printf( 24, 2, B_WHITE + F_LIGHT_RED, "ESC");
color_printf( 24, 14, B_WHITE + F_LIGHT_RED, "Ctrl+E");
color_printf( 24, 37, B_WHITE + F_LIGHT_RED, "Ctrl+S");
color_printf( 24, 60, B_WHITE + F_LIGHT_RED, "Ctrl+X");
while(1){
color_printf( 22, 24,(index == -1)?B_GRAY+F_LIGHT_WHITE:B_BLUE+F_LIGHT_WHITE, " 0x%8.8X " ,memaddr );
if( index >=0 && index<0x100 )
color_printf( 3 , 1, B_BLUE+F_LIGHT_GREEN, "%.2X", index);
else
color_printf( 3, 1, B_BLUE," ");
color_printf( 10, 69, B_BLUE+F_WHITE,(hexsearch)?"Hex: ":"String:");
color_printf( 5, 69, (index == 0x100)? B_GRAY+F_LIGHT_WHITE:B_BLUE+F_LIGHT_WHITE, "0x%8.8X" ,searchstart);
color_printf( 7, 69, (index == 0x101)? B_GRAY+F_LIGHT_WHITE:B_BLUE+F_LIGHT_WHITE, "0x%8.8X" ,searchend);
color_printf( 9, 69, (index == 0x102)? B_GRAY+F_LIGHT_WHITE:B_BLUE+F_LIGHT_WHITE, "0x%2.2X" ,searchalign);
color_printf( 11,69, (index == 0x103)? B_GRAY+F_LIGHT_WHITE:B_WHITE+F_WHITE, " " );
color_printf( 12,69, (index == 0x103)? B_GRAY+F_LIGHT_WHITE:B_WHITE+F_WHITE, " " );
if( searchstrindex < 8){
for(i = 0; i<searchstrindex;i++)
color_printf( 11,70+i, B_GRAY+F_LIGHT_WHITE, "%c" ,searchstring[i]);
}
else{
for(i = 0; i< 8; i++)
color_printf( 11,70+i, B_GRAY+F_LIGHT_WHITE, "%c" ,searchstring[i]);
for(i = 8; i<searchstrindex ; i++)
color_printf( 12,70+(i-8), B_GRAY+F_LIGHT_WHITE, "%c" ,searchstring[i]);
}
if( enterpress ){
pmem.d = memaddr;
}
//Display Data Value.
for( i = 0; i<16; i++){
if(showtype == 1){
for ( j =0 ; j<16; j++){
if( pmem.pb[i*16+j] == 0xFF)
color = B_BLUE + F_LIGHT_WHITE;
else if( pmem.pb[i*16+j] == 0x00)
color = B_BLUE + F_GRAY;
else
color = B_BLUE + F_YELLOW;
if( index == i*16+j){
color = color & 0x0F | B_LIGHT_RED;
if(enterpress)
buffer_byte = pmem.pb[index];
show_buffer_byte(buffer_byte,20,1);
color_printf ( i+4, 3*j+4, color,"%2.2X", buffer_byte);
if(isalnum(buffer_byte))
color_printf ( i+4, j + 52, B_BLUE+F_WHITE, "%c", buffer_byte);
else
color_printf ( i+4, j + 52, B_BLUE+F_WHITE, ".");
}
else{
color_printf ( i+4, 3*j+4, color,"%2.2X", pmem.pb[i*16+j]);
if(isalnum(pmem.pb[i*16+j]))
color_printf ( i+4, j + 52, B_BLUE+F_WHITE, "%c", pmem.pb[i*16+j]);
else{
if(showallcode)
color_printf ( i+4, j + 52, B_BLUE+F_WHITE, "%c", pmem.pb[i*16+j]);
else
color_printf ( i+4, j + 52, B_BLUE+F_WHITE, ".");
}
}
}
}
if(showtype == 2){
for ( j =0 ; j<8; j++){
if( pmem.pw[i*8+j] == 0xFFFF)
color = B_BLUE + F_LIGHT_WHITE;
else if( pmem.pw[i*8+j] == 0x0000)
color = B_BLUE + F_GRAY;
else
color = B_BLUE + F_YELLOW;
if( index/2 == i*8+j){
color = color & 0x0F | B_LIGHT_RED;
if(enterpress)
buffer_word = pmem.pw[index/2];
show_buffer_word(buffer_word,20,1);
color_printf ( i+4, 6*j+4, color,"%4.4X", buffer_word);
//color_printf ( i+4, j + 55, B_BLUE+F_WHITE, "%c", buffer_byte);
}
else{
color_printf ( i+4, 6*j+4, color,"%4.4X", pmem.pw[i*8+j]);
//color_printf ( i+4, j + 55, B_BLUE+F_WHITE, "%c", pmem.pb[i*16+j]);
}
}
}
if(showtype == 4){
for ( j =0 ; j<4; j++){
if( pmem.pd[i*4+j] == 0xFFFFFFFF)
color = B_BLUE + F_LIGHT_WHITE;
else if( pmem.pd[i*4+j] == 0x00000000)
color = B_BLUE + F_GRAY;
else
color = B_BLUE + F_YELLOW;
if( index/4 == i*4+j){
color = color & 0x0F | B_LIGHT_RED;
if(enterpress)
buffer_dword = pmem.pd[index/4];
show_buffer_dword(buffer_dword,20,1);
color_printf ( i+4, 12*j+4, color,"%8.8X", buffer_dword);
//color_printf ( i+4, j + 55, B_BLUE+F_WHITE, "%c", buffer_byte);
}
else{
color_printf ( i+4, 12*j+4, color,"%8.8X", pmem.pd[i*4+j]);
//color_printf ( i+4, j + 55, B_BLUE+F_WHITE, "%c", pmem.pb[i*16+j]);
}
}
}
}
// check keyboard input.
keys = check_keys_input(&keycode);
//color_printf(23, 70, B_BLUE+F_YELLOW,"%X",keycode);
// keys is number.
if( keys & 0x01){
enterpress = 0;
if(index == -1)
memaddr = (memaddr << 4) | ascii_to_hexdigit(keycode);
if(index>=0&& index<0x100){
if(showtype == 1)
buffer_byte = (buffer_byte << 4) | ascii_to_hexdigit(keycode);
没有合适的资源?快使用搜索试试~ 我知道了~
BIOS入门之我见-内存
共27个文件
c:5个
obj:5个
h:4个
需积分: 34 7 下载量 109 浏览量
2016-04-27
22:31:49
上传
评论 1
收藏 77KB ZIP 举报
温馨提示
配合博文 BIOS之我见-内存 文章, 实现DOS下4G内存的访问,查询,搜索,E820 功能。 继续完善中。
资源推荐
资源详情
资源评论
收起资源包目录
6内存.zip (27个子文件)
6
keys.err 68B
xu.tgt 1KB
mem.obj 14KB
e820.h 18B
xu.map 13KB
xu.sym 19KB
mem.err 387B
keys.h 1KB
display.h 3KB
e820.c 5KB
xu.c~ 2KB
xu.obj 4KB
keys.c 982B
xu.exe 57KB
xu.err 67B
keys.obj 2KB
mem.h 565B
xu.lk1 52B
mem.c 16KB
display.c 4KB
xu.mk 87B
display.obj 9KB
e820.obj 5KB
xu.mk1 1KB
xu.c 5KB
e820.err 189B
xu.wpj 228B
共 27 条
- 1
资源评论
kevinhugh163
- 粉丝: 93
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功