<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Чтение значени VirtualProtect]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=13144</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=13144&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Чтение значени VirtualProtect».]]></description>
		<lastBuildDate>Mon, 30 Oct 2017 05:23:51 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120608#p120608</link>
			<description><![CDATA[<p><a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366786(v=vs.85).aspx">Memory Protection Constants</a></p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Mon, 30 Oct 2017 05:23:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120608#p120608</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120598#p120598</link>
			<description><![CDATA[<p>Спасибо, работает, но как понять что к чему относится 2 и тд?</p>]]></description>
			<author><![CDATA[null@example.com (Dworkin)]]></author>
			<pubDate>Sun, 29 Oct 2017 23:21:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120598#p120598</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120587#p120587</link>
			<description><![CDATA[<div class="codebox"><pre><code>GetAccessProtection(PID, addr)  {
   static PROCESS_QUERY_INFORMATION := 0x400
   hProcess := DllCall(&quot;OpenProcess&quot;, UInt, PROCESS_QUERY_INFORMATION, UInt, 0, UInt, PID, Ptr)
   VarSetCapacity(MEMORY_BASIC_INFORMATION, size := A_PtrSize*4 + 4*2 + A_PtrSize, 0)
   if !res := DllCall(&quot;VirtualQueryEx&quot;, Ptr, hProcess, Ptr, addr, Ptr, &amp;MEMORY_BASIC_INFORMATION, Ptr, size)
      MsgBox, % &quot;Error: &quot; A_LastError
   DllCall(&quot;CloseHandle&quot;, Ptr, hProcess)
   if res
      Return  NumGet(MEMORY_BASIC_INFORMATION, A_PtrSize*4 + 4, &quot;UInt&quot;)
}</code></pre></div><p>Проверить можно так:<br /></p><div class="codebox"><pre><code>Run, notepad,,, PID
WinWait, ahk_pid %PID%
RB := new RemoteBuffer(PID, 4)              ; для проверки создаём буфер в адресном пространстве блокнота с правами чтения и записи
MsgBox, % Format(&quot;{:#x}&quot;, RB.ptr)           ; адрес буфера
MsgBox, % GetAccessProtection(PID, RB.ptr)  ; должно вернуть 4 — PAGE_READWRITE

GetAccessProtection(PID, addr)  {
   static PROCESS_QUERY_INFORMATION := 0x400
   hProcess := DllCall(&quot;OpenProcess&quot;, UInt, PROCESS_QUERY_INFORMATION, UInt, 0, UInt, PID, Ptr)
   VarSetCapacity(MEMORY_BASIC_INFORMATION, size := A_PtrSize*4 + 4*2 + A_PtrSize, 0)
   if !res := DllCall(&quot;VirtualQueryEx&quot;, Ptr, hProcess, Ptr, addr, Ptr, &amp;MEMORY_BASIC_INFORMATION, Ptr, size)
      MsgBox, % &quot;Error: &quot; A_LastError
   DllCall(&quot;CloseHandle&quot;, Ptr, hProcess)
   if res
      Return  NumGet(MEMORY_BASIC_INFORMATION, A_PtrSize*4 + 4, &quot;UInt&quot;)
}

class RemoteBuffer
{
   __New(PID, size)  {
      static PROCESS_VM_OPERATION := 0x8, PROCESS_VM_WRITE := 0x20
           , PROCESS_VM_READ := 0x10, MEM_COMMIT := 0x1000, PAGE_READWRITE := 0x4
         
      if !(this.hProc := DllCall(&quot;OpenProcess&quot;, UInt, PROCESS_VM_OPERATION|PROCESS_VM_READ|PROCESS_VM_WRITE, Int, 0, UInt, PID, Ptr))
         Return
      
      if !(this.ptr := DllCall(&quot;VirtualAllocEx&quot;, Ptr, this.hProc, Ptr, 0, Ptr, size, UInt, MEM_COMMIT, UInt, PAGE_READWRITE, Ptr))
         Return, &quot;&quot;, DllCall(&quot;CloseHandle&quot;, Ptr, this.hProc)
      
      this.hHeap := DllCall(&quot;GetProcessHeap&quot;, Ptr)
   }
   
   __Delete()  {
      DllCall(&quot;VirtualFreeEx&quot;, Ptr, this.hProc, Ptr, this.ptr, UInt, 0, UInt, MEM_RELEASE := 0x8000)
      DllCall(&quot;CloseHandle&quot;, Ptr, this.hProc)
      DllCall(&quot;HeapFree&quot;, Ptr, this.hHeap, UInt, 0, Ptr, this.pHeap)
   }
   
   Read(size, offset = 0)  {
      (this.pHeap &amp;&amp; DllCall(&quot;HeapFree&quot;, Ptr, this.hHeap, UInt, 0, Ptr, this.pHeap))
      this.pHeap := DllCall(&quot;HeapAlloc&quot;, Ptr, this.hHeap, UInt, HEAP_ZERO_MEMORY := 0x8, Ptr, size, Ptr)
      if !DllCall(&quot;ReadProcessMemory&quot;, Ptr, this.hProc, Ptr, this.ptr + offset, Ptr, this.pHeap, Ptr, size, Int, 0)
         Return, 0, DllCall(&quot;MessageBox&quot;, Ptr, 0, Str, &quot;Не удалось прочитать данные`nОшибка &quot; A_LastError, Str, &quot;&quot;, UInt, 0)
      Return this.pHeap
   }
   
   Write(pLocalBuff, size, offset = 0)  {
      if !res := DllCall(&quot;WriteProcessMemory&quot;, Ptr, this.hProc, Ptr, this.ptr + offset, Ptr, pLocalBuff, Ptr, size, PtrP, writtenBytes)
         DllCall(&quot;MessageBox&quot;, Ptr, 0, Str, &quot;Не удалось записать данные`nОшибка &quot; A_LastError, Str, &quot;&quot;, UInt, 0)
      Return writtenBytes
   }
}</code></pre></div>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 29 Oct 2017 20:40:36 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120587#p120587</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120585#p120585</link>
			<description><![CDATA[<div class="codebox"><pre><code>
#NoEnv
Process Exist, process.exe
PID := ErrorLevel
hProcess := openProcess(PID)

MemoryAddress := 0x99999 ; для примера адрес

DllCall(&quot;VirtualQueryEx&quot;, &quot;ptr&quot;, hProcess, &quot;ptr&quot;, MemoryAddress, &quot;ptr&quot;, &amp;test, &quot;ptr&quot;, 1)
msgbox % &amp;test

openProcess(dwPID, dwRights = 0x1F0FFF) {
    hProcess := DllCall(&quot;OpenProcess&quot;
                        , &quot;UInt&quot;, dwRights
                        , &quot;int&quot;,  0
                        , &quot;UInt&quot;, dwPID
                        , &quot;Uint&quot;)
    if(hProcess == 0) {
        ErrorLevel := ERROR_OPEN_PROCESS
        return 0
    }
    
    ErrorLevel := ERROR_OK
    return hProcess
}
</code></pre></div><p>Функция выдает какие-то цифры, если перевести в hex то там не атрибут защиты.<br />Увидел это </p><div class="codebox"><pre><code>https://msdn.microsoft.com/en-us/library/windows/desktop/aa366775(v=vs.85).aspx</code></pre></div><p>, но msgbox % &amp;test.Protect выдает пустое значение.</p>]]></description>
			<author><![CDATA[null@example.com (Dworkin)]]></author>
			<pubDate>Sun, 29 Oct 2017 19:26:29 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120585#p120585</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120582#p120582</link>
			<description><![CDATA[<p>Судя по всему, <a href="https://msdn.microsoft.com/en-us/library/windows/desktop/aa366907%28v=vs.85%29.aspx?f=255&amp;MSPPError=-2147217396">VirtualQueryEx</a></p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 29 Oct 2017 19:02:51 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120582#p120582</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120581#p120581</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>Так в коде, который вы привели, ни о каком модуле речи не идёт, там функция меняет атрибуты защиты указанного региона процесса, хэндл которого hProcess.</p></blockquote></div><p>Получается я хотел бы функцию которая считывает атрибуты защиты указанного региона процесса, а не изменяет его.</p>]]></description>
			<author><![CDATA[null@example.com (Dworkin)]]></author>
			<pubDate>Sun, 29 Oct 2017 18:55:02 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120581#p120581</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120580#p120580</link>
			<description><![CDATA[<div class="quotebox"><cite>Dworkin пишет:</cite><blockquote><p>DLL модуль в процессе.</p></blockquote></div><p>Так в коде, который вы привели, ни о каком модуле речи не идёт, там функция меняет атрибуты защиты указанного региона процесса, хэндл которого hProcess.</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 29 Oct 2017 18:38:38 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120580#p120580</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120578#p120578</link>
			<description><![CDATA[<p>Так все манипуляции и происходят посредством работы скрипта. Класс предоставляет лишь удобную реализацию для этого. CE нужен для тонкой настройки и, благодаря имеющемуся функционалу отладчика-дизассемблера - понимания исходной картинки адресного пространства. Чтобы добиться того же с помощью одного только AHK, надо написать подобный CE инструмент, а раз он уже есть, то имеет ли смысл заморачиваться? Не могли бы Вы пояснить, для чего конкретно нужно искомое? Может быть есть иные пути решения.</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Sun, 29 Oct 2017 17:53:50 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120578#p120578</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120577#p120577</link>
			<description><![CDATA[<div class="quotebox"><cite>teadrinker пишет:</cite><blockquote><p>А что вы модулем называете?</p></blockquote></div><p>DLL модуль в процессе. Адрес страницы модуля в процессе я могу получить, а вот как получить Memory Protection Constants этой страницы я не знаю.<br /><a href="https://msdn.microsoft.com/ru-ru/library/windows/desktop/aa366786(v=vs.85).aspx">https://msdn.microsoft.com/ru-ru/librar … s.85).aspx</a></p><div class="quotebox"><cite>KusochekDobra пишет:</cite><blockquote><p> С тех пор и пользую для чтения и манипуляций со строками и значениями, не без известного CheatEngine, конечно.</p></blockquote></div><p>К сожалению мне надо именно с помощью ahk.</p>]]></description>
			<author><![CDATA[null@example.com (Dworkin)]]></author>
			<pubDate>Sun, 29 Oct 2017 17:38:32 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120577#p120577</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120576#p120576</link>
			<description><![CDATA[<p>А что вы модулем называете?</p>]]></description>
			<author><![CDATA[null@example.com (teadrinker)]]></author>
			<pubDate>Sun, 29 Oct 2017 17:30:40 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120576#p120576</guid>
		</item>
		<item>
			<title><![CDATA[Re: AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120575#p120575</link>
			<description><![CDATA[<p>Привет.<br />Не представляю, с чем конкретно мучаетесь, но позволю себе предположить, что было бы полезно попробовать функционал <a href="https://github.com/Kalamity/classMemory/blob/master/classMemory.ahk">этой прекрасной либы</a> от RHCP. Ко всем методам даны исчерпывающие описания. Мне, после нахождения этого класса больше не потребовалось что-либо ещё искать. С тех пор и пользую для чтения и манипуляций со строками и значениями, не без известного CheatEngine, конечно.</p>]]></description>
			<author><![CDATA[null@example.com (KusochekDobra)]]></author>
			<pubDate>Sun, 29 Oct 2017 17:22:18 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120575#p120575</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Чтение значени VirtualProtect]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=120569#p120569</link>
			<description><![CDATA[<p>Добрый вечер.<br />Нашел функцию которая меняет у модуля в процессе. Я не программист поэтому не знаю как правильно назвать то что оно меняет.<br /></p><div class="codebox"><pre><code>VirtualProtectEx(hProcess, lpAddress, dwSize, flNewProtect, lpflOldProtect) {
    if(!hProcess) {
        ErrorLevel := ERROR_INVALID_HANDLE
        return 0
    }
    
    dwRet := DllCall(&quot;VirtualProtectEx&quot;, &quot;UInt&quot;, hProcess, &quot;UInt&quot;, lpAddress, &quot;UInt&quot;, dwSize, &quot;UInt&quot;, flNewProtect, &quot;UInt *&quot;, lpflOldProtect)
    if(dwRet == 0) {
        ErrorLEvel := ERROR_FREE_MEMORY
        return 0
    }
    
    ErrorLevel := ERROR_OK
    return dwRet
}</code></pre></div><p>А как считать разрешение или флаги которые стоят у модуля?</p>]]></description>
			<author><![CDATA[null@example.com (Dworkin)]]></author>
			<pubDate>Sun, 29 Oct 2017 16:43:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=120569#p120569</guid>
		</item>
	</channel>
</rss>
