A simple bootstrap

                                                A simple bootstrap
                                                                    -----2004.11.1 (C) Gr1x
To make a long story short,and enough material can be found about the PC's POST procedure, I'll just show my code and explain sth important steps,I think my source code is self-explaining enough 'cause it's short and easy to understand . I have tested it with a floppy disk,  it's risky to test it with ur harddrive. If  u did do it,I  am not responsible for any damage u made : )
Environment :(Window Platform)
     a.VMWare(Optional).If u don't want to reboot ur system many times,u should get this.
     b: Nasm.(Essential). As u need it to compile ur code . u may use Ndisasm as well to disassemble the plain binary code compiled.
    c:Visual C++ 6 or Visual Stdio .Net. As we have to write a EXE to write the bootstrap to floppy.
       U may use WinHex to write bootstrap to floppy too instead of this writing a programme.
1>Write the bootstrap procedure
----------------------------bootstrap.asm-------------------------------------------------
;***************************************************
;                     bootstrap.asm: 2004-11-1 (C) Gr1x
;                     Email:gr1x@sina.com
;****************************************************
[ORG 0]
     jmp 07C0h:start                ; remember that BIOS loads this procedure in  0:7C00h,but don't count on registers like DS
                                             ;was initialized to 0. So we jump to it ourself.
    msg db 'Hello Gr1x!',0x0
start:
    ; Update the segment registers
     mov ax,cs
     mov ds,ax
     mov es,ax
     mov si,msg ; Print msg
print:
     lodsb ; loads charater at 0x7C0h:msg
     mov ah,0eh ; 
     int 10h
     cmp al,0 ;
     jne print ; 
     jmp $
     times 510-($-$$) db 0
     dw 0000h        ;or dw 0AA55h,u can write anything here,it seems that BIOS doesn't check this 2 bytes when 
                            ; it try to boot from a floppy disk
-----------------------------------------------------------------------------------------------------
OK,now compile it:
        >nasm bootstrap.asm -o bootstrap.bin
2.Now,copy this bootstrap to floppy's boot sector. If u do it with WinHex,u can omit following.
   I wrote a program which do this action.
------------------------------write_fd.cpp----------------------------------------------
//*********************************************
//              write_fd.cpp: 2004-11-1 (C) Gr1x
//               Email:gr1x@sian.com
//***********************************************

