- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
另一个切换到 32 位保护模式的问题。我目前正在编写一个安全操作系统(仅文本)并研究了有关切换模式的教程,但要么我遗漏了某些内容,要么列出的代码没有所有详细信息。我有一个简单的引导加载程序,它加载这段代码然后运行它。然后这段代码将加载内核并可能切换到 64 位长模式。 mov cr0, eax 行的代码错误。我现在真的很困惑,所以真的很感激有人看一看。如果有帮助,我在 VirtualBox 中将其作为 VM 运行,在调试器中它会出现“u32: error: DBGCCmdHlpVarToDbgfAddr failed on '0000:00009362 L a': VERR_INVALID_SELECTOR”错误,当我尝试拆开。该代码的某些部分是从其他人那里借来的,因此我已尽力承认这一点。
;;
;; enableA20.s (adapted from Visopsys OS-loader)
;;
;; Copyright (c) 2000, J. Andrew McLaughlin
;; You're free to use this code in any manner you like, as long as this
;; notice is included (and you give credit where it is due), and as long
;; as you understand and accept that it comes with NO WARRANTY OF ANY KIND.
;; Contact me at jamesamc@yahoo.com about any bugs or problems.
;;
org 0x9210
enableA20:
;; This subroutine will enable the A20 address line in the keyboard
;; controller. Takes no arguments. Returns 0 in EAX on success,
;; -1 on failure. Written for use in 16-bit code, see lines marked
;; with 32-BIT for use in 32-bit code.u 9210
[BITS 16]
mov bx,jumper
call prstr
pusha
;; Make sure interrupts are disabled
cli
;; Keep a counter so that we can make up to 5 attempts to turn
;; on A20 if necessary
mov CX, 5
.startAttempt1:
;; Wait for the controller to be ready for a command
.commandWait1:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait1
;; Tell the controller we want to read the current status.
;; Send the command D0h: read output port.
mov AL, 0D0h
out 64h, AL
;; Wait for the controller to be ready with a byte of data
.dataWait1:
xor AX, AX
in AL, 64h
bt AX, 0
jnc .dataWait1
;; Read the current port status from port 60h
xor AX, AX
in AL, 60h
;; Save the current value of (E)AX
push AX ; 16-BIT
;; push EAX ; 32-BIT
;; Wait for the controller to be ready for a command
.commandWait2:
in AL, 64h
bt AX, 1
jc .commandWait2
;; Tell the controller we want to write the status byte again
mov AL, 0D1h
out 64h, AL
;; Wait for the controller to be ready for the data
.commandWait3:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait3
;; Write the new value to port 60h. Remember we saved the old
;; value on the stack
pop AX ; 16-BIT
;; pop EAX ; 32-BIT
;; Turn on the A20 enable bit
or AL, 00000010b
out 60h, AL
;; Finally, we will attempt to read back the A20 status
;; to ensure it was enabled.
;; Wait for the controller to be ready for a command
.commandWait4:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait4
;; Send the command D0h: read output port.
mov AL, 0D0h
out 64h, AL
;; Wait for the controller to be ready with a byte of data
.dataWait2:
xor AX, AX
in AL, 64h
bt AX, 0
jnc .dataWait2
;; Read the current port status from port 60h
xor AX, AX
in AL, 60h
;; Is A20 enabled?
bt AX, 1
;; Check the result. If carry is on, A20 is on.
jc .success
;; Should we retry the operation? If the counter value in ECX
;; has not reached zero, we will retry
loop .startAttempt1
;; Well, our initial attempt to set A20 has failed. Now we will
;; try a backup method (which is supposedly not supported on many
;; chipsets, but which seems to be the only method that works on
;; other chipsets).
;; Keep a counter so that we can make up to 5 attempts to turn
;; on A20 if necessary
mov CX, 5
.startAttempt2:
;; Wait for the keyboard to be ready for another command
.commandWait6:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait6
;; Tell the controller we want to turn on A20
mov AL, 0DFh
out 64h, AL
;; Again, we will attempt to read back the A20 status
;; to ensure it was enabled.
;; Wait for the controller to be ready for a command
.commandWait7:
xor AX, AX
in AL, 64h
bt AX, 1
jc .commandWait7
;; Send the command D0h: read output port.
mov AL, 0D0h
out 64h, AL
;; Wait for the controller to be ready with a byte of data
.dataWait3:
xor AX, AX
in AL, 64h
bt AX, 0
jnc .dataWait3
;; Read the current port status from port 60h
xor AX, AX
in AL, 60h
;; Is A20 enabled?
bt AX, 1
;; Check the result. If carry is on, A20 is on, but we might warn
;; that we had to use this alternate method
jc .warn
;; Should we retry the operation? If the counter value in ECX
;; has not reached zero, we will retry
loop .startAttempt2
;; OK, we weren't able to set the A20 address line. Do you want
;; to put an error message here?
jmp .fail
.warn:
;; Here you may or may not want to print a warning message about
;; the fact that we had to use the nonstandard alternate enabling
;; method
mov bx,a20alt
call prstr
.success:
sti
popa
xor AX, AX
mov bx,a20norm
call prstr
jmp loader
.fail:
sti
popa
mov AX, -1
mov bx,a20err
call prstr
hlt
ret
;
; Prints string to screen
;
prstr:
push bx
mov ah,0x0E
ploop:
mov al,[bx] ;load byte of string
cmp al,0 ;if al=0 then string has ended so return
jz fin
mov bh,0
mov bl,7
int 0x10 ;print chr in string
pop bx
inc bx
push bx
jmp ploop ;back to print next chr
fin:
pop bx ;get bx off stack
ret
section .data
a20err: db 13,10,13,10,"A20 initialisation failed, halting",0
a20alt: db 13,10,13,10,"Alternate A20 switch",0
a20norm: db 13,10,13,10,"Normal A20 switch",0
jumper: db 13,10,13,10,"Jumped to code",0
loader:
;
;jump to 32bit mode next
;
;32 bit mode code and gdt with help from Broken Thorn Website
;OS tutorial by Mike
;
cli ; clear interrupts
xor ax,ax
mov ds,ax
[BITS 32]
lgdt [toc] ; load GDT into GDTR
mov eax, cr0 ; set bit 0 in cr0--enter pmode
or eax, 1
mov cr0, eax
jmp $
mov ax, DATA_SEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 0x090000 ; Set stack to grown downwards from 0x30000
jmp 0x08:clear_prefetch
nop
nop
clear_prefetch:
;;mov ax,cs ;
;;push ax ;
;;mov eax,Really32 ;
;;push eax ;
;;retf ;
jmp 0x08:Really32
Really32:
;
;test 32 bit mode
;
mov eax,0xb8000
mov word [Eax],0x41
jmp $
;
;GDT table
; Offset 0 in GDT: Descriptor code=0
;
;First 1gb for code and then the rest for Data
;
gdt_data:
dd 0 ; null descriptor
dd 0
; Offset 0x8 bytes from start of GDT: Descriptor code therfore is 8
; gdt code: ; code descriptor
gdt_code:
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10011010b ; access
db 11001111b ; granularity = Limit = 2GB-1
db 00 ; base high = Base =1GB
; Offset 16 bytes (0x10) from start of GDT. Descriptor code therfore is 0x10.
; gdt data: ; data descriptor
gdt_dat:
dw 0FFFFh ; limit low
dw 0 ; base low
db 0 ; base middle
db 10010010b ; access
db 11001111b ; granularity = limit=rest of memry for data
db 00 ; base high
;...Other descriptors begin at offset 0x18. Remember that each descriptor is 8 bytes in size?
; Add other descriptors for Ring 3 applications, stack, whatever here...
end_of_gdt:
toc:
dw end_of_gdt - gdt_data ; limit (Size of GDT)
dd gdt_data ; base of GDT
CODE_SEG equ gdt_code - gdt_data
DATA_SEG equ gdt_dat - gdt_data
最后几行代码应该将“A”写入屏幕。问候
比普曼
最佳答案
感谢玛格丽特,我得到了移动 [BITS 32] 的答案,并且还生成了一系列字节的远跳转,而不是使用 32 位远跳转,这当然是行不通的。希望 64 位长模式不会这么困惑!代码如下。
lgdt [toc] ; load GDT into GDTR
mov eax, cr0 ; set bit 0 in cr0--enter pmode
or eax, 1
mov cr0, eax
jmp clear_prefetch
nop
nop
clear_prefetch:
mov ax, DATA_SEG
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
mov ss, ax
mov esp, 0x090000 ; Set stack to grown downwards from 0x30000
;;mov ax,cs ;
;;push ax ;
;;mov eax,Really32 ;
;;push eax ;
;;retf ;
db 0x66
db 0xEA
dd Really32
dw 0x0008
Really32:
;
;test 32 bit mode
;
[BITS 32]
mov eax,0xb8000
mov word [Eax],0x4141
jmp $
关于assembly - X86 切换到 32 位保护模式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42781333/
我知道这有点愚蠢,但我需要保护 javascript,从某种意义上说,我希望增加尽可能多的安全性,以免它被盗版。好吧,因为它是系统的核心组件。我打算用YUI compressor来压缩混淆。 但我还想
因此,当我的宏运行时,我有这些简单的子程序可以解除保护而不是保护东西,唯一的问题是我的一些工作表实际上是图表,并且在调用这些子程序时它们没有得到保护。如何更改我的代码以合并图表?谢谢! Sub Unp
有很多关于 preventing CSRF 的文章. 但我就是不明白:为什么我不能只解析目标页面表单中的 csrf token 并将其与我的伪造请求一起提交? 最佳答案 如果您能够将脚本代码注入(in
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 9年前关闭。 Improve this q
我正在使用一个包含用于docker创建的敏感信息的env文件。 但问题是它们并不安全。可以通过docker inspect轻松查看它们,因此,任何可以运行docker命令的用户都可以使用它们。 我正在
NSA在此处提供了保护.NET框架2.0版的指南:http://www.nsa.gov/ia/_files/app/I731-008R-2006.pdf 我想知道他们是否提供更高版本的指南,例如版本3
我编写了一个 Java 应用程序,并计划在线发布它。每个版本都将使用我制作的 secret 序列 key 锁定。 我需要从反编译器等保护我的 jar 文件。这是我到目前为止所做的: 用户在表格中输入他
我不知道为什么这不起作用。如果 ?Session=2 不是您发出的,那么您将返回您的帐户。 这是我的代码: query("SELECT * FROM user_host WHERE uid = '"
我是 elasticsearch 的新手,但我非常喜欢它。我唯一找不到也无法完成的是保护生产系统的 Elasticsearch 。我读了很多关于在 elasticsearch 前使用 nginx 作为
假设我有以下头文件: #ifndef TESTCLASS_H #define TESTCLASS_H #include class TestClass { public: TestClass
在 C++ 中,我有一个基类 A,一个子类 B。两者都有虚方法 Visit。我想在 B 中重新定义“访问”,但 B 需要访问每个 A(以及所有子类)的“访问”功能。 我有类似的东西,但它告诉我 B 无
我目前正在使用 Apache FOP 库生成 PDF。我希望这些 PDF 免受复制粘贴,因此人们必须使用实际的 OCR 库(或手动输入)来获取 PDF 上的信息。 FOP 显然提供了一些安全性,然后将
我有一个使用 JSONP 进行跨域 ajax 调用的脚本。这很好用,但我的问题是,有没有办法阻止其他站点访问这些 URL 并从中获取数据?我基本上想制作一个允许的站点列表,并且只返回列表中的数据。我正
我在基于 Html/Javascript 构建的 Web 应用程序上使用了一些全局变量。我跨页面(或部分页面)使用这些变量,有时它们用作 ajax 调用的发布数据。我的问题是:这有多安全?当然,我可以
我有一个扩展到多个类文件的大项目。这个项目是在赶时间前匆忙完成的。这对项目安全造成了影响。所以简单来说,理论上任何人都可以在我的项目中调用一个 AJAX 脚本并让它运行,因为脚本中的函数不是用户权限感
相当多的人对 ivé 发送给他们的 dll 真正感兴趣,他们不是那种应该经常免费赠送的类型... 我只是想知道,如果我要出售我的组件、用户控件等,我将如何在所有权/加密代码(如果可能)等方面保护它们。
我正在开发一个 PHP 库,我们将在其中为客户提供加密代码。该代码将包括一个他们可以实例化的主要类,该类将处理许可证验证并公开其使用方法。主类将实例化几个子类,每个子类都包含在自己的文件中。我怎样才能
我有一个以 VUEJS 作为前端的 Laravel 应用程序,我通过创建 API 路由获取数据。因此,例如获取帖子数据的路线将是 http://localhost/api/posts 保护路线的最佳方
在许多网页上,我们都包含外部脚本。无论是类似于 Facebook 的按钮、用于分析或广告系统的客户端代码、外部评论提供商还是其他东西。 那些脚本无法访问我的 Ajax 资源,因为一直在检查原始 hea
我目前正在使用 PHP/MySQL 开发一个公开和开放源代码的软件。我在一个文件夹中有几个重要的 SECRET TXT 文件。我在软件中使用它们,但问题是它们也可以被任何知道文件夹和文件名的人读取:
我是一名优秀的程序员,十分优秀!