News for hackers. Stuff that matters.
Re:Ask HN: What's the best resource for learning modern x64 ... by anonsivalley652 on Saturday February 08, 2020 @09:08PM (#22279940)
There's no magic anywhere and 99.1% of it is documented.

IA-32e/AMD64 is basically an extension of IA-32/x86. What you're looking for is to understand the difference between real mode, 386 protected mode, PAE, paging and long mode because the registers, instructions, addressing and sizes of structures differ.

You can learn all of this by reading the Intel software manuals and digging into it yourself.

Tools you need (for non-Windows):

- gdb/lldb

- assemblers: yasm, nasm, binutils (contains "as")

Optional tools:

- IDA Pro

- Virtualization/emulation such as VMware Fusion/Workstation (because it supports being a gdbserver), VirtualBox or QEMU

- Intel's CPUID app

You also need good references like:

- the Intel manual set (a giant PDF or a collection of several) https://software.intel.com/en-us/articles/intel-sdm

- https://sandpile.org (fairly current)

- https://ref.x86asm.net (outdated by useful)

Another helpful exercise is writing a toy operating system in Rust or only assembly. https://osdev.org has many resources and guides.

Re:Ask HN: What's the best resource for learning modern x64 ... by Godel_unicode on Saturday February 08, 2020 @09:12PM (#22279952)
In addition to IDA, I highly recommend looking into ghidra. It's open source, so you can peak under the hood and see how it does things.

https://github.com/NationalSecurityAgency/ghidra

Re:Ask HN: What's the best resource for learning modern x64 ... by anonsivalley652 on Saturday February 08, 2020 @09:32PM (#22280016)
Yep. It's a FOSS-quality disassembler; good if you don't have IDA (I wish), supports maybe 10% of what IDA does in total but has some other niceities that it doesn't (think: disassembler-equivalent of LLVM). (Ideally, you'd have both.) For those who don't know, IDA disassembles basically every unclassified, commercially-available architecture and executable/library/object container format (think: disassembler-equivalent of GCC if it were an IBM or Green Hills product -:P). It also has a built-in scripting API in Python(?), IIRC.

An interesting semi-abandonware static disassembler that was really good is Sourcer 8.01 from V-Communications. I think it supports Pentium II/Pro/III at most, which would include real, protected mode and long mode DOS/DOS extended/Win16/Win32 EXEs and COMs IIRC. It did a lot of memory typing and clever analysis long before IDA existed, and still interesting for retro computing.

https://www.vetusware.com/download/Sourcer%208.01%208.01/?id...

Re:Ask HN: What's the best resource for learning modern x64 ... by Godel_unicode on Sunday February 09, 2020 @02:39AM (#22280920)
You might be interested in this talk from the creator of IDA, Ilfak Guilfanov, explaining how he used Sourcer and it's shortcomings lead directly to him creating IDA.

https://m.youtube.com/watch?v=hLBlck1lTUs

Re:Ask HN: What's the best resource for learning modern x64 ... by zelly on Sunday February 09, 2020 @12:48AM (#22280603)
It's way better than IDA Pro. I have used the Pro version with the Hex-Rays decompiler. Ghidra is legitimately better. I wouldn't recommend IDA to anyone at this point because I don't see it having much of a future (sorry not sorry).

It's worth learning the Ghidra Scripting API because you can write ad-hoc scripts with Jython syntax to automate tasks/do custom analysis.

Re:Ask HN: What's the best resource for learning modern x64 ... by ackbar03 on Sunday February 09, 2020 @02:53AM (#22280956)
I was using ghidra for one of my uhh research projects earlier and I actually found the decompiler from hex rays still does better in some cases. In ghidra sometimes it times out and fails to decompile. Maybe I'm not using it correctly? I haven't begun exploring what kind of plug-ins and stuff it has, maybe that helps?
Re:Ask HN: What's the best resource for learning modern x64 ... by gallexme on Sunday February 09, 2020 @05:24AM (#22281391)
For me ghidra is better with c++ disassembling than hex ray, but hex ray is better with c style assemblies

