exe文件的内部结构

http://www.nondot.org/sabre/os/files/Executables/EXE.txt
offset  length  description                             comments
----------------------------------------------------------------------
0       word    exe file signature                      usually 4d5a
2       word    length of last used sector in file      modulo 512
4       word    size of file, incl. header              in 512-pages
6       word    number of relocation table items
8       word    size of header                          in 16-byte paragraphs
a       word    min. paragraphs needed above program    in 16-byte paragraphs
c       word    max. paragraphs needen above program    in 16-byte paragraphs
e       word    displacement of stack segment in module rel. to start of prog.
10      word    contents of SP reg. at entry
12      word    checksum                                2's complement
14      word    contents of IP reg. at entry
16      word    displacement of code module             rel. to start of prog.
18      word    offset to first relocation item in file rel. to start of prog.
1a      word    overlay number                          0 for resident prog.
1c      varies  variable RESERVED place
varies  varies  relocation table
varies  varies  variable RESERVED place
varies  varies  program and data space
varies  varies  stack segment

The relocation table is a set of far pointers (eg: 1234:5678h) and it appears
you just add the relocation factor to the value at that address. The relocation
factor is the start segment of where the program is loaded.

Example:
------------------------------------------------
code segment
start:
        mov     ax,seg _myseg
code ends

_myseg segment
_myseg ends
end start
-------------------------------------------------

 Start  Stop   Length Name               Class

 00000H 00002H 00003H CODE
 00010H 00010H 00000H _MYSEG

-------------------------------------------------

Note that _MYSEG is exactly one segment above CODE.

Generated output is B8 01 00; which is "mov ax,0001"

The fixup table for this file has a single entry, 0000:0001. Thus if the start
of the program begins at segment 3562 then the "mov ax,0001" gets converted to
"mov ax,3563".
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
拼图 原创 游戏 using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace WindowsFormsApplication1 { public partial class Form1 : Form { Random r = new Random();//随机种子 Point pi = new Point();//出界返回 Point[] pt = new Point[8];//判断胜负 string[] st = new string[8];//判断胜负 public Form1() { InitializeComponent(); } private void Form1_Load(object sender, EventArgs e) { pictureBox1.Left -= 800; tianjia(); panduan(); } void tianjia()//添加图片 { string si;//获取坐标 int i = 7;//图片数量 int n = 0;//变量 string[] s = { "000000", "000100", "000200", "100000", "100100", "100200", "200000", "200100"}; ComboBox cb = new ComboBox(); ComboBox cc = new ComboBox(); cb.Items.AddRange(s);//确定坐标 cc.Items.AddRange(s);//确定图像 for (n = 0; n < 8; n++) { PictureBox p = new PictureBox();//创建拼图 p.Name = "i" + i; p.Size = new Size(100, 100); p.BackColor = Color.Red; si = cb.Items[r.Next(0,i)].ToString();//打乱拼图坐标 p.Location = new Point(Convert.ToInt32(si) / 1000, Convert.ToInt32(si) % 1000); cb.Items.Remove(si); Bitmap bit = new Bitmap(99, 99);//给拼图添加背景图片 Graphics g = Graphics.FromImage(bit); g.DrawImageUnscaled(pictureBox1.Image, -Convert.ToInt32(cc.Items[i]) / 1000, -Convert.ToInt32(cc.Items[i]) % 1000); p.Image = bit; Controls.Add(p);//把拼图画到窗体上 pt[n] = new Point(Convert.ToInt32(cc.Items[i]) / 1000, Convert.ToInt32(cc.Items[i]) % 1000); st[n] = p.Name; i--; } } private void Form1_KeyPress(object sender, KeyPressEventArgs e) { pi = pictureBox2.Location; string key = e.KeyChar.ToString(); switch (key)//图片移动 { case "w": pictureBox2 .Top -= 100; break; case "s": pictureBox2.Top += 100; break; case "a": pictureBox2.Left -= 100; break; case "d": pictureBox2.Left += 100; break; } if (pictureBox2.Location.X < 0 || pictureBox2.Location.X > 200 || pictureBox2.Location.Y < 0 || pictureBox2.Location.Y > 200) pictureBox2.Location = pi;//判断出界 foreach (Control i in Controls)//反向移动 if (i.Location == pictureBox2.Location&&i.Name!="pictureBox2") { switch (key) { case "w": i.Top += 100; break; case "s": i.Top -= 100; break; case "a": i.Left += 100; break; case "d": i.Left -= 100; break; } } panduan(); } void panduan() { int ai = 0; for (int n = 0; n < 8; n++) foreach (Control i in Controls) if (i.Name == st[n] && i.Location == pt[n]) ai++; label1.Text = ai.ToString(); if (ai == 8) { MessageBox.Show("恭喜你,通关了"); Close(); } } private void button1_Click(object sender, EventArgs e) { if (pictureBox1.Location.X == -800) pictureBox1.Left += 800; else pictureBox1.Left -= 800; } } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值