<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title><![CDATA[Серый форум &mdash; AHK: Ограничить права привилегии приложения]]></title>
		<link>https://forum.script-coding.com/viewtopic.php?id=11722</link>
		<atom:link href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11722&amp;type=rss" rel="self" type="application/rss+xml" />
		<description><![CDATA[Недавние сообщения в теме «AHK: Ограничить права привилегии приложения».]]></description>
		<lastBuildDate>Wed, 15 Jun 2016 11:25:43 +0000</lastBuildDate>
		<generator>PunBB</generator>
		<item>
			<title><![CDATA[Re: AHK: Ограничить права привилегии приложения]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105239#p105239</link>
			<description><![CDATA[<p>Пробовали setSeDebugPrivilege(0) вызывать?</p>]]></description>
			<author><![CDATA[null@example.com (Drugoy)]]></author>
			<pubDate>Wed, 15 Jun 2016 11:25:43 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105239#p105239</guid>
		</item>
		<item>
			<title><![CDATA[AHK: Ограничить права привилегии приложения]]></title>
			<link>https://forum.script-coding.com/viewtopic.php?pid=105229#p105229</link>
			<description><![CDATA[<p>Добрый вечер. Помогите пожалуйста.<br />Как-то мне надо было прочитать из памяти процесса кое-какую информации с помощью ahk, но при чтении мне ничего не выдавало, то есть выдавало пустоту. Я нашел ответ в этой функции:<br /></p><div class="codebox"><pre><code>setSeDebugPrivilege(enable := True)
{
    h := DllCall(&quot;OpenProcess&quot;, &quot;UInt&quot;, 0x0400, &quot;Int&quot;, false, &quot;UInt&quot;, DllCall(&quot;GetCurrentProcessId&quot;), &quot;Ptr&quot;)
    ; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
    DllCall(&quot;Advapi32.dll\OpenProcessToken&quot;, &quot;Ptr&quot;, h, &quot;UInt&quot;, 32, &quot;PtrP&quot;, t)
    VarSetCapacity(ti, 16, 0)  ; structure of privileges
    NumPut(1, ti, 0, &quot;UInt&quot;)  ; one entry in the privileges array...
    ; Retrieves the locally unique identifier of the debug privilege:
    DllCall(&quot;Advapi32.dll\LookupPrivilegeValue&quot;, &quot;Ptr&quot;, 0, &quot;Str&quot;, &quot;SeDebugPrivilege&quot;, &quot;Int64P&quot;, luid)
    NumPut(luid, ti, 4, &quot;Int64&quot;)
    if enable
    	NumPut(2, ti, 12, &quot;UInt&quot;)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
    ; Update the privileges of this process with the new access token:
    r := DllCall(&quot;Advapi32.dll\AdjustTokenPrivileges&quot;, &quot;Ptr&quot;, t, &quot;Int&quot;, false, &quot;Ptr&quot;, &amp;ti, &quot;UInt&quot;, 0, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, 0)
    DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, t)  ; close this access token handle to save memory
    DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, h)  ; close this process handle to save memory
    return r
}</code></pre></div><p>ее надо было помещать в начало скрипта, запускать от имени администратора и тогда скрипт выглядел так:<br /></p><div class="codebox"><pre><code>
if not A_IsAdmin
{
    Run *RunAs &quot;%A_ScriptFullPath%&quot;
    ExitApp
}

setSeDebugPrivilege(Enable)

 ;тут был код для чтения памяти приложения

setSeDebugPrivilege(enable := True)
{
    h := DllCall(&quot;OpenProcess&quot;, &quot;UInt&quot;, 0x0400, &quot;Int&quot;, false, &quot;UInt&quot;, DllCall(&quot;GetCurrentProcessId&quot;), &quot;Ptr&quot;)
    ; Open an adjustable access token with this process (TOKEN_ADJUST_PRIVILEGES = 32)
    DllCall(&quot;Advapi32.dll\OpenProcessToken&quot;, &quot;Ptr&quot;, h, &quot;UInt&quot;, 32, &quot;PtrP&quot;, t)
    VarSetCapacity(ti, 16, 0)  ; structure of privileges
    NumPut(1, ti, 0, &quot;UInt&quot;)  ; one entry in the privileges array...
    ; Retrieves the locally unique identifier of the debug privilege:
    DllCall(&quot;Advapi32.dll\LookupPrivilegeValue&quot;, &quot;Ptr&quot;, 0, &quot;Str&quot;, &quot;SeDebugPrivilege&quot;, &quot;Int64P&quot;, luid)
    NumPut(luid, ti, 4, &quot;Int64&quot;)
    if enable
    	NumPut(2, ti, 12, &quot;UInt&quot;)  ; enable this privilege: SE_PRIVILEGE_ENABLED = 2
    ; Update the privileges of this process with the new access token:
    r := DllCall(&quot;Advapi32.dll\AdjustTokenPrivileges&quot;, &quot;Ptr&quot;, t, &quot;Int&quot;, false, &quot;Ptr&quot;, &amp;ti, &quot;UInt&quot;, 0, &quot;Ptr&quot;, 0, &quot;Ptr&quot;, 0)
    DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, t)  ; close this access token handle to save memory
    DllCall(&quot;CloseHandle&quot;, &quot;Ptr&quot;, h)  ; close this process handle to save memory
    return r
}</code></pre></div><p>Я так понял что функция выдавала что-то типа более высоких прав для чтения памяти процесса.<br />Теперь как мне ограничить права на чтение процесса что бы при чтении памяти ничего не выдавало точнее пустые значения?</p>]]></description>
			<author><![CDATA[null@example.com (Dworkin)]]></author>
			<pubDate>Tue, 14 Jun 2016 21:06:24 +0000</pubDate>
			<guid>https://forum.script-coding.com/viewtopic.php?pid=105229#p105229</guid>
		</item>
	</channel>
</rss>
