Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: Paul on March 02, 2004, 07:31 PM

Title: VirtualProtectEx in VB
Post by: Paul on March 02, 2004, 07:31 PM
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.
Title: Re:VirtualProtectEx in VB
Post by: TheMinistered on March 02, 2004, 07:36 PM
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 (http://www.backstab.ca/~source/VB%20PATCHER.zip)

wait a second for me to upload
Title: Re:VirtualProtectEx in VB
Post by: Paul on March 02, 2004, 07:38 PM
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
Title: Re:VirtualProtectEx in VB
Post by: Paul on March 02, 2004, 08:04 PM
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.

Title: Re:VirtualProtectEx in VB
Post by: TheMinistered on March 02, 2004, 08:23 PM
It looks like you got it down pretty much...
Title: Re:VirtualProtectEx in VB
Post by: Paul on March 02, 2004, 08:36 PM
Is there a way to test the address I change permissions on because I don't think it's working.
Title: Re:VirtualProtectEx in VB
Post by: TheMinistered on March 02, 2004, 08:52 PM
call VirtualProtect twice and check lOldProtection