Jump to content

cheney

Members
  • Posts

    8
  • Joined

  • Last visited

cheney's Achievements

Seeker

Seeker (1/7)

0

Reputation

  1. Thanks for your information.
  2. Hi: I want porting VC++ source code to Autoit, How can set __int64 to function SetFilePointer in Autoit ?? //////////////////Autoit//////////////////////////////////// Func Read($TestDecive,$LBAPos,$Readlength) local $Result = _WinAPI_SetFilePointer($TestDecive, $LBAPos*512,0) EndFunc //////////////////Autoit//////////////////////////////////// //////////////////VC++//////////////////////////////////// BOOL Read(HANDLE dev,DWORD Sector_Start,int Sector_num) { BOOL flag; DWORD Program_len; __int64 distance = Sector_Start*0x200; LARGE_INTEGER li; li.QuadPart = distance; li.LowPart = SetFilePointer (dev, li.LowPart, &li.HighPart, FILE_BEGIN); if (li.LowPart == 0xFFFFFFFF && GetLastError() != NO_ERROR) { li.QuadPart = -1; return false; } flag = ReadFile(dev,Buffer,Sector_num*0x200,&Program_len,NULL); return flag; } //////////////////VC++//////////////////////////////////// Thanks for your answering !!
  3. Thank you for your help !!
  4. Hi: how can I get the pointer of offset? local $Buffer = DllStructCreate("byte[" & 0x10*512 & "]") local $ptr = DllStructGetPtr($Buffer) How can I get the pointer of byte[512]? Use DllStructGetPtr ?? Thanks for your help !!
  5. Thanks for your help !
  6. Hi: I try to read file data and show it on Edit,but Edit only show to length 00001780,Why? How can I show more? If I show too more data the GUI Edit will hang ? Need CoProc?? Have any Example? Thanks for your help ! #include <WinApi.au3> #include <GuiConstants.au3> $gMain = GUICreate("ReadData", 625, 482, 193, 125) $edResults = GUICtrlCreateEdit("", 16, 56, 593, 377) GUICtrlSetFont(-1, 8.5, Default, Default, "Courier New") $btRead = GUICtrlCreateButton("Read", 264, 448, 75, 25, 0) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $btRead _ReadFile() EndSwitch WEnd Func _ReadFile () ; 64k data Local $outfile = FileOpen("out.dat", 18) for $i = 0 to 8191 step 1 FileWrite($outfile, Int("0x" & Hex(mod($i,256),2))) next FileClose($outfile) local $hFile = _WinAPI_CreateFile(@ScriptDir & '\out.dat', 2, 2, 2) _ReadLBAandShowData($hFile,0,0x20) _ReadLBAandShowData($hFile,0,0x40) FileClose($hFile) EndFunc Func _ReadLBAandShowData($hFile,$LBAPos,$Readlength) local $Result = _WinAPI_SetFilePointer($hFile, $LBAPos,0) local $err = @error local $Buffer = DllStructCreate("byte[" & $Readlength*512 & "]") local $ptr = DllStructGetPtr($Buffer) local $Read = 0 local $sBuffer If $Result = 0xFFFFFFFF Then _WinAPI_CloseHandle($hFile) MsgBox(4096,"","$Result = 0xFFFFFFFF") EndIf $Result = _WinAPI_ReadFile($hFile, $ptr,$Readlength*512,$Read) $err = @error If Not $Result Then _WinAPI_CloseHandle($hFile) MsgBox(4096,"","_WinAPI_ReadFile fail") Else _ShowBuffer($Buffer,$Readlength*0x200) EndIf ;_WinAPI_CloseHandle($hFile) If Not $Result Then SetError(8, @error, 0) EndFunc Func _ShowBuffer($Sourcebuffer,$nRead) local $i,$j,$sHex,$sWord,$sBuffer,$sTemp,$sBuffer,$nOffset,$nCode,$nPosition $nPosition = 0 $nOffset = 1 For $i = 0 To ($nRead/16)-1 ;line number $sHex = "" $sWord = "" For $j = 0 To 15 step 1 $sHex &= Hex(DllStructGetData($Sourcebuffer, 1, $i*16 + $j + $nOffset), 2);add Hex $nCode = Int("0x" & Hex(DllStructGetData($Sourcebuffer, 1, $i*16 + $j + $nOffset), 2));check by ASCLL If $nCode > 31 And $nCode < 127 Then $sWord &= Chr($nCode) Else $sWord &= "." EndIf $sHex &= " ";add space Next If Mod($i, 32) = 0 Then GUICtrlSetData($edResults, StringFormat(" Sector : %04lX " & @CRLF,$i/32),1) endif GUICtrlSetData($edResults, StringFormat(" %s: %-40s %-16s\r\n", Hex($nPosition), $sHex, $sWord),1) $nPosition += 16 ConsoleWrite("$nPosition =" & $nPosition & @CRLF) Next EndFunc ReadFileDataGuiEdit.au3
  7. Thank you all for the answering
  8. Hi all: $nBytes = 1024 $hBuffer = DllStructCreate("ubyte buffer[" & $nBytes & "]") $pBuffer = DllStructGetPtr($hBuffer) . How to fill data pattern 0x55AA or any data pattern to $hBuffe not with "for"? What method is fast ?? call memset ?? Thanks for your answer
×
×
  • Create New...