32-Bit Windows Assembly: Ep.1 – Windows API and the Stack Flashcards

1
Q

What does Assembly use to represent low-level instructions?

A

Mnemonics

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is another name for mnemonics

A

Symbolic references

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Name an Assembler that can be used for 32-bit Windows Assembly?

A

MASM

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name a Linker that can be used for 32-bit Windows Assembly?

A

LINK

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does MASM stand for?

A

Microsoft Macro Assembler

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Where can MASM be found?

A

Bundled with Visual Studio.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Name two tasks performed by the linker.

A
  • Merges various object files together

* Sets up the references to external code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Name two types of instruction syntax formatting.

A

Intel and AT&T.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What does the call assembly instruction do?

A

Changes the execution flow to the target location. This is synonymous with a function call in normal programming.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Which assembly instruction would you use to execute a function?

A

call

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does the following assembly instruction do?

push (value)

A

Takes (value) and puts it on the local stack frame.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the meaning of the following assembly instruction, and what does it do?

db (bytes)

A

“Define bytes” - an instruction to the assembler/compiler to reserve bytes inside the section it is referenced.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the meaning of the following assembly instruction, and what does it do?

dd (bytes)

A

“Define dword” - an instruction to the assembler/compiler to reserve bytes inside the section it is referenced.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What does ABI stand for?

A

Application Binary Interface.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Which section contains the executable code that the program will run?

A

.code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Which section contains initialised variables?

A

.data

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Which section contains uninitialised variables in 32-bit Windows Assembly?

A

.data?

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

In which section can you find the entry point for a program?

A

.code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

What permissions should the .code section have?

A

Readable and executable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Which section should have readable and executable permissions?

A

.code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
21
Q

In 32-bit x86 Windows Assembly language, which label designates the entry point of the program?

A

start:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

What does the assembler and linker do with a label?

A

They translate the label into a memory address inside the binary.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

What is a calling convention?

A

A calling convention is a defined approach to how parameters are passed from one function to another.

24
Q

Which calling convention is the default for Windows APIs on a 32-bit architecture?

A

“Standard Call”, or StdCall.

25
Q

How is the StdCall calling convention performed?

A

All arguments for the function to be called are put on the stack. The last argument is put on the stack first.

26
Q

What is the stack?

A

The stack is a special region of memory that stores temporary variables created by each function.

27
Q

Name a special properly of the stack.

A

The stack is a ‘last in, first out’ (LIFO) data structure.

28
Q

What happens when a function declares a new variable?

A

The variable is pushed onto the stack and manipulated there.

29
Q

What happens on the stack when a function exits?

A

All variables pushed onto the stack by that function are ‘popped’ – effectively, deleted.

30
Q

What does the .386 directive do?

A

Shows MASM that you wish to assemble a program which enables assembly of non-privileged instructions for the 80386 processor.

31
Q

What does the .model directive do?

A

Initialises the program’s memory model, can dictate the memory model and the language type.

32
Q

What is a flat memory model?

A

A flat memory model is used to dictate that the program will see a single contiguous memory structure in RAM.

33
Q

What is a stdcall memory model?

A

The language type which shows the type of calling convention used for the function’s calls.

34
Q

What does the option directive do?

A

Enables and disables features of the assembler.

35
Q

What does the casemap:none option directive do?

A

Ensures case sensitivity. The Microsoft ABI states that programs should be case sensitive.

36
Q

What does the Extern directive do?

A

Defines external variables, symbols, or labels. We are using it for the Windows APIs that we want to reference.

37
Q

What does the end directive do?

A

Sets the end of the program. If accompanied by a label, sets that label to the entry point of the program.

38
Q

What does the PROC directive do?

A

Marks the start of a procedure block.

39
Q

What does the equ directive do?

A

Assigns a value to the label. This has been combined with the special character $ (current location in memory) to calculate the size of the szMsg variable.

40
Q

Which directive instructs MASM to assemble a program which enables assembly of non-privileged instructions for the 80386 processor?

A

.386

41
Q

Which directive initialises the program’s memory model?

A

.model

42
Q

Which parameter to the .model directive dictates that the program will see a single contiguous memory structure in RAM?

A

flat

43
Q

Which parameter to the .model directive dictates that the program will see a single contiguous memory structure in RAM?

A

stdcall

44
Q

Which parameters does the .model directive accept?

A

memory-module
language-type
stack-option

45
Q

Which directive enables and disables features of the assembler?

A

option

46
Q

Which parameter of the option directive ensures case sensitivity?

A

caremap:none

47
Q

Which directive defines external variables, symbols, or labels?

A

Extern

48
Q

Which directive sets the end of the program?

A

end

49
Q

Which directive marks the start of a procedure block?

A

PROC

50
Q

Which directive assigns a value to a label?

A

equ

51
Q

What is the system call number for the standard output device in 32-bit Windows Assembly?

A

-11

52
Q

___ is a data structure that can hold multiple values of the same data type

A

Array

53
Q

___ is a data structure that can hold multiple values of different data types

A

Struct

54
Q

Can an empty struct be passed to the Windows API?

A

Yes.

For some Windows API calls, the programmer will pass an empty declared struct to the API call and the Operating System will fill out the values and return execution back to the main program.

55
Q

When declaring a struct, which section must it be placed in?

A

.data