-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArray_TotalMemory.asm
More file actions
74 lines (64 loc) · 1.61 KB
/
Array_TotalMemory.asm
File metadata and controls
74 lines (64 loc) · 1.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
;==============================================================================
;
; UASM64 Library
;
; https://github.com/mrfearless/UASM64-Library
;
;==============================================================================
.686
.MMX
.XMM
.x64
option casemap : none
IF @Platform EQ 1
option win64 : 11
ENDIF
option frame : auto
include UASM64.inc
.CODE
UASM64_ALIGN
;------------------------------------------------------------------------------
; Array_TotalMemory
;
; Get the total amount of memory to store the whole array and its items.
;
; Parameters:
;
; * pArray - pointer to the array.
;
; * lpdwTotalMemory - variable to store the total memory for the array.
;
; Returns:
;
; The total amount of memory that each array item takes up in total.
;
; Notes:
;
; This function as based on the MASM32 Library function: arrtotal
;
; See Also:
;
; Array_TotalItems
;
;------------------------------------------------------------------------------
Array_TotalMemory PROC FRAME USES RCX RDX RDI RSI pArray:QWORD, lpdwTotalMemory:QWORD
mov rsi, pArray
mov rdi, [rsi] ; get the array member count
xor rdx, rdx
mov rcx, 1
@@:
mov rax, [rsi+rcx*8] ; get array member address
sub rax, 8 ; sub 4 to get stored OLE length
add rdx, [rax] ; add it to EDX
add rcx, 1 ; increment index
cmp rcx, rdi ; test if index == array count
jle @B
;cmp DWORD PTR [esp+8][8], 0
;je @F
add rdx, rdi
add rdx, rdi
@@:
mov rax, rdx
ret
Array_TotalMemory ENDP
END