nasm

Should using MOV instruction to set SS to 0x0000 cause fault #GP(0) in 64-bit mode?

血红的双手。 提交于 2021-01-19 21:17:51
问题 This question is inspired by a Reddit question in r/osdev except that this question focuses on the SS register. One may say RTFM (ISA entry for MOV), but when this question comes up it can get varying answers even among OS developers. Question : Should using the MOV instruction to set SS to 0x0000 cause a general protection fault #GP(0) in 64-bit mode? For example: If I am in 64-bit mode with a Current Privilege level (CPL) of 0, should I expect to see a #GP(0) with this code snippet: NULL

NASM: How to create/handle basic bmp file using intel 64 bit assembly?

Deadly 提交于 2021-01-07 10:41:22
问题 How do I create/handle simple bmp file filling it with one color only using intel 64 bit assembly and nasm assembler? 回答1: The steps that include such operation are: Create bmp file header with fixed values (explanation of specific fields below) Create buffer which contains enough space - three bytes per pixel (one color = red + green + blue) Open/create file Fill the buffer Write header to file Write buffer to file Close file Exit program Ad. 2: This is a bit more tricky - if the number of

NASM: How to create/handle basic bmp file using intel 64 bit assembly?

你离开我真会死。 提交于 2021-01-07 10:40:52
问题 How do I create/handle simple bmp file filling it with one color only using intel 64 bit assembly and nasm assembler? 回答1: The steps that include such operation are: Create bmp file header with fixed values (explanation of specific fields below) Create buffer which contains enough space - three bytes per pixel (one color = red + green + blue) Open/create file Fill the buffer Write header to file Write buffer to file Close file Exit program Ad. 2: This is a bit more tricky - if the number of

NASM: How to create/handle basic bmp file using intel 64 bit assembly?

前提是你 提交于 2021-01-07 10:40:17
问题 How do I create/handle simple bmp file filling it with one color only using intel 64 bit assembly and nasm assembler? 回答1: The steps that include such operation are: Create bmp file header with fixed values (explanation of specific fields below) Create buffer which contains enough space - three bytes per pixel (one color = red + green + blue) Open/create file Fill the buffer Write header to file Write buffer to file Close file Exit program Ad. 2: This is a bit more tricky - if the number of

execute system command (bash) using assembly?

霸气de小男生 提交于 2021-01-07 01:33:18
问题 Basically I am trying to execute the command /bin/ls using assembly, but unfortunately I am failing: SECTION .data buf: db "Hello", 5 SECTION .text global _start _start: xor eax, eax mov edx, eax push edx mov eax, 0x736c2f2f ; "sl/" push eax mov eax, 0x6e69622f ; "nib/" push eax mov ebx, esp push edx mov eax, 0x2f push eax mov ecx, esp mov eax, 11 xor edx, edx int 0x80 mov eax, 1 int 0x80 But If I change the mov eax, 11 to mov eax, 4 and add mov edx, 7 after xor edx, edx . It do print /bin/ls

execute system command (bash) using assembly?

被刻印的时光 ゝ 提交于 2021-01-07 01:32:17
问题 Basically I am trying to execute the command /bin/ls using assembly, but unfortunately I am failing: SECTION .data buf: db "Hello", 5 SECTION .text global _start _start: xor eax, eax mov edx, eax push edx mov eax, 0x736c2f2f ; "sl/" push eax mov eax, 0x6e69622f ; "nib/" push eax mov ebx, esp push edx mov eax, 0x2f push eax mov ecx, esp mov eax, 11 xor edx, edx int 0x80 mov eax, 1 int 0x80 But If I change the mov eax, 11 to mov eax, 4 and add mov edx, 7 after xor edx, edx . It do print /bin/ls

Image base comes out wrong in manually-generated PE headers for a 64-bit executable

谁都会走 提交于 2021-01-05 07:43:38
问题 I want to build Custom Portable executable using NASM. After getting executable using command nasm -f bin program.asm -o program.exe it crashes and gives error similar to this Below you can see the code. bits 64 %define BASE 400000h ALIGNMENT equ 512 %define SECTALIGN 8192 STD_OUTPUT_HANDLE equ -11 NULL equ 0 %define ROUND(v, a) (((v + a - 1) / a) * a) %define ALIGNED(v) (ROUND(v, ALIGNMENT)) %define RVA(obj) (obj - BASE) section header progbits start=0 vstart=BASE mz_hdr: dw "MZ" ; DOS magic

Image base comes out wrong in manually-generated PE headers for a 64-bit executable

家住魔仙堡 提交于 2021-01-05 07:40:51
问题 I want to build Custom Portable executable using NASM. After getting executable using command nasm -f bin program.asm -o program.exe it crashes and gives error similar to this Below you can see the code. bits 64 %define BASE 400000h ALIGNMENT equ 512 %define SECTALIGN 8192 STD_OUTPUT_HANDLE equ -11 NULL equ 0 %define ROUND(v, a) (((v + a - 1) / a) * a) %define ALIGNED(v) (ROUND(v, ALIGNMENT)) %define RVA(obj) (obj - BASE) section header progbits start=0 vstart=BASE mz_hdr: dw "MZ" ; DOS magic

Printing hex from dx with nasm

守給你的承諾、 提交于 2020-12-30 02:56:54
问题 I actually want to print the content of the dx register with nasm. Thereby the content is a 16 bit hex digit such as 0x12AB. Therefore I've first implemented a function which is able to print a string: print_string: pusha mov ah, 0xe print_character: mov al, [bx] inc bx or al, al jz print_done int 0x10 jmp print_character print_done: popa ret You can use this function in this way: mov bx, MSG call print_string MSG: db 'Test',0 Now i want to have a function, which converts the hex to a string,

Printing hex from dx with nasm

坚强是说给别人听的谎言 提交于 2020-12-30 02:56:52
问题 I actually want to print the content of the dx register with nasm. Thereby the content is a 16 bit hex digit such as 0x12AB. Therefore I've first implemented a function which is able to print a string: print_string: pusha mov ah, 0xe print_character: mov al, [bx] inc bx or al, al jz print_done int 0x10 jmp print_character print_done: popa ret You can use this function in this way: mov bx, MSG call print_string MSG: db 'Test',0 Now i want to have a function, which converts the hex to a string,