• Welcome to Valhalla Legends Archive.
 

VirtualProtectEx in VB

Started by Paul, March 02, 2004, 07:31 PM

Previous topic - Next topic

Paul

Does anyone have a clear cut working example on how to use VirtualProtectEx in Visual Basic 6? How to declare everything properly and how to actually use it? I've tried googling for VirtualProtectEx+Visual Basic+Usage and find nothing that shows an idiot-proof example on how to properly use AND if possible test it.

TheMinistered

#1
why do you need virtualprotectex, why not just virtualrprotect?  But, I do have a working example in this project: www.backstab.ca/~source/VB%20PATCHER.zip

wait a second for me to upload

Paul

#2
Quote from: TheMinistered on March 02, 2004, 07:36 PM
why do you need virtualprotectex, why not just virtualrprotect?

Do you have an idiot-proof example on how to implement VirtualProtect?

Edit:
Cool, I'll check that out!

Double edit:

404 Error on that url. Nevermind! :P

Paul

In my form I have the following:

Private Declare Function VirtualProtect Lib "kernel32" (ByVal lpAddress As Long, ByVal dwSize As Long, ByVal flNewProtect As Long, lpflOldProtect As Long) As Long

Private Const PAGE_EXECUTE_READWRITE As Long = &H40&

Dim lOldProtect As Long

VirtualProtect &Hoffsethere, 4, PAGE_EXECUTE_READWRITE, lOldProtect



Is this how you use/declare everything? All I want to do is change the rights to one address.


TheMinistered

It looks like you got it down pretty much...

Paul

Is there a way to test the address I change permissions on because I don't think it's working.

TheMinistered

call VirtualProtect twice and check lOldProtection