-
Notifications
You must be signed in to change notification settings - Fork 71
/
class_RemoteTreeView.ahk
712 lines (668 loc) · 24.6 KB
/
class_RemoteTreeView.ahk
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
; Link: https://raw.githubusercontent.com/AlecH92/VEXTournamentManagerTools/de5642513c2b3a8288ee44056eb3e41ecf244268/AutoHotKey%20Scripts/RemoteTreeViewClass.ahk
; Author:
; Date:
; for: AHK_L
/*
*/
;--------------------------------------------------------------------------------------------------
; Title: Remote TreeView class
; This class allows a script to work with TreeViews controlled by a third party process.
;
; 8/30/2012 Released for beta testing
;
; 8/31/2012 Added a wait parameter to SetSelection
; Changed name of ExpandCollapse to Expand
; Changed default WaitTime of Expand to 0
;
; 9/2/2012 Removed GetState method and replaced it with the IsBold, IsChecked, IsExpanded
; and IsSelected methods.
;
; 9/7/2012 Added Check method.
; For ease of use, changed parameters of SetSelection, Expand and IsChecked methods.
;
; 9/17/2012 Extended the "Full" option of GetNext() to allow it to transverse sub-trees.
; Given a starting node, all decendents of that node will be transversed depth
; first. Those nodes which are not descendants of the starting node will NOT be
; visited. To traverse the entire tree, including the real root, pass zero as the
; starting node.
;
;
class RemoteTreeView
{
;----------------------------------------------------------------------------------------------
; Method: __New
; Stores the TreeView's Control HWnd in the object for later use
;
; Parameters:
; TVHnd - HWND of the TreeView control
;
; Returns:
; Nothing
;
__New(TVHnd)
{
this.TVHnd := TVHnd
}
;----------------------------------------------------------------------------------------------
; Method: GetItemRect
; Retrieves the bounding rectangle for a tree-view item and indicates
; whether the item is visible.
; https://msdn.microsoft.com/en-us/library/bb773610%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396
;
; Parameters:
; pItem - Handle to the item you wish retrieved
;
; Returns:
; TRUE if successful, or FALSE otherwise
;
GetItemRect(pItem)
{
VarSetCapacity(rc,16)
NumPut(this.GetSelection(),&rc)
SendMessage,0x1104,1,&rc,,% "ahk_id " this.TVHnd
return %rc%
}
GetItemHeight()
{
SendMessage TVM_GETITEMHEIGHT,1,,,% "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: SetSelection
; Makes the given item selected and expanded. Optionally scrolls the
; TreeView so the item is visible.
;
; Parameters:
; pItem - Handle to the item you wish selected
;
; Returns:
; TRUE if successful, or FALSE otherwise
;
SetSelection(pItem)
{
SendMessage TVM_SELECTITEM, TVGN_CARET|TVSI_NOSINGLEEXPAND, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetSelection
; Retrieves the currently selected item
;
; Parameters:
; None
;
; Returns:
; Handle to the selected item if successful, Null otherwise.
;
GetSelection()
{
SendMessage TVM_GETNEXTITEM, TVGN_CARET, 0, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetRoot
; Retrieves the root item of the treeview
;
; Parameters:
; None
;
; Returns:
; Handle to the topmost or very first item of the tree-view control
; if successful, NULL otherwise.
;
GetRoot()
{
SendMessage TVM_GETNEXTITEM, TVGN_ROOT, 0, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetParent
; Retrieves an item's parent
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Handle to the parent of the specified item. Returns
; NULL if the item being retrieved is the root node of the tree.
;
GetParent(pItem)
{
SendMessage TVM_GETNEXTITEM, TVGN_PARENT, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetChild
; Retrieves an item's first child
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Handle to the first Child of the specified item, NULL otherwise.
;
GetChild(pItem)
{
SendMessage TVM_GETNEXTITEM, TVGN_CHILD, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetNext
; Returns the handle of the sibling below the specified item (or 0 if none).
;
; Parameters:
; pItem - (Optional) Handle to the item
;
; flag - (Optional) "FULL" or "F"
;
; Returns:
; This method has the following modes:
; 1. When all parameters are omitted, it returns the handle
; of the first/top item in the TreeView (or 0 if none).
;
; 2. When the only first parameter (pItem) is present, it returns the
; handle of the sibling below the specified item (or 0 if none).
; If the first parameter is 0, it returns the handle of the first/top
; item in the TreeView (or 0 if none).
;
; 3. When the second parameter is "Full" or "F", the first time GetNext()
; is called the hItem passed is considered the "root" of a sub-tree that
; will be transversed in a depth first manner. No nodes except the
; decendents of that "root" will be visited. To traverse the entire tree,
; including the real root, pass zero in the first call.
;
; When all descendants have benn visited, the method returns zero.
;
; Example:
; hItem = 0 ; Start the search at the top of the tree.
; Loop
; {
; hItem := MyTV.GetNext(hItem, "Full")
; if not hItem ; No more items in tree.
; break
; ItemText := MyTV.GetText(hItem)
; MsgBox The next Item is %hItem%, whose text is "%ItemText%".
; }
;
GetNext(pItem = 0, flag = "")
{
static Root := -1
if (RegExMatch(flag, "i)^\s*(F|Full)\s*$")) {
if (Root = -1) {
Root := pItem
}
SendMessage TVM_GETNEXTITEM, TVGN_CHILD, pItem, , % "ahk_id " this.TVHnd
if (ErrorLevel = 0) {
SendMessage TVM_GETNEXTITEM, TVGN_NEXT, pItem, , % "ahk_id " this.TVHnd
if (ErrorLevel = 0) {
Loop {
SendMessage TVM_GETNEXTITEM, TVGN_PARENT, pItem, , % "ahk_id " this.TVHnd
if (ErrorLevel = Root) {
Root := -1
return 0
}
pItem := ErrorLevel
SendMessage TVM_GETNEXTITEM, TVGN_NEXT, pItem, , % "ahk_id " this.TVHnd
} until ErrorLevel
}
}
return ErrorLevel
}
Root := -1
if (!pItem)
SendMessage TVM_GETNEXTITEM, TVGN_ROOT, 0, , % "ahk_id " this.TVHnd
else
SendMessage TVM_GETNEXTITEM, TVGN_NEXT, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetPrev
; Returns the handle of the sibling above the specified item (or 0 if none).
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Handle of the sibling above the specified item (or 0 if none).
;
GetPrev(pItem)
{
SendMessage TVM_GETNEXTITEM, TVGN_PREVIOUS, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: Expand
; Expands or collapses the specified tree node
;
; Parameters:
; pItem - Handle to the item
;
; flag - Determines whether the node is expanded or collapsed.
; true : expand the node (default)
; false : collapse the node
;
;
; Returns:
; Nonzero if the operation was successful, or zero otherwise.
;
Expand(pItem, DoExpand = true)
{
flag := DoExpand ? TVE_EXPAND : TVE_COLLAPSE
SendMessage TVM_EXPAND, flag, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: Check
; Changes the state of a treeview item's check box
;
; Parameters:
; pItem - Handle to the item
;
; fCheck - If true, check the node
; If false, uncheck the node
;
; Force - If true (default), prevents this method from failing due to
; the node having an invalid initial state. See IsChecked
; method for more info.
;
; Returns:
; Returns true if if successful, otherwise false
;
; Remarks:
; This method makes pItem the current selection.
;
Check(pItem, fCheck, Force = true)
{
SavedDelay := A_KeyDelay
SetKeyDelay 30
CurrentState := this.IsChecked(pItem, false)
if (CurrentState = -1)
if (Force) {
ControlSend, , {Space}, % "ahk_id " this.TVHnd
CurrentState := this.IsChecked(pItem, false)
}
else
return false
if (CurrentState and not fCheck) or (not CurrentState and fCheck )
ControlSend, , {Space}, % "ahk_id " this.TVHnd
SetKeyDelay %SavedDelay%
return true
}
;----------------------------------------------------------------------------------------------
; Method: GetText
; Retrieves the text/name of the specified node
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; The text/name of the specified Item. If the text is longer than 127, only
; the first 127 characters are retrieved.
;
GetText(pItem)
{
TVM_GETITEM := A_IsUnicode ? TVM_GETITEMW : TVM_GETITEMA
WinGet ProcessId, pid, % "ahk_id " this.TVHnd
hProcess := OpenProcess(PROCESS_VM_OPERATION|PROCESS_VM_READ
|PROCESS_VM_WRITE|PROCESS_QUERY_INFORMATION
, false, ProcessId)
Size := 28 + 3 * A_PtrSize ; Size of a TVITEM structure
_tvi := VirtualAllocEx(hProcess, 0, Size, MEM_COMMIT, PAGE_READWRITE)
_txt := VirtualAllocEx(hProcess, 0, 256, MEM_COMMIT, PAGE_READWRITE)
; TVItem Structure
VarSetCapacity(tvi, Size, 0)
NumPut(TVIF_TEXT|TVIF_HANDLE, tvi, 0, "UInt")
NumPut(pItem, tvi, 4, "Ptr")
NumPut(_txt, tvi, 12 + A_PtrSize, "Ptr")
NumPut(127, tvi, 12 + 2 * A_PtrSize, "Uint")
VarSetCapacity(txt, 256, 0)
WriteProcessMemory(hProcess, _tvi, &tvi, Size)
SendMessage TVM_GETITEM, 0, _tvi, , % "ahk_id " this.TVHnd
ReadProcessMemory(hProcess, _txt, txt, 256)
VirtualFreeEx(hProcess, _txt, 0, MEM_RELEASE)
VirtualFreeEx(hProcess, _tvi, 0, MEM_RELEASE)
CloseHandle(hProcess)
return txt
}
;----------------------------------------------------------------------------------------------
; Method: EditLabel
; Begins in-place editing of the specified item's text, replacing the text of the
; item with a single-line edit control containing the text. This method implicitly
; selects and focuses the specified item.
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Returns the handle to the edit control used to edit the item text if successful,
; or NULL otherwise. When the user completes or cancels editing, the edit control
; is destroyed and the handle is no longer valid.
;
EditLabel(pItem)
{
TVM_EDITLABEL := A_IsUnicode ? TVM_EDITLABELW : TVM_EDITLABELA
SendMessage TVM_EDITLABEL, 0, pItem, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: GetCount
; Returns the total number of expanded items in the control
;
; Parameters:
; None
;
; Returns:
; Returns the total number of expanded items in the control
;
GetCount()
{
SendMessage TVM_GETCOUNT, 0, 0, , % "ahk_id " this.TVHnd
return ErrorLevel
}
;----------------------------------------------------------------------------------------------
; Method: IsChecked
; Retrieves an item's checked status
;
; Parameters:
; pItem - Handle to the item
;
; Force - If true (default), forces the node to return a valid state.
; Since this involves toggling the state of the check box, it
; can have undesired side effects. Make this false to disable
; this feature.
; Returns:
; Returns 1 if the item is checked, 0 if unchecked.
;
; Returns -1 if the checkbox state cannot be determined because no checkbox
; image is currently associated with the node and Force is false.
;
; Remarks:
; Due to a "feature" of Windows, a checkbox can be displayed even if no checkbox image
; is associated with the node. It is important to either check the actual value returned
; or make the Force parameter true.
;
; This method makes pItem the current selection.
;
IsChecked(pItem, Force = true)
{
SavedDelay := A_KeyDelay
SetKeyDelay 30
this.SetSelection(pItem)
SendMessage TVM_GETITEMSTATE, pItem, 0, , % "ahk_id " this.TVHnd
State := ((ErrorLevel & TVIS_STATEIMAGEMASK) >> 12) - 1
if (State = -1 and Force) {
ControlSend, , {Space 2}, % "ahk_id " this.TVHnd
SendMessage TVM_GETITEMSTATE, pItem, 0, , % "ahk_id " this.TVHnd
State := ((ErrorLevel & TVIS_STATEIMAGEMASK) >> 12) - 1
}
SetKeyDelay %SavedDelay%
return State
}
;----------------------------------------------------------------------------------------------
; Method: IsBold
; Check if a node is in bold font
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Returns true if the item is in bold, false otherwise.
;
IsBold(pItem)
{
SendMessage TVM_GETITEMSTATE, pItem, 0, , % "ahk_id " this.TVHnd
return (ErrorLevel & TVIS_BOLD) >> 4
}
;----------------------------------------------------------------------------------------------
; Method: IsExpanded
; Check if a node has children and is expanded
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Returns true if the item has children and is expanded, false otherwise.
;
IsExpanded(pItem)
{
SendMessage TVM_GETITEMSTATE, pItem, 0, , % "ahk_id " this.TVHnd
return (ErrorLevel & TVIS_EXPANDED) >> 5
}
;----------------------------------------------------------------------------------------------
; Method: IsSelected
; Check if a node is Selected
;
; Parameters:
; pItem - Handle to the item
;
; Returns:
; Returns true if the item is selected, false otherwise.
;
IsSelected(pItem)
{
SendMessage TVM_GETITEMSTATE, pItem, 0, , % "ahk_id " this.TVHnd
return (ErrorLevel & TVIS_SELECTED) >> 1
}
}
;==================================================================================================
;
; Functions
;
;==================================================================================================
;----------------------------------------------------------------------------------------------
; Function: OpenProcess
; Opens an existing local process object.
;
; Parameters:
; DesiredAccess - The desired access to the process object.
;
; InheritHandle - If this value is TRUE, processes created by this process will inherit
; the handle. Otherwise, the processes do not inherit this handle.
;
; ProcessId - The Process ID of the local process to be opened.
;
; Returns:
; If the function succeeds, the return value is an open handle to the specified process.
; If the function fails, the return value is NULL.
;
OpenProcess(DesiredAccess, InheritHandle, ProcessId)
{
return DllCall("OpenProcess"
, "Int", DesiredAccess
, "Int", InheritHandle
, "Int", ProcessId
, "Ptr")
}
;----------------------------------------------------------------------------------------------
; Function: CloseHandle
; Closes an open object handle.
;
; Parameters:
; hObject - A valid handle to an open object
;
; Returns:
; If the function succeeds, the return value is nonzero.
; If the function fails, the return value is zero.
;
CloseHandle(hObject)
{
return DllCall("CloseHandle"
, "Ptr", hObject
, "Int")
}
;----------------------------------------------------------------------------------------------
; Function: VirtualAllocEx
; Reserves or commits a region of memory within the virtual address space of the
; specified process, and specifies the NUMA node for the physical memory.
;
; Parameters:
; hProcess - A valid handle to an open object. The handle must have the
; PROCESS_VM_OPERATION access right.
;
; Address - The pointer that specifies a desired starting address for the region
; of pages that you want to allocate.
;
; If you are reserving memory, the function rounds this address down to
; the nearest multiple of the allocation granularity.
;
; If you are committing memory that is already reserved, the function rounds
; this address down to the nearest page boundary. To determine the size of a
; page and the allocation granularity on the host computer, use the GetSystemInfo
; function.
;
; If Address is NULL, the function determines where to allocate the region.
;
; Size - The size of the region of memory to be allocated, in bytes.
;
; AllocationType - The type of memory allocation. This parameter must contain ONE of the
; following values:
; MEM_COMMIT
; MEM_RESERVE
; MEM_RESET
;
; ProtectType - The memory protection for the region of pages to be allocated. If the
; pages are being committed, you can specify any one of the memory protection
; constants:
; PAGE_NOACCESS
; PAGE_READONLY
; PAGE_READWRITE
; PAGE_WRITECOPY
; PAGE_EXECUTE
; PAGE_EXECUTE_READ
; PAGE_EXECUTE_READWRITE
; PAGE_EXECUTE_WRITECOPY
;
; Returns:
; If the function succeeds, the return value is the base address of the allocated region of pages.
; If the function fails, the return value is NULL.
;
VirtualAllocEx(hProcess, Address, Size, AllocationType, ProtectType)
{
return DllCall("VirtualAllocEx"
, "Ptr", hProcess
, "Ptr", Address
, "UInt", Size
, "UInt", AllocationType
, "UInt", ProtectType
, "Ptr")
}
;----------------------------------------------------------------------------------------------
; Function: VirtualFreeEx
; Releases, decommits, or releases and decommits a region of memory within the
; virtual address space of a specified process
;
; Parameters:
; hProcess - A valid handle to an open object. The handle must have the
; PROCESS_VM_OPERATION access right.
;
; Address - The pointer that specifies a desired starting address for the region
; to be freed. If the dwFreeType parameter is MEM_RELEASE, lpAddress
; must be the base address returned by the VirtualAllocEx function when
; the region is reserved.
;
; Size - The size of the region of memory to be allocated, in bytes.
;
; If the FreeType parameter is MEM_RELEASE, dwSize must be 0 (zero). The function
; frees the entire region that is reserved in the initial allocation call to
; VirtualAllocEx.
;
; If FreeType is MEM_DECOMMIT, the function decommits all memory pages that
; contain one or more bytes in the range from the Address parameter to
; (lpAddress+dwSize). This means, for example, that a 2-byte region of memory
; that straddles a page boundary causes both pages to be decommitted. If Address
; is the base address returned by VirtualAllocEx and dwSize is 0 (zero), the
; function decommits the entire region that is allocated by VirtualAllocEx. After
; that, the entire region is in the reserved state.
;
; FreeType - The type of free operation. This parameter can be one of the following values:
; MEM_DECOMMIT
; MEM_RELEASE
;
; Returns:
; If the function succeeds, the return value is a nonzero value.
; If the function fails, the return value is 0 (zero).
;
VirtualFreeEx(hProcess, Address, Size, FType)
{
return DllCall("VirtualFreeEx"
, "Ptr", hProcess
, "Ptr", Address
, "UINT", Size
, "UInt", FType
, "Int")
}
;----------------------------------------------------------------------------------------------
; Function: WriteProcessMemory
; Writes data to an area of memory in a specified process. The entire area to be written
; to must be accessible or the operation fails
;
; Parameters:
; hProcess - A valid handle to an open object. The handle must have the
; PROCESS_VM_WRITE and PROCESS_VM_OPERATION access right.
;
; BaseAddress - A pointer to the base address in the specified process to which data
; is written. Before data transfer occurs, the system verifies that all
; data in the base address and memory of the specified size is accessible
; for write access, and if it is not accessible, the function fails.
;
; Buffer - A pointer to the buffer that contains data to be written in the address
; space of the specified process.
;
; Size - The number of bytes to be written to the specified process.
;
; NumberOfBytesWritten
; - A pointer to a variable that receives the number of bytes transferred
; into the specified process. This parameter is optional. If NumberOfBytesWritten
; is NULL, the parameter is ignored.
;
; Returns:
; If the function succeeds, the return value is a nonzero value.
; If the function fails, the return value is 0 (zero).
;
WriteProcessMemory(hProcess, BaseAddress, Buffer, Size, ByRef NumberOfBytesWritten = 0)
{
return DllCall("WriteProcessMemory"
, "Ptr", hProcess
, "Ptr", BaseAddress
, "Ptr", Buffer
, "Uint", Size
, "UInt*", NumberOfBytesWritten
, "Int")
}
;----------------------------------------------------------------------------------------------
; Function: ReadProcessMemory
; Reads data from an area of memory in a specified process. The entire area to be read
; must be accessible or the operation fails
;
; Parameters:
; hProcess - A valid handle to an open object. The handle must have the
; PROCESS_VM_READ access right.
;
; BaseAddress - A pointer to the base address in the specified process from which to
; read. Before any data transfer occurs, the system verifies that all data
; in the base address and memory of the specified size is accessible for read
; access, and if it is not accessible the function fails.
;
; Buffer - A pointer to a buffer that receives the contents from the address space
; of the specified process.
;
; Size - The number of bytes to be read from the specified process.
;
; NumberOfBytesWritten
; - A pointer to a variable that receives the number of bytes transferred
; into the specified buffer. If lpNumberOfBytesRead is NULL, the parameter
; is ignored.
;
; Returns:
; If the function succeeds, the return value is a nonzero value.
; If the function fails, the return value is 0 (zero).
;
ReadProcessMemory(hProcess, BaseAddress, ByRef Buffer, Size, ByRef NumberOfBytesRead = 0)
{
return DllCall("ReadProcessMemory"
, "Ptr", hProcess
, "Ptr", BaseAddress
, "Ptr", &Buffer
, "UInt", Size
, "UInt*", NumberOfBytesRead
, "Int")
}