How would i write to protected memory in VB6 or C++? preferably VB6...

this is what i have so far but it doesnt work.

Code:
Private Const PAGE_EXECUTE_READWRITE = &H805C00A1
for that ive tried 805C00A1 wich is what the game has set for the fog address...and &H40 wich is what MSDN says to use

Code:
    Dim old As Long
    Dim hwnd As Long
    Dim pid As Long
    Dim phandle As Long
    
    hwnd = FindWindow(vbNullString, "WarRock")
    
    If (hwnd = 0) Then
        Exit Function
    End If
    
    GetWindowThreadProcessId hwnd, pid
    phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
    
    If (phandle = 0) Then
        Exit Function
    End If

VirtualProtectEx phandle, addy, 1, PAGE_EXECUTE_READWRITE, old
    CloseHandle phandle