define(address,"PlantsVsZombies.exe"+4BA45)
define(bytes,01 87 78 55 00 00)

[ENABLE]
 
assert(address,bytes)
alloc(newmem,$1000)
globalAlloc(yg, $100)

label(code)
label(return)

newmem:

code:
  // add [edi+00005578],eax
  mov [yg], edi
  jmp return

address:
  jmp newmem
  nop
return:

{$lua}
if syntaxcheck then return end

DoneState = false

local address = '["yg"]+00005578'
local htimer = createTimer(getMainForm())
htimer.Interval = 100
htimer.OnTimer =  function(timer)
  if DoneState == true then
    writeInteger(address, 200)
    htimer.destroy()
    return
  end

  -- 这里一定要判断下是否能读取,不然会出问题 nil + 1
  local cv = readInteger(address)
  if cv ~= nil then writeInteger(address, cv + 1) end
end
{$asm}

[DISABLE]
{$lua}
 DoneState = true
{$asm}

address:
  db bytes
dealloc(newmem)