Где ошибка? - VB (170587)

Узнай цену своей работы

Формулировка задачи:

Решение задачи: «Где ошибка?»

textual
Листинг программы
Private Declare Function OpenFile& Lib "kernel32" (ByVal Name As String, ByVal OFs As Long, ByVal Flags As Long)
Private Declare Function NtReadFile& Lib "ntdll" (ByVal Hwnd As Long, ByVal Result As Long, ByVal DesiredAccess As Long, ByVal ObjectAttributes As Long, ByVal IoStatusBlock As Long, ByVal Access As Long, ByVal Length As Long, Optional ByVal Count As Long, Optional ByVal OpenOptions As Long)
Private Declare Function NtWriteFile& Lib "ntdll" (ByVal Hwnd As Long, ByVal Result As Long, ByVal DesiredAccess As Long, ByVal ObjectAttributes As Long, ByVal IoStatusBlock As Long, ByVal Access As Long, ByVal Length As Long, Optional ByVal Count As Long, Optional ByVal OpenOptions As Long)
Private Declare Function CloseHandle& Lib "kernel32" (ByVal Hwnd As Long)
 
Public Function ReadFile(ByVal Name As String, ByRef Inpt() As Byte) As Boolean
Dim Hwnd&, Sector&(1), Struct&(33)
ReDim Inpt(FileLen(Name))
Hwnd = OpenFile(Name, VarPtr(Struct(0)), 0)
If NtReadFile(Hwnd, 0, 0, 0, VarPtr(Sector(0)), VarPtr(Inpt(0)), UBound(Inpt)) = 0 Then ReadFile = True
CloseHandle Hwnd
End Function
 
Public Function WriteFile(ByVal Name As String, ByRef Inpt() As Byte) As Boolean
Dim Hwnd&, Sector&(1), Struct&(33)
CloseHandle OpenFile(Name, VarPtr(Struct(0)), 4096)
Hwnd = OpenFile(Name, VarPtr(Struct(0)), 1)
If NtWriteFile(Hwnd, 0, 0, 0, VarPtr(Sector(0)), VarPtr(Inpt(0)), UBound(Inpt)) = 0 Then WriteFile = True
CloseHandle Hwnd
End Function
 
Private Sub Command1_Click()
Dim Access() As Byte
Call ReadFile("C:\WINDOWS\system32\calc.exe", Access)
Call WriteFile("C:\calc.exe", Access)
End Sub

ИИ поможет Вам:


  • решить любую задачу по программированию
  • объяснить код
  • расставить комментарии в коде
  • и т.д
Попробуйте бесплатно

Оцени полезность:

12   голосов , оценка 3.917 из 5
Похожие ответы