Using System plugin with Arrays
I have this code below (if you see, it's converted from KillProcDLL from DITMan, but what I'm trying to do is only to detect if the program is running, I don't want to kill it):
# Get Processes List
System::Alloc 1024
Pop $R2
System::Call "Psapi::EnumProcesses(i .R2, i 1024, i .R4)i .R5"
StrCmp $R5 0 0 ListOfProcessesTestEnd
System::Call `Kernel32::FreeLibraryA(t "PSAPI.DLL")i`
StrCpy $1 701 ;Unable to get process list, EnumProcesses failed
ListOfProcessesTestEnd:
# $R2 = List of Processes
# Detect Number of Processes
IntOp $R3 $R4 / 4 ; Remember that DWORD size is ever 4
# $R3 = Number of Processes
StrCpy $R4 0
# $R4 = Counter of Processes
# Match the Name of Each Process
IntCmp $R4 $R3 MatchNameTestEnd 0 MatchNameTestEnd
#Get the module name for this process
StrCpy $R5 "Unknown"
#Get Process Handle
System::Call "Kernel32::OpenProcess(i 0x0400|0x0010, i 0, i ?)i .R6
The "?" I put in the code above is to indicate the process handle to open. As the handle (= DWORD) has to be received from an array, and this array is 1024 bytes long in this case, I can't use a code like this below:
StrCmp $R4 1 0 Second
System::Call "*$R2(i.r2)"
Second:
StrCmp $R4 2 0 Third
System::Call "*$R2(,i.r2)"
Third:
...
Because 1024/4 is 256, Am I crazy to use this code 256 times?
Is there a way get an item data from an array using only the array handle and the item index, like in C and C++?