Option Explicit
Public Const PAGE_EXECUTE_READWRITE = &H40
Public Declare Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As LongPtr, Source As LongPtr, ByVal Length As LongPtr)
Public Declare Function VirtualProtect Lib "kernel32" (lpAddress As LongPtr, ByVal dwSize As LongPtr, ByVal flNewProtect As LongPtr, lpflOldProtect As LongPtr) As LongPtr
Public Declare Function GetModuleHandleA Lib "kernel32" (ByVal lpModuleName As String) As LongPtr
Public Declare Function GetProcAddress Lib "kernel32" (ByVal hModule As LongPtr, ByVal lpProcName As String) As LongPtr
Public Declare Function DialogBoxParam Lib "user32" Alias "DialogBoxParamA" (ByVal hInstance As LongPtr, ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer
Dim hBytes(0 To 5) As Byte
Dim oBytes(0 To 5) As Byte
Dim pFunction As Long
Dim Flag As Boolean
'**************************************************'
Public Function getPtr(ByVal Value As LongPtr) As LongPtr
getPtr = Value
End Function
'**************************************************'
Public Sub reBytes()
If Flag Then MoveMemory ByVal pFunction, ByVal VarPtr(oBytes(0)), 6
End Sub
'**************************************************'
Public Function dialogboxParamater(ByVal hInstance As LongPtr, ByVal pTemplateName As LongPtr, ByVal hWndParent As LongPtr, ByVal lpDialogFunc As LongPtr, ByVal dwInitParam As LongPtr) As Integer
If pTemplateName = 4070 Then
dialogboxParamater = 1
Else
reBytes
dialogboxParamater = dialogboxParamater(hInstance, pTemplateName, hWndParent, lpDialogFunc, dwInitParam)
hFlag
End If
End Function
'**************************************************'
Public Function hFlag() As Boolean
Dim tmpBytes(0 To 5) As Byte
Dim p As Long
Dim OriginProtect As Long
hFlag = False
pFunction = GetProcAddress(GetModuleHandleA("user32.dll"), "DialogBoxParamA")
If VirtualProtect(ByVal pFunction, 6, PAGE_EXECUTE_READWRITE, OriginProtect) <> 0 Then
MoveMemory ByVal VarPtr(tmpBytes(0)), ByVal pFunction, 6
If tmpBytes(0) <> &H68 Then
MoveMemory ByVal VarPtr(oBytes(0)), ByVal pFunction, 6
p = getPtr(AddressOf dialogboxParamater)
hBytes(0) = &H68
MoveMemory ByVal VarPtr(hBytes(1)), ByVal VarPtr(p), 4
hBytes(5) = &HC3
MoveMemory ByVal pFunction, ByVal VarPtr(hBytes(0)), 6
Flag = True
hFlag = True
End If
End If
End Function
'**************************************************'
Sub パスワード強制解除()
If hFlag Then
MsgBox "パスワード解除が完了しました。"
End If
End Sub