<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=14900&amp;type=atom" />
	<updated>2019-08-04T17:52:33Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=14900</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135251#p135251" />
			<content type="html"><![CDATA[<p>А, понял методом Send.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-08-04T17:52:33Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135251#p135251</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135250#p135250" />
			<content type="html"><![CDATA[<p>Данные отправляются как SafeArray.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-04T17:47:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135250#p135250</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135248#p135248" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>видно время переходить на ahk64</p></blockquote></div><p>Зачем переходить, проще запускать редкие скрипты под х64, иначе начнут всплывать проблемы под х86 у других.<br /></p><div class="quotebox"><cite>Malcev пишет:</cite><blockquote><p>заливка происходит в 1 запрос</p></blockquote></div><p>А разве сами данные в самом запросе, то есть я видел что отправляются файлы в виде BASE64, а тут то как работает?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-08-04T17:38:00Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135248#p135248</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135246#p135246" />
			<content type="html"><![CDATA[<p>Просто у меня стоит ahk32 - видно время переходить на ahk64.<br />Еще интересно, как в таком случае броузер заливает файл в 2 гб, там заливка происходит в 1 запрос:<br /></p><div class="codebox"><pre><code>HTTP.Open(&quot;POST&quot;, &quot;https://&quot; server &quot;.failiem.lv/save_file.php?PHPSESSID=&quot; phpsessid &quot;&amp;up_id=&quot; up_id &quot;&amp;ignore_user_abort=1&amp;skip_update=1&amp;key=&quot; key &quot;&amp;v=&quot; now, true)</code></pre></div><p>Получается, что AHK плохо распределяет память?</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-04T17:30:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135246#p135246</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135245#p135245" />
			<content type="html"><![CDATA[<p>А смысл это пилить под AutoHotkey x32, если на Windows x86 оно всё равно не заработает?</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-08-04T17:26:20Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135245#p135245</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135244#p135244" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>ypppu пишет:</cite><blockquote><p>А под 32 битами имелось в виду AutoHotkey x32, запущенная на Windows7 x64 ?</p></blockquote></div><p>Да.<br /></p><div class="quotebox"><cite>serzh82saratov пишет:</cite><blockquote><p>Тут что то про IMAGE_FILE_LARGE_ADDRESS_AWARE.</p></blockquote></div><p>После патча autohotkey.exe c 4gb_patch.exe читает до 1.7ГБ.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-04T17:23:09Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135244#p135244</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135243#p135243" />
			<content type="html"><![CDATA[<p><a href="http://www.toolgir.ru/ispolzovanie-bolee-2gb-dlya-32-bit-prilozheniya/">Тут</a> что то про IMAGE_FILE_LARGE_ADDRESS_AWARE.</p>]]></content>
			<author>
				<name><![CDATA[serzh82saratov]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27879</uri>
			</author>
			<updated>2019-08-04T17:11:14Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135243#p135243</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135241#p135241" />
			<content type="html"><![CDATA[<p>А под 32 битами имелось в виду AutoHotkey x32, запущенная на Windows7 x64 ?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2019-08-04T17:04:26Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135241#p135241</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135239#p135239" />
			<content type="html"><![CDATA[<p><strong>ypppu</strong>, Windows 7 x64 и Windows 10 x64.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-04T16:47:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135239#p135239</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135238#p135238" />
			<content type="html"><![CDATA[<p>Ну, 2 ГБ — это на всё про всё. Думаю, зависит от того, как там память выделяется.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2019-08-04T15:48:12Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135238#p135238</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135237#p135237" />
			<content type="html"><![CDATA[<p><strong>Malcev</strong>, Windows 10 x32?</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2019-08-04T15:39:42Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135237#p135237</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135235#p135235" />
			<content type="html"><![CDATA[<p>Там пишется про 2 ГБ, а у меня почему-то не работает при файлах начиная с 800 МБ.</p>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-04T14:37:17Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135235#p135235</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135232#p135232" />
			<content type="html"><![CDATA[<p>Да, на 32 битах же процессу доступно 2 ГБ пользовательского адресного пространства. Я уже и забыл об этом. При каких-то там настройках можно расширить до 3 ГБ. Возможно, из-за этого проблемы. Для данных массива, по идее, нужен непрерывный блок. Может быть, уже не удаётся его получить.</p><p><a href="https://docs.microsoft.com/en-us/windows/win32/memory/memory-limits-for-windows-releases">https://docs.microsoft.com/en-us/window … s-releases</a></p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2019-08-04T14:18:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135232#p135232</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135229#p135229" />
			<content type="html"><![CDATA[<p>А не может быть на 32 битах ограничениий по размеру, так как таким способом тоже не получается:<br /></p><div class="codebox"><pre><code>ByteArray(ByRef src, bytes, copy:=false)
{
	ByteArr := ComObjArray(0x11, bytes) ; VT_ARRAY|VT_UI1
	ComObjFlags(ByteArr, -1) ; Remove F_OWNVALUE flag
	NumPut(IsByRef(src) ? &amp;src : src, ComObjValue(ByteArr) + 12 + (A_PtrSize==8 ? 4 : 0))
	return copy ? ByteArr.Clone() : ByteArr
}</code></pre></div><p>Проверял через заливку на файлообменник файла более 1 гига.<br />На 64 битах работает, на 32 битах нет.<br /></p><div class="codebox"><pre><code>path := &quot;D:\test.mp4&quot;


HTTP := ComObjCreate(&quot;WinHTTP.WinHTTPRequest.5.1&quot;)
HTTP.Open(&quot;GET&quot;, &quot;https://failiem.lv&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)PHPSESSID=(.+?)&quot;&quot;.+?strCurrentUploadCallServer = &#039;(.+?)\.&quot;, match)
phpsessid := match1, server := match2

HTTP.Open(&quot;GET&quot;, &quot;https://failiem.lv/server_scripts/get_upload_id.php?show_add_key=1&quot;, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
RegexMatch(HTTP.ResponseText, &quot;s)(.+?),.+?,(.+?)$&quot;, match)
up_id := match1, key := match2

now := A_NowUTC
EnvSub, now,1970, seconds
now .= A_MSec
objParam := {file: [path]}
CreateFormData(PostData, hdr_ContentType, objParam)

HTTP.SetTimeouts(0, 0, 0, 0)
HTTP.Open(&quot;POST&quot;, &quot;https://&quot; server &quot;.failiem.lv/save_file.php?PHPSESSID=&quot; phpsessid &quot;&amp;up_id=&quot; up_id &quot;&amp;ignore_user_abort=1&amp;skip_update=1&amp;key=&quot; key &quot;&amp;v=&quot; now, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)&quot;)
HTTP.SetRequestHeader(&quot;Content-Type&quot;, hdr_ContentType)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send(PostData)
HTTP.WaitForResponse()
uploadedLink := &quot;https://failiem.lv/u/&quot; up_id

; проверка загрузки
HTTP.SetTimeouts(0, 60000, 30000, 30000)
HTTP.Open(&quot;GET&quot;, uploadedLink, true)
HTTP.SetRequestHeader(&quot;User-Agent&quot;, &quot;Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko)&quot;)
HTTP.SetRequestHeader(&quot;Pragma&quot;, &quot;no-cache&quot;)
HTTP.SetRequestHeader(&quot;Cache-Control&quot;, &quot;no-cache, no-store&quot;)
HTTP.SetRequestHeader(&quot;If-Modified-Since&quot;, &quot;Sat, 1 Jan 2000 00:00:00 GMT&quot;)
HTTP.Send()
HTTP.WaitForResponse()
if InStr(HTTP.ResponseText, &quot;tools_button_download&quot;)
   msgbox % clipboard := uploadedLink
else
   msgbox Error
return


; CreateFormData() by tmplinshi, AHK Topic: https://autohotkey.com/boards/viewtopic.php?t=7647
; Thanks to Coco: https://autohotkey.com/boards/viewtopic.php?p=41731#p41731
; Modified version by SKAN, 09/May/2016

CreateFormData(ByRef retData, ByRef retHeader, objParam) {
	New CreateFormData(retData, retHeader, objParam)
}

Class CreateFormData {

	__New(ByRef retData, ByRef retHeader, objParam) {

		Local CRLF := &quot;`r`n&quot;, i, k, v, str, pvData
		; Create a random Boundary
		Local Boundary := this.RandomBoundary()
		Local BoundaryLine := &quot;------------------------------&quot; . Boundary

    this.Len := 0 ; GMEM_ZEROINIT|GMEM_FIXED = 0x40
    this.Ptr := DllCall( &quot;GlobalAlloc&quot;, &quot;UInt&quot;,0x40, &quot;UInt&quot;,1, &quot;Ptr&quot;  )          ; allocate global memory

		; Loop input paramters
		For k, v in objParam
		{
			If IsObject(v) {
				For i, FileName in v
				{
					str := BoundaryLine . CRLF
					     . &quot;Content-Disposition: form-data; name=&quot;&quot;&quot; . k . &quot;&quot;&quot;; filename=&quot;&quot;&quot; . FileName . &quot;&quot;&quot;&quot; . CRLF
					     . &quot;Content-Type: &quot; . this.MimeType(FileName) . CRLF . CRLF
          this.StrPutUTF8( str )
          this.LoadFromFile( Filename )
          this.StrPutUTF8( CRLF )
				}
			} Else {
				str := BoundaryLine . CRLF
				     . &quot;Content-Disposition: form-data; name=&quot;&quot;&quot; . k &quot;&quot;&quot;&quot; . CRLF . CRLF
				     . v . CRLF
        this.StrPutUTF8( str )
			}
		}

		this.StrPutUTF8( BoundaryLine . &quot;--&quot; . CRLF )

    ; Create a bytearray and copy data in to it.
    retData := ComObjArray( 0x11, this.Len ) ; Create SAFEARRAY = VT_ARRAY|VT_UI1
    pvData  := NumGet( ComObjValue( retData ) + 8 + A_PtrSize )
    DllCall( &quot;RtlMoveMemory&quot;, &quot;Ptr&quot;,pvData, &quot;Ptr&quot;,this.Ptr, &quot;Ptr&quot;,this.Len )

    this.Ptr := DllCall( &quot;GlobalFree&quot;, &quot;Ptr&quot;,this.Ptr, &quot;Ptr&quot; )                   ; free global memory 

    retHeader := &quot;multipart/form-data; boundary=----------------------------&quot; . Boundary
	}

  StrPutUTF8( str ) {
    Local ReqSz := StrPut( str, &quot;utf-8&quot; ) - 1
    this.Len += ReqSz                                  ; GMEM_ZEROINIT|GMEM_MOVEABLE = 0x42
    this.Ptr := DllCall( &quot;GlobalReAlloc&quot;, &quot;Ptr&quot;,this.Ptr, &quot;UInt&quot;,this.len + 1, &quot;UInt&quot;, 0x42 )   
    StrPut( str, this.Ptr + this.len - ReqSz, ReqSz, &quot;utf-8&quot; )
  }
  
  LoadFromFile( Filename ) {
    Local objFile := FileOpen( FileName, &quot;r&quot; )
    this.Len += objFile.Length                     ; GMEM_ZEROINIT|GMEM_MOVEABLE = 0x42 
    this.Ptr := DllCall( &quot;GlobalReAlloc&quot;, &quot;Ptr&quot;,this.Ptr, &quot;UInt&quot;,this.len, &quot;UInt&quot;, 0x42 )
    objFile.RawRead( this.Ptr + this.Len - objFile.length, objFile.length )
    objFile.Close()       
  }

	RandomBoundary() {
		str := &quot;0|1|2|3|4|5|6|7|8|9|a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z&quot;
		Sort, str, D| Random
		str := StrReplace(str, &quot;|&quot;)
		Return SubStr(str, 1, 12)
	}

	MimeType(FileName) {
		n := FileOpen(FileName, &quot;r&quot;).ReadUInt()
		Return (n        = 0x474E5089) ? &quot;image/png&quot;
		     : (n        = 0x38464947) ? &quot;image/gif&quot;
		     : (n&amp;0xFFFF = 0x4D42    ) ? &quot;image/bmp&quot;
		     : (n&amp;0xFFFF = 0xD8FF    ) ? &quot;image/jpeg&quot;
		     : (n&amp;0xFFFF = 0x4949    ) ? &quot;image/tiff&quot;
		     : (n&amp;0xFFFF = 0x4D4D    ) ? &quot;image/tiff&quot;
		     : &quot;application/octet-stream&quot;
	}

}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[Malcev]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26930</uri>
			</author>
			<updated>2019-08-04T13:24:36Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135229#p135229</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Упаковка больших файлов (>1Gb) в COM bytearray на ahk32 bit]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=135227#p135227" />
			<content type="html"><![CDATA[<p>Можно, в принципе, и вручную создать структуру SAFEARRAY, заполнить. Кажись я как-то делал. Хотя ведь и функции для этого есть в WinAPI, насколько помню, целый набор для работы с SAFEARRAY. Но с такими большими файлами я не пробовал.</p>]]></content>
			<author>
				<name><![CDATA[YMP]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=81</uri>
			</author>
			<updated>2019-08-04T13:02:28Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=135227#p135227</id>
		</entry>
</feed>
