Questions About Dos Eques
I have some assembly code that reads 4 bytes from a file and stores them on the stack and then displays those 4 bytes to stdout, the code works fine but when i use gdb to see what the code is doing, and trying to find thoses 4 bytes on the stack i cant find them..
(gdb) p $esp $1 = (void *) 0xbffff6bc (gdb) x/4 $esp 0xbffff6bc: 0 1 0 -1073743777
the first 4 bytes of the file are:
cat nummers.txt|od -c 0000000 3 \n 1 \n 2 \n 3 \n 0000010
%macro write 2 mov eax,4 ; write syscall mov ebx,STDOUT ; stdout mov edx,%2 ; number of bytes mov ecx,%1 ; buffer int 80h ; call kernel %endmacro section .data file
I created a batch file that searches for the users desktop folder in Windows.
for /F "skip=2 tokens=3* delims= " %%a in ('reg query "HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\User Shell Folders" /v Desktop') do set DESKTOP=%%a
If my desktop folder isn't in
C:\Users\User\Desktop, it will work and return the correct folder, for example in my case
E:\User\Desktop. If the desktop folder is in
C:\Users\User\Desktop, the script above will result into
%USERPROFILE%\Desktop. Later in the script I try to create a new file on desktop. In the first option it will work, because
E:\User\Desktop is a real directory. In the second one it won't because obviously
%USERPROFILE%\Desktop doesn't count as a directory.
echo start javaw -jar "path/to/program.jar" >"%DESKTOP%\Start program.bat"
How to get it work on both situations?<
I'm trying to write Hello World in GNU assembler for Mac OS X, but it's bus erroring before it can print "Hello World".
.global start .data .equ stdout, 1 .equ sys_write, 4 .equ sys_exit, 1 .equ kernel, 0x80 msg: .asciz "Hello World!\n" .equ len, .-msg .text start: push $len push $msg push $stdout mov $sys_write, %eax sub $4, %esp int $kernel add $4 + $4 * $3, %esp push $0 mov $sys_exit, %eax sub $4, %esp int $kernel
$ clang -c -o hello.o hello.s $ ld -o hello -macosx_version_min 10.6 hello.o $ ./hello Bus error: 10 $ gdb hello (gdb) run Starting program: /Users/andrew/Desktop/src/mcandre/gas/hello/freebsd/hello Program received signal EXC_BAD_ACCESS, Could not access memory. Reason: KERN_PROTECTION_FAILURE at address: 0x0000000000002000 0x0000000000002000