#include <windows.h>
#include <winioctl.h>
#include <stdio.h>
#pragma comment(linker,"/subsystem:console" )
void Banner()
{
 printf("---------------------------------------------/n");
 printf("  write_fd:write a file to floppy in raw mode/n");
 printf("  author:gr1x              email:gr1x@sian.com/n");
 printf("  usage:write_fd filename/n");
 printf("---------------------------------------------/n);
}

int main(int argc,char **argv)
{
 HANDLE                  hDevice=NULL,hFile=NULL;
 TCHAR                   szDevicename[64];
 LPTSTR                  szBuff=NULL;
 DISK_GEOMETRY           Geometry;
 BOOL                    bRet;
 DWORD                   bytes,bread,count;
 Banner();
 if(argc!=2)
 {
  printf("Usage:%s filename/n",*argv);
  exit(0);
 }
 __try
 {
  hFile=CreateFile(argv[1],GENERIC_READ,FILE_SHARE_READ,NULL,OPEN_EXISTING,NULL);
  if (hDevice == INVALID_HANDLE_VALUE)
  {
   printf("Error in open file %s!/n",argv[1]);
   __leave;
  }
  wsprintf(szDevicename,"////.//a:");
  hDevice = CreateFile( szDevicename,
   GENERIC_READ|GENERIC_WRITE,
   FILE_SHARE_READ|FILE_SHARE_WRITE,
   NULL,
   OPEN_EXISTING,
   0,
   NULL
   );

  if (hDevice == INVALID_HANDLE_VALUE)
  {
   printf("Error in open floppy device!");
   __leave;
  }

  DeviceIoControl(hDevice,FSCTL_LOCK_VOLUME,&count,NULL);   DeviceIoControl(hDevice,IOCTL_DISK_GET_DRIVE_GEOMETRY,&Geometry,sizeof(DISK_GEOMETRY),NULL);   szBuff = (LPSTR)HeapAlloc(GetProcessHeap(),HEAP_ZERO_MEMORY,Geometry.BytesPerSector*2);   if ( szBuff == NULL)  {   printf("Error in HeapAlloc!");   __leave;  }   bytes = 512*2;   bRet = ReadFile(hFile,szBuff,bytes,&bread,NULL);   if (bRet==FALSE || bread<512)  {   printf("Error in read file!");   __leave;  }   printf("%d bytes read from %s/n",argv[1]);  bRet=WriteFile(hDevice,NULL);  if (bRet==FALSE || bread<512)  {   printf("Error in write file to floppy!");   __leave;  }   if(!DeviceIoControl(hDevice,FSCTL_UNLOCK_VOLUME,NULL))   printf("DeviceIoControl(hDevice,NULL) error!/n");  DeviceIoControl(hDevice,NULL);   printf("Write finished!/nBoot sector in HEX:/n");  for(int j=0,int i=0; i<512; i++)  {   unsigned char ch=(unsigned char) szBuff[i];   if (j==8) printf(" -");   if (j==16)   {    printf("/n");    j=0;   }   j++;   if (ch<0x10) printf(" %2x",ch);   else printf(" %2x",ch);  }  printf("/n"); } __finally {  if(szBuff!=NULL)   HeapFree(GetProcessHeap(),HEAP_NO_SERIALIZE,szBuff);  if(hDevice!=NULL)   CloseHandle(hDevice);  if(hFile!=NULL)   CloseHandle(hFile); } return 0;}--------------------------------------------------------------------------------------------Don't ask me how to compile this cpp file!3>Type following commad in CMD    >write_fd bootstrap.bin4>OK,boot ur system with the floppy.God bless u!

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


前端工程师一般用的是Bootstrap的框架而不是样式,样式一般自己重新定义class类即可,主要样式要随具体情况而定包括位置任何带有class.btn的元素都会继承圆角灰色按钮的默认外观。但是Bootstrap提供了一些选项来定义按钮的样式。<buttontype="button"class="btn">基本
起步导入:<linkrel="stylesheet"href="bootstrap-3.3.7-dist/css/bootstrap.css"><scriptsrc="js/jquery-3.3.1.js"></script><scriptsrc="bootstrap-3.3.7-dist/js/bootstrap.js"></script>屏幕
(1)modal声明一个模态框(2)modal-dialog定义模态框尺寸(3)modal-lg定义大尺寸模态框(4)modal-sm定义小尺寸模态框(5)modal-header(6)modal-body(7)modal-footer<!doctypehtml><html><head><metacharset="utf-8"><title>模态框<itle><linkrel=&quo
图片在Bootstrap版本3中,通过为图片添加 .img-responsive 类可以让图片支持响应式布局。其实质是为图片设置了 max-width:100%;、 height:auto; 和 display:block; 属性,从而让图片在其父元素中更好的缩放。如果需要让使用了 .img-responsive 类的图片水平居
<inputtype="text"class="form-controldatepicker"style="padding:0.375rem0.75rem;"placeholder="开始时间"readonly="true" id="start_time"name="start_time"> $(".datepicke
目录bootstrap-treeview使用小记零、写在前面的话一、功能说明二、特性简述三、实战3.1依赖环境3.2数据源格式3.3Options选项3.4Methods方法3.5Events事件N-2、番外N-1、本文demoN、参考资料bootstrap-treeview使用小记零、写在前面的话p.s.bootst
  一、应用http://www.bootcss.com/进入bootstrap4或bootstrap3中文网,想要快速地将Bootstrap应用到你的项目中,有以下两种办法: 1、bootstrap可以在线引用,方法如下:A、CSS将引入Bootstrap样式表的 <link> 标签复制并粘贴到 <head> 中,并放在所有其他样式表之前。<!
第87节:Java中的Bootstrap基础与SQL入门前言复习什么是JQ?:writelessdomore写更少的代码,做更多的事找出所有兄弟:$("div").siblings()基本过滤器:选择器:过滤器$("div:first"):first:找到第一个元素:last:找到最后一个元素:even:找出偶数索引:odd:找出奇叔索引
1.bootstrap表单(1)form声明一个表单域(2)form-inline内联表单域(3)form-horizontal水平排列表单域(4)form-group表单组、包括表单文字和表单控件(5)form-control文本输入框、下拉列表控件样式(6)checkboxcheck-inline多选框样式(7)radioradio-inline单选框样式(8)input-group表单控件组
<!DOCTYPEhtml><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width,initial-scale=1.0"><title>首页<itle><
嗯。。。以前做ssh。应该是stratusspringhibernate。 然后现在来了一个新的需求。 要用java,bootstrap,oracle,springboot,jquery,mybatis。 开始,我也挺心虚的,但是后来一看,,,其实本没有必要这么虚。。。毕竟。。。这些东西,写的有问题。。。问题在于没有逻辑。 bootstrap,j
表格基本实例为任意 <table> 标签添加 .table 类可以为其赋予基本的样式—少量的内补(padding)和水平方向的分隔线。这种方式看起来很多余!?但是我们觉得,表格元素使用的很广泛,如果我们为其赋予默认样式可能会影响例如日历和日期选择之类的插件,所以我们选择将此样式独立出来。
1、问题背景   一般情况下,查询列表有查询条件、查询按钮和重置按钮,输入查询条件,点击查询按钮查询列表等数据;点击重置按钮会将查询条件恢复到原始状态 2、实现源码 <!DOCTYPEhtml><html> <head> <metacharset="UTF-8"> <title>Bootstrap-查询按钮和重置按钮<
Bootstrap简介什么是Bootstrap?Bootstrap官网框架:库liblibraryjQuery作为一个框架来讲,提供一套比较便捷的操作DOM的方式把大家都需要的功能预先写好到一些文件这就是一个框架Bootstrap让我们的Web开发更简单,更快捷;注意是Bootstrap不是BootStrap!这是一个词,不是
1.bootstrap图片img-responsive声明响应式图片2.bootstrap字体图标通过字体代替图标,font文件夹需要和css文件夹在同一目录3.bootst导航条(1)navbar声明导航条(2)navbar-default声明默认的导航条样式(3)navbar-inverse声明反白的导航条样式(4)navbar-static-top去掉导航条的圆角(5)n
1.路径导航<!doctypehtml><html><head><metacharset="utf-8"><title>路径导航<itle><linkrel="stylesheet"type="text/css"href="css/bootstrap.min.css"><scripttype="text/ja
问题描述:最近在学习BootStrap,过程中遇到引用glyphicon图标无法显示的问题,经过在百度后该问题已解决。1、首先看一下图标显示失败的页面:2、经过参考大佬们的经验,我找到了解决办法。首先我的BootStrap的css样式表是经过下载之后直接拷贝了其中一个文件到编译器中使用的,没有把所有
BootStrap布局一、BootStrap布局CSS组件主要包括栅格系统、列表组、进度条、icon图标、导航栏等组件。JavaScript插件主要有动画效果、窗体模式、下拉菜单、选项卡等二、网格系统Bootstrap内置了一套响应式、移动优先的流式栅格系统,随着屏幕设备或可视窗口(viewport)尺寸的
1引入所需要的文件2用法
想让bootstrap的table列内容超出部分省略号,要在table上加table-layout:fixed和word-break:break-all,然后在头部thead的th加上宽度百分比,最后在列里加个标签如span,在这个span加上单行超出部分省略号的css:display:inline-block,overflow:hidden,white-space:nowrap,text-overflow:e