• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

試験的なTTX置き場


コミットメタ情報

リビジョン261e426374413f9069b732251a7195627b8649b1 (tree)
日時2016-09-08 19:47:19
作者IWAMOTO Kouichi <sue@iwmt...>
コミッターIWAMOTO Kouichi

ログメッセージ

管理者権限のチェックのテスト

変更サマリ

差分

--- /dev/null
+++ b/TTXCheckAdminPriv/LICENSE
@@ -0,0 +1,22 @@
1+Copyright (c) 2015 IWAMOTO Kouichi
2+
3+Redistribution and use in source and binary forms, with or without
4+modification, are permitted provided that the following conditions
5+are met:
6+
7+1. Redistributions of source code must retain the above copyright
8+notice, this list of conditions and the following disclaimer.
9+2. Redistributions in binary form must reproduce the above copyright
10+notice, this list of conditions and the following disclaimer in the
11+documentation and/or other materials provided with the distribution.
12+
13+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
15+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
16+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
17+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
18+NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
19+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
20+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22+THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+++ b/TTXCheckAdminPriv/ReadMe.txt
@@ -0,0 +1,6 @@
1+TTXCheckAdminPriv -- 管理者権限があるかの確認
2+
3+機能:
4+ Tera Term 起動時に管理者権限があるかを確認し、権限がある場合は Help Menu に
5+ elevated という何もしないメニューを追加します。
6+ UAC 環境では UAC での権限の昇格を行っている時のみ追加します。
--- /dev/null
+++ b/TTXCheckAdminPriv/TTXCheckAdminPriv.c
@@ -0,0 +1,154 @@
1+/*
2+ * Copyright (c) 2016 IWAMOTO Kouichi
3+ *
4+ * Redistribution and use in source and binary forms, with or without
5+ * modification, are permitted provided that the following conditions
6+ * are met:
7+ *
8+ * 1. Redistributions of source code must retain the above copyright
9+ * notice, this list of conditions and the following disclaimer.
10+ * 2. Redistributions in binary form must reproduce the above copyright
11+ * notice, this list of conditions and the following disclaimer in the
12+ * documentation and/or other materials provided with the distribution.
13+ *
14+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
15+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
18+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24+ */
25+
26+#include "teraterm.h"
27+#include "tttypes.h"
28+#include "ttplugin.h"
29+#include "tt_res.h"
30+#include <stdlib.h>
31+#include <stdio.h>
32+#include <windows.h>
33+
34+#include "compat_w95.h"
35+
36+#define ORDER 5900
37+
38+#define ID_MENUID 59055
39+
40+static HANDLE hInst; /* Instance handle of TTX*.DLL */
41+
42+typedef struct {
43+ PTTSet ts;
44+ PComVar cv;
45+ BOOL elevated;
46+} TInstVar;
47+
48+static TInstVar FAR * pvar;
49+static TInstVar InstVar;
50+
51+#define GetFileMenu(menu) GetSubMenuByChildID(menu, ID_FILE_NEWCONNECTION)
52+#define GetEditMenu(menu) GetSubMenuByChildID(menu, ID_EDIT_COPY2)
53+#define GetSetupMenu(menu) GetSubMenuByChildID(menu, ID_SETUP_TERMINAL)
54+#define GetControlMenu(menu) GetSubMenuByChildID(menu, ID_CONTROL_RESETTERMINAL)
55+#define GetHelpMenu(menu) GetSubMenuByChildID(menu, ID_HELP_ABOUT)
56+
57+HMENU GetSubMenuByChildID(HMENU menu, UINT id) {
58+ int i, j, items, subitems, cur_id;
59+ HMENU m;
60+
61+ items = GetMenuItemCount(menu);
62+
63+ for (i=0; i<items; i++) {
64+ if (m = GetSubMenu(menu, i)) {
65+ subitems = GetMenuItemCount(m);
66+ for (j=0; j<subitems; j++) {
67+ cur_id = GetMenuItemID(m, j);
68+ if (cur_id == id) {
69+ return m;
70+ }
71+ }
72+ }
73+ }
74+ return NULL;
75+}
76+
77+static void PASCAL FAR TTXInit(PTTSet ts, PComVar cv) {
78+ HANDLE token;
79+ DWORD len;
80+
81+ TOKEN_ELEVATION elevation;
82+
83+ pvar->ts = ts;
84+ pvar->cv = cv;
85+ pvar->elevated = FALSE;
86+
87+ if (OpenProcessToken(GetCurrentProcess(), TOKEN_QUERY, &token)) {
88+ if (GetTokenInformation(token, TokenElevation, &elevation, sizeof(elevation), &len)) {
89+ pvar->elevated = elevation.TokenIsElevated;
90+ }
91+ CloseHandle(token);
92+ }
93+}
94+
95+static void PASCAL FAR TTXModifyMenu(HMENU menu) {
96+ MENUITEMINFO mi;
97+ HMENU HelpMenu;
98+
99+ HelpMenu = GetHelpMenu(menu);
100+
101+ if (pvar->elevated) {
102+ InsertMenu(HelpMenu, -1, MF_BYPOSITION | MF_STRING, ID_MENUID, "elevated");
103+ }
104+}
105+
106+static TTXExports Exports = {
107+ sizeof(TTXExports),
108+ ORDER,
109+
110+ TTXInit,
111+ NULL, // TTXGetUIHooks,
112+ NULL, // TTXGetSetupHooks,
113+ NULL, // TTXOpenTCP,
114+ NULL, // TTXCloseTCP,
115+ NULL, // TTXSetWinSize,
116+ TTXModifyMenu,
117+ NULL, // TTXModifyPopupMenu,
118+ NULL, // TTXProcessCommand,
119+ NULL, // TTXEnd
120+};
121+
122+BOOL __declspec(dllexport) PASCAL FAR TTXBind(WORD Version, TTXExports FAR * exports) {
123+ int size = sizeof(Exports) - sizeof(exports->size);
124+
125+ if (size > exports->size) {
126+ size = exports->size;
127+ }
128+ memcpy((char FAR *)exports + sizeof(exports->size),
129+ (char FAR *)&Exports + sizeof(exports->size),
130+ size);
131+ return TRUE;
132+}
133+
134+BOOL WINAPI DllMain(HANDLE hInstance, ULONG ul_reason, LPVOID lpReserved)
135+{
136+ switch (ul_reason) {
137+ case DLL_THREAD_ATTACH:
138+ /* do thread initialization */
139+ break;
140+ case DLL_THREAD_DETACH:
141+ /* do thread cleanup */
142+ break;
143+ case DLL_PROCESS_ATTACH:
144+ /* do process initialization */
145+ DoCover_IsDebuggerPresent();
146+ hInst = hInstance;
147+ pvar = &InstVar;
148+ break;
149+ case DLL_PROCESS_DETACH:
150+ /* do process cleanup */
151+ break;
152+ }
153+ return TRUE;
154+}
--- /dev/null
+++ b/TTXCheckAdminPriv/TTXCheckAdminPriv.vcproj
@@ -0,0 +1,201 @@
1+<?xml version="1.0" encoding="shift_jis"?>
2+<VisualStudioProject
3+ ProjectType="Visual C++"
4+ Version="8.00"
5+ Name="TTXCheckAdminPriv"
6+ ProjectGUID="{A76F81AC-DD8D-43CE-AFC1-DC6A30DB5159}"
7+ RootNamespace="TTXCheckAdminPriv"
8+ Keyword="Win32Proj"
9+ >
10+ <Platforms>
11+ <Platform
12+ Name="Win32"
13+ />
14+ </Platforms>
15+ <ToolFiles>
16+ </ToolFiles>
17+ <Configurations>
18+ <Configuration
19+ Name="Debug|Win32"
20+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
21+ IntermediateDirectory="$(ConfigurationName)"
22+ ConfigurationType="2"
23+ CharacterSet="0"
24+ >
25+ <Tool
26+ Name="VCPreBuildEventTool"
27+ />
28+ <Tool
29+ Name="VCCustomBuildTool"
30+ />
31+ <Tool
32+ Name="VCXMLDataGeneratorTool"
33+ />
34+ <Tool
35+ Name="VCWebServiceProxyGeneratorTool"
36+ />
37+ <Tool
38+ Name="VCMIDLTool"
39+ />
40+ <Tool
41+ Name="VCCLCompilerTool"
42+ Optimization="0"
43+ AdditionalIncludeDirectories="$(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm"
44+ PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;_USRDLL"
45+ MinimalRebuild="true"
46+ BasicRuntimeChecks="3"
47+ RuntimeLibrary="1"
48+ UsePrecompiledHeader="0"
49+ WarningLevel="3"
50+ Detect64BitPortabilityProblems="false"
51+ DebugInformationFormat="4"
52+ />
53+ <Tool
54+ Name="VCManagedResourceCompilerTool"
55+ />
56+ <Tool
57+ Name="VCResourceCompilerTool"
58+ />
59+ <Tool
60+ Name="VCPreLinkEventTool"
61+ />
62+ <Tool
63+ Name="VCLinkerTool"
64+ AdditionalDependencies="&quot;$(SolutionDir)..\teraterm\$(ConfigurationName)\ttpcmn.lib&quot;"
65+ LinkIncremental="2"
66+ GenerateDebugInformation="true"
67+ SubSystem="2"
68+ TargetMachine="1"
69+ />
70+ <Tool
71+ Name="VCALinkTool"
72+ />
73+ <Tool
74+ Name="VCManifestTool"
75+ />
76+ <Tool
77+ Name="VCXDCMakeTool"
78+ />
79+ <Tool
80+ Name="VCBscMakeTool"
81+ />
82+ <Tool
83+ Name="VCFxCopTool"
84+ />
85+ <Tool
86+ Name="VCAppVerifierTool"
87+ />
88+ <Tool
89+ Name="VCWebDeploymentTool"
90+ />
91+ <Tool
92+ Name="VCPostBuildEventTool"
93+ />
94+ </Configuration>
95+ <Configuration
96+ Name="Release|Win32"
97+ OutputDirectory="$(SolutionDir)$(ConfigurationName)"
98+ IntermediateDirectory="$(ConfigurationName)"
99+ ConfigurationType="2"
100+ CharacterSet="0"
101+ WholeProgramOptimization="1"
102+ >
103+ <Tool
104+ Name="VCPreBuildEventTool"
105+ />
106+ <Tool
107+ Name="VCCustomBuildTool"
108+ />
109+ <Tool
110+ Name="VCXMLDataGeneratorTool"
111+ />
112+ <Tool
113+ Name="VCWebServiceProxyGeneratorTool"
114+ />
115+ <Tool
116+ Name="VCMIDLTool"
117+ />
118+ <Tool
119+ Name="VCCLCompilerTool"
120+ AdditionalIncludeDirectories="$(SolutionDir)..\teraterm\common;$(SolutionDir)..\teraterm\teraterm"
121+ PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;_USRDLL"
122+ RuntimeLibrary="0"
123+ UsePrecompiledHeader="0"
124+ WarningLevel="3"
125+ Detect64BitPortabilityProblems="false"
126+ DebugInformationFormat="3"
127+ />
128+ <Tool
129+ Name="VCManagedResourceCompilerTool"
130+ />
131+ <Tool
132+ Name="VCResourceCompilerTool"
133+ />
134+ <Tool
135+ Name="VCPreLinkEventTool"
136+ />
137+ <Tool
138+ Name="VCLinkerTool"
139+ AdditionalDependencies="&quot;$(SolutionDir)..\teraterm\$(ConfigurationName)\ttpcmn.lib&quot;"
140+ LinkIncremental="1"
141+ GenerateDebugInformation="true"
142+ SubSystem="2"
143+ OptimizeReferences="2"
144+ EnableCOMDATFolding="2"
145+ TargetMachine="1"
146+ />
147+ <Tool
148+ Name="VCALinkTool"
149+ />
150+ <Tool
151+ Name="VCManifestTool"
152+ />
153+ <Tool
154+ Name="VCXDCMakeTool"
155+ />
156+ <Tool
157+ Name="VCBscMakeTool"
158+ />
159+ <Tool
160+ Name="VCFxCopTool"
161+ />
162+ <Tool
163+ Name="VCAppVerifierTool"
164+ />
165+ <Tool
166+ Name="VCWebDeploymentTool"
167+ />
168+ <Tool
169+ Name="VCPostBuildEventTool"
170+ />
171+ </Configuration>
172+ </Configurations>
173+ <References>
174+ </References>
175+ <Files>
176+ <Filter
177+ Name="Source Files"
178+ Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
179+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
180+ >
181+ <File
182+ RelativePath="TTXCheckAdminPriv.c"
183+ >
184+ </File>
185+ </Filter>
186+ <Filter
187+ Name="ReadMe"
188+ >
189+ <File
190+ RelativePath="LICENSE"
191+ >
192+ </File>
193+ <File
194+ RelativePath="ReadMe.txt"
195+ >
196+ </File>
197+ </Filter>
198+ </Files>
199+ <Globals>
200+ </Globals>
201+</VisualStudioProject>