사용자 도구

사이트 도구


사이드바

카테고리

winapi:vistauac

Update: 2012/04/20

UAC 권한 상승 창이 뜨도록 exe에 바로 manifest 주입하기

mt.exe를 활용하는 방법

mt.exe 를 이용하면 이미 생성된 실행파일에 manifest 파일을 embedding할 수 있습니다. mt.exe를 활용하는 방법에도 2가지 방법이 있을 수 있습니다.

command prompt를 이용하여 다음과 같이 입력합니다.

mt.exe -manifest MyApp.exe.manifest -outputresource:MyApp.exe;#1

여기서 #1 은 manfest 파일에 대한 resource identifier를 1로 정의한다는 의미입니다.

mt를 실행하려면 “Visual Studio (version) command prompt”를 프로그램 그룹에서 찾아 실행합니다. 이미 패스에 추가했다면 이런건 불필요하겠지만.

Visual Studio 2005 내에서 project properties를 선택하고 Build Event Tab의 Post-Build event에 다음을 입력합니다.

"$(DevEnvDir)..\..\VC\bin\mt.exe" 
-manifest "$(ProjectDir)$(TargetName).exe.manifest" 
–outputresource:"$(TargetDir)$(TargetFileName)";#1

이 명령은 한줄로 실행해야 합니다. (설마 그것도 모르진 않겠지?)

Manifest Tool을 이용하는 방법

Visual Studio 2005를 이용하여 C++ 어플리케이션을 개발하고 있다면, 좀 더 손쉽게 manifest 파일을 embedding할 수 있습니다.

project properties를 선택하고 Configuration Properties→Manifest Tool을 선택한 후, Input and Output을 선택합니다. Additional Manifest Files 에 'MyApp.exe.manifest' 와 같이 manifest 파일명을 입력하면 됩니다.

manifest example

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity version="1.0.0.0"
processorArchitecture="X86"
name="IsUserAdmin"
type="win32"/>

<description>Description of your application</description>
<!-- Identify the application security requirements. -->
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="requireAdministrator"
uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly> 

결론

각각 마음에 드는 방법으로, 2번 방법을 이용하는 것이 가장 간단하면서도, managed/native의 구분없이 사용할 수 있으므로 가장 적절하지 않을까 생각. ( 되다고 하는군요 )

이미 배포된 exe에 손을 봐야 한다면 2번이 제일 편하더군
winapi/vistauac.txt · 마지막으로 수정됨: 2022/12/05 06:28 저자 kieuns