Thanks to the better RTTI Analyzer

Re:Ask HN: What's the best resource for learning modern x64 ... by zelly on Sunday February 09, 2020 @04:12PM (#22284339)
It depends massively on platform, architecture, and programming language. Hex-Rays is probably still ideal for embedded and obscure platforms. Ghidra's decompiler seems optimized for ARM and amd64 userland consumer-level stuff that the NSA was most interested in hacking.
Re:Ask HN: What's the best resource for learning modern x64 ... by chrisseaton on Saturday February 08, 2020 @10:18PM (#22280184)
> IA-32e

I’ve never seen this name before. Where does it come from?

AMD call it AMD64. Intel call it Intel 64.

Why do we need even more names for the same thing beyond these two?!

x86_64, x86-64, x64, AMD64, amd64, Intel 64, EM64T, all mean the same thing!

Re:Ask HN: What's the best resource for learning modern x64 ... by lizknope on Sunday February 09, 2020 @06:49AM (#22281660)
It's an older reference but it checks out.

When Intel was developing Itanium they named the new architecture IA-64 and retroactively named their 32-bit x86 line IA-32.

After AMD released "AMD64" Intel started copying the AMD 64-bit extensions. IA-32e was a short lived name and Intel started using "Intel 64" to refer to the 64-bit extension of x86 and continued using IA-64 for the Itanium VLIW CPU line.

https://en.wikipedia.org/wiki/X86-64#History_2

After several years of denying its existence, Intel announced at the February 2004 IDF that the project was indeed underway. Intel's chairman at the time, Craig Barrett, admitted that this was one of their worst-kept secrets.

Intel's name for this instruction set has changed several times. The name used at the IDF was CT (presumably[original research?] for Clackamas Technology, another codename from an Oregon river); within weeks they began referring to it as IA-32e (for IA-32 extensions) and in March 2004 unveiled the "official" name EM64T (Extended Memory 64 Technology). In late 2006 Intel began instead using the name Intel 64 for its implementation, paralleling AMD's use of the name AMD64.

Re:Ask HN: What's the best resource for learning modern x64 ... by chrisseaton on Sunday February 09, 2020 @06:52AM (#22281670)
I wonder where the x86-64, x86_64, and (the most strange of all) x64 names came from.

I think we should call it AMD64, since that's what the people who actually designed it wanted it to be called.

Re:Ask HN: What's the best resource for learning modern x64 ... by cesarb on Sunday February 09, 2020 @09:02AM (#22282127)
> I wonder where the x86-64, x86_64, and (the most strange of all) x64 names came from.

The "x86-64" name is the original one, and came from AMD themselves: https://web.archive.org/web/20000817071303/http://www.amd.co... (and "x86_64" is obviously an alias for where a hyphen is not an allowed character, like identifiers on many programming languages).

The "x64" name came from Microsoft, probably due to file name length limitations (this was before Windows XP unified the Windows 9x and Windows NT lines).

IIRC, the "AMD64" name came later, probably to distinguish it better from Intel's IA-64 (Itanium).

Re:Ask HN: What's the best resource for learning modern x64 ... by unilynx on Sunday February 09, 2020 @02:58AM (#22280971)
Wild guess, naming it '32bit extended' allowed Intel to still refer to Itanium as the 'real 64 bit' back in those days.

Intel didn't want the x86 to be 64bit.. they wanted the world to switch to Itanium for that. I figure a lot of the naming mess can be traced back to Intel's marketing.

Re:Ask HN: What's the best resource for learning modern x64 ... by 2ton_jeff on Sunday February 09, 2020 @01:51AM (#22280789)
Flat Assembler is actually easier to get your head around early on than any of the *asm variants IMO: https://flatassembler.net/