<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Серый форум &mdash; AHK: Ограничить права привилегии приложения]]></title>
	<link rel="self" href="https://forum.script-coding.com/extern.php?action=feed&amp;tid=11722&amp;type=atom" />
	<updated>2016-06-15T11:25:43Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.script-coding.com/viewtopic.php?id=11722</id>
		<entry>
			<title type="html"><![CDATA[Re: AHK: Ограничить права привилегии приложения]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105239#p105239" />
			<content type="html"><![CDATA[<p>Пробовали setSeDebugPrivilege(0) вызывать?</p>]]></content>
			<author>
				<name><![CDATA[Drugoy]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27463</uri>
			</author>
			<updated>2016-06-15T11:25:43Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105239#p105239</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[AHK: Ограничить права привилегии приложения]]></title>
			<link rel="alternate" href="https://forum.script-coding.com/viewtopic.php?pid=105229#p105229" />
			<content type="html"><![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>]]></content>
			<author>
				<name><![CDATA[Dworkin]]></name>
				<uri>https://forum.script-coding.com/profile.php?id=27052</uri>
			</author>
			<updated>2016-06-14T21:06:24Z</updated>
			<id>https://forum.script-coding.com/viewtopic.php?pid=105229#p105229</id>
		</entry>
</feed>
