<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: В GUI дублируются функции]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=8204&amp;type=atom" />
	<updated>2013-04-05T02:54:03Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=8204</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71098#p71098" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>Я изменил кое-что в первом сообщении.</p></blockquote></div><p>Спасибо, так лучше!</p>]]></content>
			<author>
				<name><![CDATA[ypppu]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=5974</uri>
			</author>
			<updated>2013-04-05T02:54:03Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71098#p71098</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71078#p71078" />
			<content type="html"><![CDATA[<p>Спасибо огромное все работает, смог добавить что-то еще сам <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2013-04-03T21:38:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71078#p71078</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71072#p71072" />
			<content type="html"><![CDATA[<p>По смещению 0x474 находятся 4 байта (dword), 4 байта&nbsp; это 32 бита, каждый бит может принимать значение 0 или 1, т.е. в 4 байта можно записать аж 32 логических значения «что-то включено или выключено».<br />+2 подразумевает, что второй бит dword&#039;а по смещению 0x474 отвечает за «невидимость».<br /></p><div class="codebox"><pre><code>processName := &quot;gta_sa.exe&quot;
baseAddressPointer := 0xB7CD98
healthOffset := 0x540
armourOffset := 0x548
pedStateOffset := 0x474 ; и не спрашивайте, что такое Ped

Gui Margin, 20, 10
Gui Add, Edit, w30 vhealthValue, 9
Gui Add, Button, x+10 yp Section gHealth, Set Health
Gui Add, Edit, w30 xm varmourValue, 50
Gui Add, Button, xs yp gArmour, Set Armour
Gui Add, Button, xm gInvisibility, Toggle invisibility
Gui Show
return

GuiClose:
    ExitApp

Invisibility:
    if !baseAddress
        InitAddresses()

    pedState := ProcessReadMemory(pedStateAddress, processName, &quot;UInt&quot;)

    if (A_ThisLabel = &quot;Invisibility&quot;) ; на случай добавления кнопок и меток переключающих значения в pedState
        ToggleInvisibilityBit(pedState)

    ProcessWriteMemory(pedState, pedStateAddress, processName, &quot;UInt&quot;)
    return

Health:
Armour:
    GuiControlGet healthValue
    GuiControlGet armourValue

    if !baseAddress
        InitAddresses()

    ProcessWriteMemory(%A_ThisLabel%Value, %A_ThisLabel%Address, processName, &quot;float&quot;)
    return

InitAddresses() {
    global
    baseAddress := ProcessReadMemory(baseAddressPointer, processName)
    healthAddress := baseAddress + healthOffset
    armourAddress := baseAddress + armourOffset
    pedStateAddress := baseAddress + pedStateOffset
}

ToggleInvisibilityBit(ByRef pedState ) {
    pedState ^= 1 &lt;&lt; 1 ; так переключается 2-й бит.
}


ProcessReadMemory(address, processIDorName, type := &quot;Int&quot;, numBytes := 4) {
    VarSetCapacity(buf, numBytes, 0)

    Process Exist, %processIDorName%
    if !processID := ErrorLevel
        throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . &quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 24, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, &quot;Ptr&quot;)
        throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;ReadProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, &amp;buf, &quot;Ptr&quot;, numBytes, &quot;PtrP&quot;, numBytesRead, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        throw Exception(&quot;Failed to read process memory.`n`nError code:`t&quot; . A_LastError)

    if !numBytesRead
        throw Exception(&quot;Read 0 bytes from the`n`nprocess:`t&quot; . processIDorName . &quot;`naddress:`t&quot; . address)

    return (type = &quot;Str&quot;)
        ? StrGet(&amp;buf, numBytes)
        : NumGet(buf, type)
}

ProcessWriteMemory(ByRef data, address, processIDorName, type := &quot;Int&quot;, numBytes := 4) {
    VarSetCapacity(buf, numBytes, 0)
    (type = &quot;Str&quot;)
        ? StrPut(data, &amp;buf, numBytes)
        : NumPut(data, buf, type)

    Process Exist, %processIDorName%
    if !processID := ErrorLevel
        throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . &quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 40, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, &quot;Ptr&quot;)
        throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, &amp;buf, &quot;Ptr&quot;, numBytes, &quot;UInt&quot;, 0, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        throw Exception(&quot;Failed to write process memory.`n`nError code:`t&quot; . A_LastError)

    return result
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-04-03T19:08:34Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71072#p71072</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71068#p71068" />
			<content type="html"><![CDATA[<div class="quotebox"><cite>creature.ws пишет:</cite><blockquote><div class="quotebox"><blockquote><p>изменять его не надо</p></blockquote></div><p>А что с ним следует сделать?</p></blockquote></div><p>Я имел ввиду что не надо создавать в GUI &quot;Gui Add, Edit&quot;. </p><p>Знаю что без code, но в code нельзя выставить цвет текста, так что извиняюсь.</p><p>Красным я выделил что добавил.</p><br /><div class="quotebox"><cite>AutoHotkey script пишет:</cite><blockquote><p>processName := &quot;gta_sa.exe&quot;<br />baseAddressPointer := 0xB7CD98<br />healthOffset := 0x540<br />armourOffset := 0x548<br /><span style="color: #ff0000">invisibleoffset := 0x470</span></p><p>Gui Margin, 20, 10<br />Gui Add, Edit, w30 vhealthValue, 9<br />Gui Add, Button, x+10 yp Section gHealth, Set Health<br />Gui Add, Edit, w30 xm varmourValue, 50<br />Gui Add, Button, xs yp gArmour, Set Armour<br /><span style="color: #ff0000">Gui Add, Button, xs y+20 gInvisible, Invisible</span><br />Gui Show<br />return</p><p>GuiClose:<br />&nbsp; &nbsp; ExitApp</p><p>Health:<br />Armour:<br />&nbsp; &nbsp; GuiControlGet healthValue<br />&nbsp; &nbsp; GuiControlGet armourValue</p><p>&nbsp; &nbsp; try {<br />&nbsp; &nbsp; &nbsp; &nbsp; if !baseAddress {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; baseAddress := ProcessReadMemory(baseAddressPointer, processName)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; healthAddress := baseAddress + healthOffset<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; armourAddress := baseAddress + armourOffset<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; ProcessWriteMemory(%A_ThisLabel%Value, %A_ThisLabel%Address, processName, &quot;float&quot;)<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; catch e<br />&nbsp; &nbsp; &nbsp; &nbsp; MsgBox % e.Message<br />&nbsp; &nbsp; return</p><p><span style="color: #ff0000">Invisible:</span></p><p><span style="color: #ff0000">try<br />invisibleValue(3)</span></p><br /><p><span style="color: #ff0000">invisibleValue(value)<br />&nbsp; &nbsp; GuiControlGet invisiblehValue<br />try {<br />&nbsp; &nbsp; &nbsp; &nbsp; if !baseAddress {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; baseAddress := ProcessReadMemory(baseAddressPointer, processName)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; invisibleAddress := baseAddress + invisibleOffset<br />&nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; WriteMemory(value, invisibleAddress, &quot;gta_sa.exe&quot;, &quot;Uint&quot;)<br />&nbsp; &nbsp; }<br />&nbsp; &nbsp; catch e<br />&nbsp; &nbsp; &nbsp; &nbsp; MsgBox % e.Message<br />&nbsp; &nbsp; return</span></p><p>ProcessReadMemory(address, processIDorName, type := &quot;Int&quot;, numBytes := 4) {<br />&nbsp; &nbsp; VarSetCapacity(buf, numBytes, 0)<br />&nbsp; &nbsp; VarSetCapacity(numBytesRead, A_PtrSize, 0)</p><p>&nbsp; &nbsp; Process Exist, %processIDorName%<br />&nbsp; &nbsp; if !processID := ErrorLevel<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . </p><p>&quot;&quot;&quot;&quot;)</p><p>&nbsp; &nbsp; if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 24, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, </p><p>&quot;Ptr&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)</p><p>&nbsp; &nbsp; result := DllCall(&quot;ReadProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, </p><p>&amp;buf, &quot;Ptr&quot;, numBytes, &quot;PtrP&quot;, numBytesRead, &quot;UInt&quot;)</p><p>&nbsp; &nbsp; if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)</p><p>&nbsp; &nbsp; if !result<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Failed to read process memory.`n`nError code:`t&quot; . A_LastError)</p><p>&nbsp; &nbsp; if !numBytesRead<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Read 0 bytes from the`n`nprocess:`t&quot; . processIDorName . </p><p>&quot;`naddress:`t&quot; . address)</p><p>&nbsp; &nbsp; return NumGet(buf, 0, type)<br />}</p><p>ProcessWriteMemory(data, address, processIDorName, type := &quot;Int&quot;, numBytes := 4) {<br />&nbsp; &nbsp; VarSetCapacity(buf, numBytes, 0)<br />&nbsp; &nbsp; NumPut(data, buf, 0, type)</p><p>&nbsp; &nbsp; Process Exist, %processIDorName%<br />&nbsp; &nbsp; if !processID := ErrorLevel<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . </p><p>&quot;&quot;&quot;&quot;)</p><p>&nbsp; &nbsp; if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 40, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, </p><p>&quot;Ptr&quot;)<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)</p><p>&nbsp; &nbsp; result := DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, </p><p>&amp;buf, &quot;Ptr&quot;, numBytes, &quot;UInt&quot;, 0, &quot;UInt&quot;)</p><p>&nbsp; &nbsp; if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)</p><p>&nbsp; &nbsp; if !result<br />&nbsp; &nbsp; &nbsp; &nbsp; throw Exception(&quot;Failed to write process memory.`n`nError code:`t&quot; . A_LastError)</p><p>&nbsp; &nbsp; return result<br />}</p></blockquote></div>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2013-04-03T18:21:27Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71068#p71068</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71066#p71066" />
			<content type="html"><![CDATA[<div class="quotebox"><blockquote><p>изменять его не надо</p></blockquote></div><p>А что с ним следует сделать?<br /></p><div class="quotebox"><blockquote><p>как в этот код вставить другой оффсет</p></blockquote></div><p>При нажатии кнопок Set Armour или Set Health выполняются подпрограммы начинающиеся с метки Armour или Health соответственно. «Другой оффсет» к установке значения armour или health отношения не имеет.<br />Определитесь, что с значением по смещению 0x474 нужно делать и как эти действия должны выполнятся, после — добавьте соответствующий фрагмент кода. <br />Dword это Uint.</p>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-04-03T17:30:54Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71066#p71066</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71064#p71064" />
			<content type="html"><![CDATA[<p>Спасибо все работает <img src="//forum.script-coding.com/img/smilies/smile.png" width="15" height="15" /></p><p>Но как в этот код вставить другой оффсет если оно не float и изменять его не надо?</p><p>Базовый адрес тот же, offset = 0x474, value = 2(делает игрока невидимым) тип данных dword. Я пробовал пробовал, но у меня не получалось, ошибки не выдавало, но перс не становился невидимым, либо во обще ничего не работало ни невидимость ни жизни ни броня(</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2013-04-03T17:17:23Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71064#p71064</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71060#p71060" />
			<content type="html"><![CDATA[<p>Код, приведенный ниже, подразумевается использовать <em>вместо </em>примера из первого сообщения.<br /></p><div class="codebox"><pre><code>processName := &quot;gta_sa.exe&quot;
baseAddressPointer := 0xB7CD98
healthOffset := 0x540
armourOffset := 0x548

Gui Margin, 20, 10
Gui Add, Edit, w30 vhealthValue, 9
Gui Add, Button, x+10 yp Section gHealth, Set Health
Gui Add, Edit, w30 xm varmourValue, 50
Gui Add, Button, xs yp gArmour, Set Armour
Gui Show
return

GuiClose:
    ExitApp

Health:
Armour:
    GuiControlGet healthValue
    GuiControlGet armourValue

    try {
        if !baseAddress {
            baseAddress := ProcessReadMemory(baseAddressPointer, processName)
            healthAddress := baseAddress + healthOffset
            armourAddress := baseAddress + armourOffset
        }
        ProcessWriteMemory(%A_ThisLabel%Value, %A_ThisLabel%Address, processName, &quot;float&quot;)
    }
    catch e
        MsgBox % e.Message
    return

ProcessReadMemory(address, processIDorName, type := &quot;Int&quot;, numBytes := 4) {
    VarSetCapacity(buf, numBytes, 0)

    Process Exist, %processIDorName%
    if !processID := ErrorLevel
        throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . &quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 24, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, &quot;Ptr&quot;)
        throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;ReadProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, &amp;buf, &quot;Ptr&quot;, numBytes, &quot;PtrP&quot;, numBytesRead, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        throw Exception(&quot;Failed to read process memory.`n`nError code:`t&quot; . A_LastError)

    if !numBytesRead
        throw Exception(&quot;Read 0 bytes from the`n`nprocess:`t&quot; . processIDorName . &quot;`naddress:`t&quot; . address)

    return (type = &quot;Str&quot;)
        ? StrGet(&amp;buf, numBytes)
        : NumGet(buf, type)
}

ProcessWriteMemory(ByRef data, address, processIDorName, type := &quot;Int&quot;, numBytes := 4) {
    VarSetCapacity(buf, numBytes, 0)
    (type = &quot;Str&quot;)
        ? StrPut(data, &amp;buf, numBytes)
        : NumPut(data, buf, type)

    Process Exist, %processIDorName%
    if !processID := ErrorLevel
        throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . &quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 40, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, &quot;Ptr&quot;)
        throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, &amp;buf, &quot;Ptr&quot;, numBytes, &quot;UInt&quot;, 0, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        throw Exception(&quot;Failed to write process memory.`n`nError code:`t&quot; . A_LastError)

    return result
}</code></pre></div>]]></content>
			<author>
				<name><![CDATA[creature.ws]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=26105</uri>
			</author>
			<updated>2013-04-03T14:26:59Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71060#p71060</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: В GUI дублируются функции]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=71057#p71057" />
			<content type="html"><![CDATA[<p>Здравствуйте помогите пожалуйста со скриптом.</p><p>У вас на форуме нашел скрипт , который работает с памятью и все отлично у меня работает. <br />Я хотел сделать чтобы при нажатии кнопки в GUI мне давало определенное количество одного предмета, а при нажатии другой кнопки давало определенное количество другого предмета.</p><p>По отдельности в GUI они работают, но если их соединить вместе то пишет что функции дублируются.</p><p>Вот сам код с GUI:<br /></p><div class="codebox"><pre><code>Gui, Add, Button, default, Health 
Gui, Add, Button, default, Armour
Gui, Show,, Simple Input Example
return 

GuiClose:

ButtonHealth:
      Try
        SetActorHP(9)
    Catch e
        MsgBox,, Error, % e.Message
    return

SetActorHP(value)
{
    baseAddress := ReadMemory(0xB7CD98, &quot;gta_sa.exe&quot;, &quot;Ptr&quot;, A_PtrSize)
    WriteMemory(value, baseAddress + 0x540, &quot;gta_sa.exe&quot;, &quot;float&quot;)
}

ReadMemory(address, processIDorName, type = &quot;Int&quot;, numBytes = 4)
{
    VarSetCapacity(MVALUE, numBytes, 0)
    VarSetCapacity(numBytesRead, A_PtrSize, 0)

    Process, Exist, %processIDorName%
    if !processID := ErrorLevel
        Throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . 

&quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 24, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, 

&quot;Ptr&quot;)
        Throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;ReadProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, 

&amp;MVALUE, &quot;UInt&quot;, numBytes, &quot;UIntP&quot;, numBytesRead, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        Throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        Throw Exception(&quot;Failed to read process memory.`n`nError code:`t&quot; . A_LastError)

    if !numBytesRead
        Throw Exception(&quot;Read 0 bytes from the`n`nprocess:`t&quot; processIDorName &quot;`naddress:`t&quot; 

address)

    return NumGet(MVALUE, 0, type)
}

WriteMemory(data, address, processIDorName, type = &quot;Int&quot;, numBytes = 4)
{
    VarSetCapacity(buf, numBytes, 0)
    NumPut(data, buf, 0, type)

    Process, Exist, %processIDorName%
    if !processID := ErrorLevel
        Throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . 

&quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 40, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, 

&quot;Ptr&quot;)
        Throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, 

&amp;buf, &quot;UInt&quot;, numBytes, &quot;UInt&quot;, 0, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        Throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        Throw Exception(&quot;Failed to write process memory.`n`nError code:`t&quot; . A_LastError)

    return result
}

ButtonArmour:
     Try
        SetActorAr(50)
    Catch e
        MsgBox,, Error, % e.Message
    return

SetActorAr(value)
{
    baseAddress := ReadMemory(0xB7CD98, &quot;gta_sa.exe&quot;, &quot;Ptr&quot;, A_PtrSize)
    WriteMemory(value, baseAddress + 0x548, &quot;gta_sa.exe&quot;, &quot;float&quot;)
}

ReadMemory(address, processIDorName, type = &quot;Int&quot;, numBytes = 4)
{
    VarSetCapacity(MVALUE, numBytes, 0)
    VarSetCapacity(numBytesRead, A_PtrSize, 0)

    Process, Exist, %processIDorName%
    if !processID := ErrorLevel
        Throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . 

&quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 24, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, 

&quot;Ptr&quot;)
        Throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;ReadProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, 

&amp;MVALUE, &quot;UInt&quot;, numBytes, &quot;UIntP&quot;, numBytesRead, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        Throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        Throw Exception(&quot;Failed to read process memory.`n`nError code:`t&quot; . A_LastError)

    if !numBytesRead
        Throw Exception(&quot;Read 0 bytes from the`n`nprocess:`t&quot; processIDorName &quot;`naddress:`t&quot; 

address)

    return NumGet(MVALUE, 0, type)
}

WriteMemory(data, address, processIDorName, type = &quot;Int&quot;, numBytes = 4)
{
    VarSetCapacity(buf, numBytes, 0)
    NumPut(data, buf, 0, type)

    Process, Exist, %processIDorName%
    if !processID := ErrorLevel
        Throw Exception(&quot;Invalid process name or process ID:`n`n&quot;&quot;&quot; . processIDorName . 

&quot;&quot;&quot;&quot;)

    if !processHandle := DllCall(&quot;OpenProcess&quot;, &quot;Int&quot;, 40, &quot;UInt&quot;, 0, &quot;UInt&quot;, processID, 

&quot;Ptr&quot;)
        Throw Exception(&quot;Failed to open process.`n`nError code:`t&quot; . A_LastError)

    result := DllCall(&quot;WriteProcessMemory&quot;, &quot;Ptr&quot;, processHandle, &quot;Ptr&quot;, address, &quot;Ptr&quot;, 

&amp;buf, &quot;UInt&quot;, numBytes, &quot;UInt&quot;, 0, &quot;UInt&quot;)

    if !DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, processHandle, &quot;UInt&quot;) &amp;&amp; !result
        Throw Exception(&quot;Failed to close process handle.`n`nError code:`t&quot; . A_LastError)

    if !result
        Throw Exception(&quot;Failed to write process memory.`n`nError code:`t&quot; . A_LastError)

    return result
}
ExitApp</code></pre></div><p>Пробовал переименовать функции, но мне сложно понять что изменять и поэтому не получается(</p>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2013-04-03T11:29:47Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=71057#p71057</id>
		</entry>
</feed>
