Subversion Repositories Aucun

Compare Revisions

Ignore whitespace Rev 202 → Rev 203

/tags/1.4.7/trunk/AnyUserUnlockGina.vcxproj
0,0 → 1,221
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectName>AnyUserCanUnlockNowGina</ProjectName>
<ProjectGuid>{D818D87C-2DFB-47CE-8944-49A220F2F365}</ProjectGuid>
<RootNamespace>RemoteUnlockGina</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</GenerateManifest>
<EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</EmbedManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</GenerateManifest>
<EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</EmbedManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</GenerateManifest>
<EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</EmbedManifest>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<GenerateManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</GenerateManifest>
<EmbedManifest Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</EmbedManifest>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Aucun</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Aucun</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Aucun64</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Aucun64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WIN32_WINNT=0x0501;_DEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
<AdditionalDependencies>Advapi32.lib;user32.lib;netapi32.lib;Secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(SolutionDir)\GinaHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_WIN32_WINNT=0x0501;_DEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<UseFullPaths>false</UseFullPaths>
</ClCompile>
<Link>
<AdditionalDependencies>Advapi32.lib;user32.lib;netapi32.lib;Secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(SolutionDir)\GinaHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;_WIN32_WINNT=0x0501;NDEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>Advapi32.lib;user32.lib;netapi32.lib;Secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(SolutionDir)\GinaHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<PreprocessorDefinitions>WIN32;_WIN32_WINNT=0x0501;NDEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>Advapi32.lib;user32.lib;netapi32.lib;Secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ModuleDefinitionFile>$(SolutionDir)\GinaHook.def</ModuleDefinitionFile>
<GenerateDebugInformation>true</GenerateDebugInformation>
<GenerateMapFile>true</GenerateMapFile>
<SubSystem>Windows</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="debug.c" />
<ClCompile Include="GinaDlg.c" />
<ClCompile Include="GinaHook.c" />
<ClCompile Include="SecurityHelper.cpp" />
<ClCompile Include="Settings.c" />
<ClCompile Include="Trace.c" />
<ClCompile Include="UnlockPolicy.c" />
</ItemGroup>
<ItemGroup>
<None Include="GinaHook.Def" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="debug.h" />
<ClInclude Include="extern.h" />
<ClInclude Include="GinaDlg.h" />
<ClInclude Include="GinaHook.h" />
<ClInclude Include="global.h" />
<ClInclude Include="resource.h" />
<ClInclude Include="SecurityHelper.h" />
<ClInclude Include="Settings.h" />
<ClInclude Include="Trace.h" />
<ClInclude Include="UnlockPolicy.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="AnyUserCanUnlockNowGina.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
/tags/1.4.7/trunk/AnyUserUnlockGina.sln
0,0 → 1,36

Microsoft Visual Studio Solution File, Format Version 11.00
# Visual Studio 2010
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AnyUserCanUnlockNowGina", "AnyUserUnlockGina.vcxproj", "{D818D87C-2DFB-47CE-8944-49A220F2F365}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Debug|Win32.ActiveCfg = Debug|Win32
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Debug|Win32.Build.0 = Debug|Win32
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Debug|x64.ActiveCfg = Debug|x64
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Debug|x64.Build.0 = Debug|x64
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Release|Win32.ActiveCfg = Release|Win32
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Release|Win32.Build.0 = Release|Win32
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Release|x64.ActiveCfg = Release|x64
{D818D87C-2DFB-47CE-8944-49A220F2F365}.Release|x64.Build.0 = Release|x64
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Debug|Win32.ActiveCfg = Debug|Win32
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Debug|Win32.Build.0 = Debug|Win32
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Debug|x64.ActiveCfg = Debug|x64
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Debug|x64.Build.0 = Debug|x64
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Release|Win32.ActiveCfg = Release|Win32
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Release|Win32.Build.0 = Release|Win32
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Release|x64.ActiveCfg = Release|x64
{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
/tags/1.4.7/trunk/Sample.reg
0,0 → 1,43
REGEDIT4
 
;****************************************************************************
;* The groups whose members will be able to either unlock or force logoff
;* any user, unless the currently logged on user is a member of the unlock
;* group.
;*
;* Delete or leave empty any entry you do not use.
;*
;****************************************************************************
[HKEY_LOCAL_MACHINE\SOFTWARE\Paralint.com\Aucun\Groups]
"Unlock"="My domain\\the-users-that-can-unlock-session"
"Force logoff"="My domain\\the-regular-users-that-can-kill-a-session"
"Excluded"="Administrators"
 
;****************************************************************************
;* This is to display a message to users warning them that their session
;* could be unlocked by users of a given group. This setting has an effect
;* only if the "Unlock" group is set and the logged on user is NOT a member
;* of the "Excluded" group.
;*
;* If present, the %s will be replaced by the name of the Unlock group. See
;* online docs for details.
;*
;****************************************************************************
[HKEY_LOCAL_MACHINE\SOFTWARE\Paralint.com\Aucun\\notice]
"Caption"="Security warning"
"Text"="A custom unlocking software is installed. It allows anybody from the %s group to unlock your workstation and impersonate you.\\n\\nWould you like to log off instead ?"
 
;****************************************************************************
;* Should things go bad, you can enable a trace by adding this to the registry.
;* Send the trace to me ([email protected]) along with a description and
;* we will work it out
;****************************************************************************
;[HKEY_LOCAL_MACHINE\SOFTWARE\Paralint.com\Aucun\Debug]
;"Output"="OutputDebugString"
 
;****************************************************************************
;* If you are willing to try, I support loading a third party Gina. Keep in
;* mind that I can't do more that a honest effort to support that option.
;****************************************************************************
;[HKEY_LOCAL_MACHINE\SOFTWARE\Paralint.com\Aucun]
;"Original Gina"="some_other_gina.dll"
/tags/1.4.7/trunk/makezip.cmd
0,0 → 1,72
@echo off
 
setlocal
 
SET PROJECT_NAME=aucun
SET VCBUILD_DEFAULT_CFG=
 
echo Zipping versioned project files
if exist %PROJECT_NAME%.zip del %PROJECT_NAME%.zip
if exist %PROJECT_NAME%-src.zip del %PROJECT_NAME%-src.zip
svn st -v | findstr /V /B "[\?CDIX\!\~]" | gawk "{ $0 = substr($0, 6); print $4 }" | zip %PROJECT_NAME%-src.zip [email protected]
 
echo.
echo Preparing for build
md %PROJECT_NAME%
 
pushd %PROJECT_NAME%
 
unzip -q ..\%PROJECT_NAME%-src.zip
 
echo.
findstr /s /n DebugBreak *.c *.cpp *.h
if ERRORLEVEL 1 (
echo Building...
 
echo Aucun Win32 Release
msbuild AnyUserUnlockGina.vcxproj /nologo /v:q /p:Platform=Win32;Configuration=Release
echo Aucun Win32 Debug
msbuild AnyUserUnlockGina.vcxproj /nologo /v:q /p:Platform=Win32;Configuration=Debug
echo Aucun x64 Release
msbuild AnyUserUnlockGina.vcxproj /nologo /v:q /p:Platform=x64;Configuration=Release
echo Aucun x64 Debug
msbuild AnyUserUnlockGina.vcxproj /nologo /v:q /p:Platform=x64;Configuration=Debug
 
echo Test Win32 Release
msbuild test.vcxproj /nologo /v:q /p:Platform=Win32;Configuration=Release
echo Test Win32 Debug
msbuild test.vcxproj /nologo /v:q /p:Platform=Win32;Configuration=Debug
echo Test x64 Release
msbuild test.vcxproj /nologo /v:q /p:Platform=x64;Configuration=Release
echo Test x64 Release
msbuild test.vcxproj /nologo /v:q /p:Platform=x64;Configuration=Debug
 
echo Creating binary zip
zip -j -q ..\%PROJECT_NAME%.zip README.txt Release\%PROJECT_NAME%.dll x64\Release\%PROJECT_NAME%64.dll sample.reg
) else (
echo.
echo DebugBreak found in source code. Fix it or die.
if exist ..\%PROJECT_NAME%.zip del ..\%PROJECT_NAME%.zip
if exist ..\%PROJECT_NAME%-src.zip del ..\%PROJECT_NAME%-src.zip
)
 
popd
 
rd /s /q %PROJECT_NAME%
 
echo.
dir *.zip | findstr zip
 
echo.
unzip -l %PROJECT_NAME%.zip *.dll
if NOT ERRORLEVEL 0 (
echo.
echo Binary not found in distribution. Fix it or die.
if exist ..\%PROJECT_NAME%.zip del ..\%PROJECT_NAME%.zip
if exist ..\%PROJECT_NAME%-src.zip del ..\%PROJECT_NAME%-src.zip
)
 
echo.
echo Done.
endlocal
echo.
/tags/1.4.7/trunk/test.vcxproj
0,0 → 1,198
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}</ProjectGuid>
<RootNamespace>test</RootNamespace>
<Keyword>Win32Proj</Keyword>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Platform)\$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(ProjectName)64</TargetName>
<TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(ProjectName)64</TargetName>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;Advapi32.lib;user32.lib;netapi32.lib;credui.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;Advapi32.lib;user32.lib;netapi32.lib;credui.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;Advapi32.lib;user32.lib;netapi32.lib;credui.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Midl>
<TargetEnvironment>X64</TargetEnvironment>
</Midl>
<ClCompile>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;SECURITY_WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
</ClCompile>
<Link>
<AdditionalDependencies>kernel32.lib;Advapi32.lib;user32.lib;netapi32.lib;credui.lib;secur32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<RandomizedBaseAddress>false</RandomizedBaseAddress>
<DataExecutionPrevention>
</DataExecutionPrevention>
<TargetMachine>MachineX64</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="debug.c" />
<ClCompile Include="SecurityHelper.cpp" />
<ClCompile Include="Settings.c" />
<ClCompile Include="test.cpp" />
<ClCompile Include="Trace.c" />
<ClCompile Include="UnlockPolicy.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="debug.h" />
<ClInclude Include="extern.h" />
<ClInclude Include="SecurityHelper.h" />
<ClInclude Include="Settings.h" />
<ClInclude Include="Trace.h" />
<ClInclude Include="UnlockPolicy.h" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="AnyUserUnlockGina.vcxproj">
<Project>{d818d87c-2dfb-47ce-8944-49a220f2f365}</Project>
</ProjectReference>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
/tags/1.4.7/trunk/GinaHook.c
0,0 → 1,554
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#define _WIN32_WINNT 0x0501
 
#include <windows.h>
#include <winwlx.h>
 
#include "Ginahook.h"
#include "GinaDlg.h"
#include "global.h"
#include "trace.h"
#include "debug.h"
#include "SecurityHelper.h"
#include "Settings.h"
 
//
// Location of the real MSGINA.
//
 
#define REALGINA_PATH TEXT("MSGINA.DLL")
#define GINASTUB_VERSION (WLX_VERSION_1_4) // Highest version supported at
// this point. Remember to modify
// this as support for newer version
// is added to this program.
 
//Hooked instance of MSGINA
HINSTANCE hDll;
HINSTANCE hResourceDll;
 
//
// Winlogon function dispatch table.
//
PVOID g_pWinlogon = NULL;
static DWORD g_dwVersion = WLX_VERSION_1_4;
static HANDLE WinlogonHandle = 0;
 
static MyGinaContext gAucunContext = {0};
MyGinaContext *pgAucunContext = &gAucunContext;
 
//
// Pointers to the real MSGINA functions.
//
 
static PFWLXNEGOTIATE pfWlxNegotiate;
static PFWLXINITIALIZE pfWlxInitialize;
static PFWLXDISPLAYSASNOTICE pfWlxDisplaySASNotice;
static PFWLXLOGGEDOUTSAS pfWlxLoggedOutSAS;
static PFWLXACTIVATEUSERSHELL pfWlxActivateUserShell;
static PFWLXLOGGEDONSAS pfWlxLoggedOnSAS;
static PFWLXDISPLAYLOCKEDNOTICE pfWlxDisplayLockedNotice;
static PFWLXWKSTALOCKEDSAS pfWlxWkstaLockedSAS;
static PFWLXISLOCKOK pfWlxIsLockOk;
static PFWLXISLOGOFFOK pfWlxIsLogoffOk;
static PFWLXLOGOFF pfWlxLogoff;
static PFWLXSHUTDOWN pfWlxShutdown;
 
//
// New for version 1.1
//
static PFWLXSTARTAPPLICATION pfWlxStartApplication = NULL;
static PFWLXSCREENSAVERNOTIFY pfWlxScreenSaverNotify = NULL;
 
//
// New for version 1.2 - No new GINA interface was added, except
// a new function in the dispatch table.
//
 
//
// New for version 1.3
//
static PFWLXNETWORKPROVIDERLOAD pfWlxNetworkProviderLoad = NULL;
static PFWLXDISPLAYSTATUSMESSAGE pfWlxDisplayStatusMessage = NULL;
static PFWLXGETSTATUSMESSAGE pfWlxGetStatusMessage = NULL;
static PFWLXREMOVESTATUSMESSAGE pfWlxRemoveStatusMessage = NULL;
 
//
// New for version 1.4
//
static PWLXGETCONSOLESWITCHCREDENTIALS pfWlxGetConsoleSwitchCredentials = NULL;
static PWLXRECONNECTNOTIFY pfWlxReconnectNotify = NULL;
static PWLXDISCONNECTNOTIFY pfWlxDisconnectNotify = NULL;
 
PVOID GetHookedContext(PVOID pWlxContext)
{
return ((MyGinaContext*)pWlxContext)->mHookedContext;
}
 
//
// Hook into the real MSGINA.
//
BOOL MyInitialize(HINSTANCE hDll, DWORD dwWlxVersion)
{
//
// Get pointers to all of the WLX functions in the real MSGINA.
//
pfWlxInitialize = (PFWLXINITIALIZE) GetProcAddress(hDll, "WlxInitialize");
 
if (!pfWlxInitialize)
{
return FALSE;
}
 
pfWlxDisplaySASNotice = (PFWLXDISPLAYSASNOTICE) GetProcAddress(hDll, "WlxDisplaySASNotice");
 
if (!pfWlxDisplaySASNotice)
{
return FALSE;
}
 
pfWlxLoggedOutSAS = (PFWLXLOGGEDOUTSAS) GetProcAddress(hDll, "WlxLoggedOutSAS");
 
if (!pfWlxLoggedOutSAS)
{
return FALSE;
}
 
pfWlxActivateUserShell = (PFWLXACTIVATEUSERSHELL) GetProcAddress(hDll, "WlxActivateUserShell");
 
if (!pfWlxActivateUserShell)
{
return FALSE;
}
 
pfWlxLoggedOnSAS = (PFWLXLOGGEDONSAS) GetProcAddress(hDll, "WlxLoggedOnSAS");
 
if (!pfWlxLoggedOnSAS)
{
return FALSE;
}
 
pfWlxDisplayLockedNotice = (PFWLXDISPLAYLOCKEDNOTICE) GetProcAddress(hDll, "WlxDisplayLockedNotice");
 
if (!pfWlxDisplayLockedNotice)
{
return FALSE;
}
 
pfWlxIsLockOk = (PFWLXISLOCKOK) GetProcAddress(hDll, "WlxIsLockOk");
 
if (!pfWlxIsLockOk)
{
return FALSE;
}
 
pfWlxWkstaLockedSAS = (PFWLXWKSTALOCKEDSAS) GetProcAddress(hDll, "WlxWkstaLockedSAS");
 
if (!pfWlxWkstaLockedSAS)
{
return FALSE;
}
 
pfWlxIsLogoffOk = (PFWLXISLOGOFFOK) GetProcAddress(hDll, "WlxIsLogoffOk");
 
if (!pfWlxIsLogoffOk)
{
return FALSE;
}
 
pfWlxLogoff = (PFWLXLOGOFF) GetProcAddress(hDll, "WlxLogoff");
 
if (!pfWlxLogoff)
{
return FALSE;
}
 
pfWlxShutdown = (PFWLXSHUTDOWN) GetProcAddress(hDll, "WlxShutdown");
 
if (!pfWlxShutdown)
{
return FALSE;
}
 
//
// Load functions for version 1.1 as necessary.
//
if (dwWlxVersion > WLX_VERSION_1_0)
{
pfWlxStartApplication = (PFWLXSTARTAPPLICATION) GetProcAddress(hDll, "WlxStartApplication");
 
if (!pfWlxStartApplication)
{
return FALSE;
}
 
pfWlxScreenSaverNotify = (PFWLXSCREENSAVERNOTIFY) GetProcAddress(hDll, "WlxScreenSaverNotify");
 
if (!pfWlxScreenSaverNotify)
{
return FALSE;
}
}
 
//
// Load functions for version 1.3 as necessary.
//
if (dwWlxVersion > WLX_VERSION_1_2)
{
pfWlxNetworkProviderLoad = (PFWLXNETWORKPROVIDERLOAD)GetProcAddress(hDll, "WlxNetworkProviderLoad");
 
if (!pfWlxNetworkProviderLoad)
{
return FALSE;
}
 
pfWlxDisplayStatusMessage = (PFWLXDISPLAYSTATUSMESSAGE)GetProcAddress(hDll, "WlxDisplayStatusMessage");
 
if (!pfWlxDisplayStatusMessage)
{
return FALSE;
}
 
pfWlxGetStatusMessage =(PFWLXGETSTATUSMESSAGE)GetProcAddress(hDll, "WlxGetStatusMessage");
if (!pfWlxGetStatusMessage)
{
return FALSE;
}
 
pfWlxRemoveStatusMessage =
(PFWLXREMOVESTATUSMESSAGE)
GetProcAddress(hDll, "WlxRemoveStatusMessage");
if (!pfWlxRemoveStatusMessage)
{
return FALSE;
}
}
 
//
// Load functions for version 1.3 as necessary.
//
if (dwWlxVersion > WLX_VERSION_1_3)
{
pfWlxGetConsoleSwitchCredentials = (PWLXGETCONSOLESWITCHCREDENTIALS) GetProcAddress(hDll, "WlxGetConsoleSwitchCredentials");
if (!pfWlxGetConsoleSwitchCredentials) return FALSE;
 
pfWlxReconnectNotify = (PWLXRECONNECTNOTIFY) GetProcAddress(hDll, "WlxReconnectNotify");
if (!pfWlxReconnectNotify) return FALSE;
 
pfWlxDisconnectNotify = (PWLXDISCONNECTNOTIFY) GetProcAddress(hDll, "WlxDisconnectNotify");
if (!pfWlxDisconnectNotify) return FALSE;
 
}
 
//
// Everything loaded OK.
//
return TRUE;
}
 
 
BOOL WINAPI WlxNegotiate(DWORD dwWinlogonVersion, DWORD *pdwDllVersion)
{
DWORD dwWlxVersion = GINASTUB_VERSION;
 
//
// Load MSGINA.DLL.
//
wchar_t original_gina[MAX_PATH];
 
if(GetSettingText(L"SOFTWARE\\Paralint.com\\Aucun", L"Original Gina", original_gina, MAX_PATH) != S_OK)
wcscpy(original_gina, REALGINA_PATH);
 
if (!(hDll = LoadLibrary(original_gina)))
{
return FALSE;
}
 
//Chances are this call will not result in a module load, because either aucun or a third party Gina chained
//to us will have already loaded it.
hResourceDll = LoadLibraryEx(REALGINA_PATH, 0, LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE|LOAD_LIBRARY_AS_IMAGE_RESOURCE);
 
//
// Get pointers to WlxNegotiate function in the real MSGINA.
//
pfWlxNegotiate = (PFWLXNEGOTIATE) GetProcAddress(hDll, "WlxNegotiate");
if (!pfWlxNegotiate)
{
return FALSE;
}
 
//
// Handle older version of Winlogon.
//
if (dwWinlogonVersion < dwWlxVersion)
{
dwWlxVersion = dwWinlogonVersion;
}
 
//
// Negotiate with MSGINA for version that we can support.
//
if (!pfWlxNegotiate(dwWlxVersion, &dwWlxVersion))
{
return FALSE;
}
 
//
// Load the rest of the WLX functions from the real MSGINA.
//
if (!MyInitialize(hDll, dwWlxVersion))
{
return FALSE;
}
 
//
// Inform Winlogon which version to use.
//
*pdwDllVersion = g_dwVersion = dwWlxVersion;
 
return TRUE;
}
 
 
BOOL WINAPI WlxInitialize(LPWSTR lpWinsta, HANDLE hWlx, PVOID pvReserved, PVOID pWinlogonFunctions, PVOID * pWlxContext)
{
BOOL result;
//
// Save pointer to dispatch table.
//
// Note that g_pWinlogon will need to be properly casted to the
// appropriate version when used to call function in the dispatch
// table.
//
// For example, assuming we are at WLX_VERSION_1_3, we would call
// WlxSasNotify() as follows:
//
// ((PWLX_DISPATCH_VERSION_1_3) g_pWinlogon)->WlxSasNotify(hWlx, MY_SAS);
//
g_pWinlogon = pWinlogonFunctions;
 
WinlogonHandle = hWlx;
 
//
// Now hook the WlxDialogBoxParam() dispatch function.
//
HookWlxDialogBoxParam(g_pWinlogon, g_dwVersion);
 
//*
*pWlxContext = &gAucunContext;
gAucunContext.Winlogon = hWlx;
result = pfWlxInitialize(lpWinsta, hWlx, pvReserved, pWinlogonFunctions, &gAucunContext.mHookedContext);
 
 
/*/
result = pfWlxInitialize(lpWinsta, hWlx, pvReserved, pWinlogonFunctions, pWlxContext);
//*/
 
if(result == TRUE)
{
gAucunContext.mLSA = 0; //safety
RegisterLogonProcess(LOGON_PROCESS_NAME, &gAucunContext.mLSA);
}
 
return result;
}
 
 
VOID WINAPI WlxDisplaySASNotice(PVOID pWlxContext)
{
pfWlxDisplaySASNotice(GetHookedContext(pWlxContext));
}
 
 
int WINAPI WlxLoggedOutSAS(PVOID pWlxContext, DWORD dwSasType, PLUID pAuthenticationId, PSID pLogonSid, PDWORD pdwOptions, PHANDLE phToken, PWLX_MPR_NOTIFY_INFO pMprNotifyInfo, PVOID * pProfile)
{
int result;
 
TRACE(L"Logon attemp ");
 
result = pfWlxLoggedOutSAS(GetHookedContext(pWlxContext), dwSasType, pAuthenticationId, pLogonSid, pdwOptions, phToken, pMprNotifyInfo, pProfile);
 
if (result == WLX_SAS_ACTION_LOGON)
{
TRACEMORE(L"succeeded.\n");
 
DuplicateToken(*phToken, SecurityIdentification, &(((MyGinaContext*)pWlxContext)->mCurrentUser));
}
else
TRACEMORE(L"failed or cancelled.\n");
 
return result;
}
 
 
BOOL WINAPI WlxActivateUserShell(PVOID pWlxContext, PWSTR pszDesktopName, PWSTR pszMprLogonScript, PVOID pEnvironment)
{
return pfWlxActivateUserShell(GetHookedContext(pWlxContext), pszDesktopName, pszMprLogonScript, pEnvironment);
}
 
 
int WINAPI WlxLoggedOnSAS(PVOID pWlxContext, DWORD dwSasType, PVOID pReserved)
{
int result;
 
TRACE(L"Logged on SAS, type %d\n", dwSasType);
 
result = pfWlxLoggedOnSAS(GetHookedContext(pWlxContext), dwSasType, pReserved);
 
TRACE(L"Going back to windows (%d)\n", result);
 
return result;
}
 
 
VOID WINAPI WlxDisplayLockedNotice(PVOID pWlxContext)
{
pfWlxDisplayLockedNotice(GetHookedContext(pWlxContext));
}
 
 
BOOL WINAPI WlxIsLockOk(PVOID pWlxContext)
{
return pfWlxIsLockOk(GetHookedContext(pWlxContext));
}
 
 
int WINAPI WlxWkstaLockedSAS(PVOID pWlxContext, DWORD dwSasType)
{
int result;
 
result = pfWlxWkstaLockedSAS(GetHookedContext(pWlxContext), dwSasType);
 
if (result == WLX_SAS_ACTION_LOGOFF)
{
TRACE(L"Proceding with a force logoff (comming from AUCUN).\n");
 
result = WLX_SAS_ACTION_FORCE_LOGOFF;
}
 
return result;
}
 
 
BOOL WINAPI WlxIsLogoffOk(PVOID pWlxContext)
{
return pfWlxIsLogoffOk(GetHookedContext(pWlxContext));
}
 
 
VOID WINAPI WlxLogoff(PVOID pWlxContext)
{
pfWlxLogoff(GetHookedContext(pWlxContext));
 
TRACE(L"User logged off.\n");
CloseHandle(((MyGinaContext*)pWlxContext)->mCurrentUser);
((MyGinaContext*)pWlxContext)->mCurrentUser = 0;
}
 
 
VOID WINAPI WlxShutdown(PVOID pWlxContext, DWORD ShutdownType)
{
pfWlxShutdown(GetHookedContext(pWlxContext), ShutdownType);
LsaDeregisterLogonProcess(((MyGinaContext*)pWlxContext)->mLSA);
//The original Ginahook sample didn't release the DLL before shutting down.
//A user noticed a crash when the machine was shutdown. Turns out that WlxShutdown
//is not the last function called by Winlogon. WlxDisplayStatusMessage might be
//called a few more times.
//Since we are shutting down anyway, cleaning up is more trouble than its worth.
//FreeLibrary(hDll);
//FreeLibrary(hResourceDll);
}
 
 
//
// New for version 1.1
//
BOOL WINAPI WlxScreenSaverNotify(PVOID pWlxContext, BOOL * pSecure)
{
TRACE(L"Screen saver notification.\n");
return pfWlxScreenSaverNotify(GetHookedContext(pWlxContext), pSecure);
}
 
BOOL WINAPI WlxStartApplication(PVOID pWlxContext, PWSTR pszDesktopName, PVOID pEnvironment, PWSTR pszCmdLine)
{
BOOL result;
 
result = pfWlxStartApplication(GetHookedContext(pWlxContext), pszDesktopName, pEnvironment, pszCmdLine);
 
TRACE(L"WlxStartApplication returned %d\n", result);
return result;
}
 
 
//
// New for version 1.3
//
 
BOOL WINAPI WlxNetworkProviderLoad(PVOID pWlxContext, PWLX_MPR_NOTIFY_INFO pNprNotifyInfo)
{
return pfWlxNetworkProviderLoad(GetHookedContext(pWlxContext), pNprNotifyInfo);
}
 
 
BOOL WINAPI WlxDisplayStatusMessage(PVOID pWlxContext, HDESK hDesktop, DWORD dwOptions, PWSTR pTitle, PWSTR pMessage)
{
return pfWlxDisplayStatusMessage(GetHookedContext(pWlxContext), hDesktop, dwOptions, pTitle, pMessage);
}
 
 
BOOL WINAPI WlxGetStatusMessage(PVOID pWlxContext, DWORD * pdwOptions, PWSTR pMessage, DWORD dwBufferSize)
{
return pfWlxGetStatusMessage(GetHookedContext(pWlxContext), pdwOptions, pMessage, dwBufferSize);
}
 
 
BOOL WINAPI WlxRemoveStatusMessage(PVOID pWlxContext)
{
return pfWlxRemoveStatusMessage(GetHookedContext(pWlxContext));
}
 
 
//
// New for 1.4
//
BOOL WINAPI WlxGetConsoleSwitchCredentials(PVOID pWlxContext, PVOID pCredInfo)
{
return pfWlxGetConsoleSwitchCredentials(GetHookedContext(pWlxContext), pCredInfo);
}
 
VOID WINAPI WlxReconnectNotify(PVOID pWlxContext)
{
pfWlxReconnectNotify(GetHookedContext(pWlxContext));
}
 
VOID WINAPI WlxDisconnectNotify(PVOID pWlxContext)
{
pfWlxDisconnectNotify(GetHookedContext(pWlxContext));
}
/tags/1.4.7/trunk/GinaDlg.c
0,0 → 1,530
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#include <windows.h>
#include <winwlx.h>
#include <assert.h>
#include <lm.h>
#include <string.h>
#include <security.h>
#include <windowsx.h>
 
#include "Ginahook.h"
#include "Settings.h"
#include "UnlockPolicy.h"
 
#include "global.h"
#include "debug.h"
#include "trace.h"
#include "SecurityHelper.h"
 
 
typedef struct
{
int IDD_SAS;
int IDC_LOCKWKSTA;
int IDC_LOGOFF;
int IDD_UNLOCKPASSWORD;
int IDC_USERNAME;
int IDC_PASSWORD;
int IDC_DOMAIN;
int IDS_CAPTION;
int IDS_DOMAIN_USERNAME;
int IDS_USERNAME;
int IDS_GENERIC_UNLOCK;
}
DialogAndControlsID;
 
static const DialogAndControlsID gDialogsAndControls[] =
{
//Windows Server 2003
//XP SP3 (and probably previeus versions also, never tested)
{
1800, // IDD_SAS
1800, // IDC_LOCKWKSTA
1801, // IDC_LOGOFF
1950, // IDD_UNLOCKPASSWORD
1953, // IDC_USERNAME
1954, // IDC_PASSWORD
1956, // IDC_DOMAIN
1501, // IDS_CAPTION
1528, // IDS_DOMAIN_USERNAME
1561, // IDS_USERNAME
1528 // IDS_GENERIC_UNLOCK //1607
},
};
 
static const int nbDialogsAndControlsID = sizeof gDialogsAndControls / sizeof *gDialogsAndControls;
static int gCurrentDlgIndex = -1;
 
//
// Pointers to redirected functions.
//
 
static PWLX_DIALOG_BOX_PARAM pfWlxDialogBoxParam = NULL;
typedef struct
{
HANDLE CurrentUser;
HANDLE Winlogon;
LPARAM HookedLPARAM;
} DialogLParamHook;
 
const wchar_t gAucunWinlogonContext[] = L"Paralint.com_Aucun_WinlogonContext";
 
 
//
// Pointers to redirected dialog box.
//
 
static DLGPROC pfWlxWkstaLockedSASDlgProc = NULL;
 
//
// Local functions.
//
 
int WINAPI MyWlxDialogBoxParam(HANDLE, HANDLE, LPWSTR, HWND, DLGPROC, LPARAM);
 
BOOLEAN ShouldHookUnlockPasswordDialog();
 
 
//
// Hook WlxDialogBoxParam() dispatch function.
//
void HookWlxDialogBoxParam(PVOID pWinlogonFunctions, DWORD dwWlxVersion)
{
//WlxDialogBoxParam
pfWlxDialogBoxParam = ((PWLX_DISPATCH_VERSION_1_0) pWinlogonFunctions)->WlxDialogBoxParam;
((PWLX_DISPATCH_VERSION_1_0) pWinlogonFunctions)->WlxDialogBoxParam = MyWlxDialogBoxParam;
}
 
BOOLEAN GetDomainUsernamePassword(HWND hwndDlg, wchar_t *domain, int nbdomain, wchar_t *username, int nbusername, wchar_t *password, int nbpassword)
{
BOOLEAN result = FALSE;
 
if ((gCurrentDlgIndex >= 0) && (gCurrentDlgIndex < nbDialogsAndControlsID)) //sanity
{
if ((GetDlgItemText(hwndDlg, gDialogsAndControls[gCurrentDlgIndex].IDC_PASSWORD, password, nbpassword) > 0)
&& (GetDlgItemText(hwndDlg, gDialogsAndControls[gCurrentDlgIndex].IDC_USERNAME, username, nbusername) > 0))
{
result = TRUE; //That's enough to keep going. Let's try the domain nonetheless
 
GetDlgItemText(hwndDlg, gDialogsAndControls[gCurrentDlgIndex].IDC_DOMAIN, domain, nbdomain);
}
}
 
return result;
}
 
BOOL IsWindowsServer()
{
OSVERSIONINFOEX osvi;
DWORDLONG dwlConditionMask = 0;
 
// Initialize the OSVERSIONINFOEX structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = 5;
osvi.wProductType = VER_NT_SERVER;
 
// Initialize the condition mask.
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);
 
// Perform the test.
return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_PRODUCT_TYPE, dwlConditionMask);
}
 
 
DWORD DisplayUnlockNotice(HWND hDlg, HANDLE hWlx)
{
DWORD result = IDNO; //proceed with lock
 
wchar_t unlock[MAX_GROUPNAME] = L"";
 
if (GetGroupName(gUnlockGroupName, unlock, sizeof unlock / sizeof *unlock) == S_OK)
{
wchar_t caption[512];
wchar_t text[2048];
 
if ((GetNoticeText(L"Caption", caption, sizeof caption / sizeof *caption) == S_OK)
&& (GetNoticeText(L"Text", text, sizeof text / sizeof *text) == S_OK))
{
wchar_t message[MAX_USERNAME + sizeof text / sizeof *text];
wchar_t *read = text;
wchar_t *write = text;
 
TRACE(L"Unlock notice will be displayed.\n");
 
//Insert real \n caracters from the \n found in the string.
while (*read)
{
if ((*read == '\\') && (*(read+1) == 'n'))
{
*write++ = '\n';
read += 2;
}
else
{
*write++ = *read++;
}
}
 
*write = 0;
 
wsprintf(message, text, unlock); //Will insert group name if there is a %s in the message
result = ((PWLX_DISPATCH_VERSION_1_0) g_pWinlogon)->WlxMessageBox(hWlx, hDlg, message, caption, MB_YESNOCANCEL|MB_ICONEXCLAMATION);
}
}
 
return result;
 
}
 
DWORD DisplayForceLogoffNotice(HWND hDlg, HANDLE hWlx, HANDLE current_user)
{
DWORD result = IDCANCEL;
 
TRACE(L"About to display a notice for dialog index %d\n", gCurrentDlgIndex);
 
if ((gCurrentDlgIndex >= 0) && (gCurrentDlgIndex < nbDialogsAndControlsID)) //sanity
{
wchar_t buf[2048];
wchar_t caption[512];
 
//Start with the caption
LoadString(hResourceDll, gDialogsAndControls[gCurrentDlgIndex].IDS_CAPTION, caption, sizeof caption / sizeof *caption);
 
//Windows XP has a plain vanilla message, no insert. Let's start with that
LoadString(hResourceDll, gDialogsAndControls[gCurrentDlgIndex].IDS_GENERIC_UNLOCK, buf, sizeof buf / sizeof *buf);
 
//The format of the message is different on Windows Server. This test is somewhat short sighted,
//but we know that in the future versions there is no Gina at all ! That's why we shortcut
//the test to either Windows XP or Windows Server.
if (IsWindowsServer())
{
wchar_t format[1024];
wchar_t username[1024];
wchar_t domain[1024];
int howmany;
 
howmany = GetUsernameAndDomainFromToken(current_user, domain, sizeof domain / sizeof *domain, username, sizeof username / sizeof *username);
 
switch(howmany)
{
case 2:
{
LoadString(hResourceDll, gDialogsAndControls[gCurrentDlgIndex].IDS_DOMAIN_USERNAME, format, sizeof format / sizeof *format);
wsprintf(buf, format, domain, username, L"some time");
}
break;
case 1:
{
LoadString(hResourceDll, gDialogsAndControls[gCurrentDlgIndex].IDS_USERNAME, format, sizeof format / sizeof *format);
wsprintf(buf, format, username, L"some time");
}
break;
}
}
 
TRACE(buf);
TRACEMORE(L"\n");
 
result = ((PWLX_DISPATCH_VERSION_1_0) g_pWinlogon)->WlxMessageBox(hWlx, hDlg, buf, caption, MB_OKCANCEL|MB_ICONEXCLAMATION);
}
 
return result;
}
 
// DelPropProc is an application-defined callback function
// that deletes a window property.
BOOL CALLBACK DelPropProc(HWND hwndSubclass, LPTSTR lpszString, HANDLE hData, ULONG_PTR x) // data handle
{
RemoveProp(hwndSubclass, lpszString);
return TRUE;
}
 
INT_PTR CALLBACK MyWlxWkstaLoggedOnSASDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
INT_PTR bResult = FALSE;
 
// We hook a click on OK
if (uMsg == WM_INITDIALOG)
{
DialogLParamHook *myinitparam = (DialogLParamHook*)lParam;
 
lParam = myinitparam->HookedLPARAM;
 
SetProp(hwndDlg, gAucunWinlogonContext, myinitparam->Winlogon);
 
TRACE(L"Hooked dialog shown.\n");
}
else if (uMsg == WM_DESTROY)
{
EnumPropsEx(hwndDlg, DelPropProc, 0);
}
else if ((uMsg == WM_COMMAND) && (wParam == gDialogsAndControls[gCurrentDlgIndex].IDC_LOCKWKSTA))
{
TRACE(L"User locking workstation.\n");
/*
There is a race condition here (time of check, time of use).
We check for a certain condition and display a warning. Then we let go
and make the same test again to hook the dialog or not. An administrator
with a good sense of timing could manage set the registry just after the
test of ShouldHookUnlockPasswordDialog is made but before the actual
dialog would be hooked.
 
In other words: with good timing, an administrator with access to the
registry can prevent the unlock notice from showing.
 
Spotting the flaw is 80% of the fun... I will probably never fix it.
*/
if (ShouldHookUnlockPasswordDialog(pgAucunContext->mCurrentUser))
{
TRACE(L"Will hook dialog if allowed to.\n");
switch (DisplayUnlockNotice(hwndDlg, GetProp(hwndDlg, gAucunWinlogonContext)))
{
//We said that a custom Gina was installed, and asked "do you want
//to lof off instead" ?
case IDYES:
//Why 113 ? I didn't find this value anywhere in the header files,
//but it is the value returned by the original MSGINA DialogProc
//When you click YES on the "Are you sure you want to log off" dialog box.
TRACE(L"User wants to logoff instead.\n");
EndDialog(hwndDlg, 113);
bResult = TRUE;
break;
 
//Forget about it, I am not locking at all
case IDCANCEL:
TRACE(L"Lock request cancelled.\n");
bResult = TRUE;
break;
 
//I don't care. Lock my workstation
case IDNO:
default:
break;
}
}
}
else if (uMsg == WM_COMMAND)
{
TRACE(L"User clicked on %d\n", wParam);
}
 
if (!bResult)
bResult = pfWlxWkstaLockedSASDlgProc(hwndDlg, uMsg, wParam, lParam);
 
return bResult;
}
 
 
//
// Redirected WlxWkstaLockedSASDlgProc().
//
INT_PTR CALLBACK MyWlxWkstaLockedSASDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
INT_PTR bResult = FALSE;
 
// We hook a click on OK
if (uMsg == WM_INITDIALOG)
{
DialogLParamHook *myinitparam = (DialogLParamHook*)lParam;
 
lParam = myinitparam->HookedLPARAM;
 
SetProp(hwndDlg, gAucunWinlogonContext, myinitparam->Winlogon);
TRACE(L"Hooked dialog shown.\n");
}
else if (uMsg == WM_DESTROY)
{
EnumPropsEx(hwndDlg, DelPropProc, 0);
}
else if ((uMsg == WM_COMMAND) && (wParam == IDOK))
{
wchar_t rawdomain[MAX_DOMAIN];
wchar_t rawusername[MAX_USERNAME];
wchar_t password[MAX_PASSWORD];
 
TRACE(L"Unlock or logoff attemp\n");
 
//Get the username and password for this particular Dialog template
if (GetDomainUsernamePassword(hwndDlg, rawdomain, sizeof rawdomain / sizeof *rawdomain,
rawusername, sizeof rawusername / sizeof *rawusername,
password, sizeof password / sizeof *password))
{
wchar_t *username = 0;
wchar_t *domain = 0;
 
//Replace this hack with CredUIParseUserName
username = wcsstr(rawusername, L"\\");
 
if (username)
{
domain = rawusername;
*username++ = 0; //Null terminate the domain name and skip the separator
}
else
{
username = rawusername; //No domain entered, so point directly to the supplied buffer
if (*rawdomain)
domain = rawdomain;
}
 
if (*username && *password)
{
// Can you spot the buffer overflow vulnerability in this next line ?
TRACE(L"User %s has entered his password.\n", username);
// Don't worry, GetDomainUsernamePassword validated input length. We are safe.
 
switch (ShouldUnlockForUser(pgAucunContext->mLSA, pgAucunContext->mCurrentUser, domain, username, password))
{
case eForceLogoff:
//Might help with house keeping, instead of directly calling EndDialog
if (DisplayForceLogoffNotice(hwndDlg, GetProp(hwndDlg, gAucunWinlogonContext), pgAucunContext->mCurrentUser) == IDOK)
{
TRACE(L"User was allowed (and agreed) to forcing a logoff.\n");
PostMessage(hwndDlg, WLX_WM_SAS, WLX_SAS_TYPE_USER_LOGOFF, 0);
}
else
{
//mimic MSGINA behavior
SetDlgItemText(hwndDlg, gDialogsAndControls[gCurrentDlgIndex].IDC_PASSWORD, L"");
}
bResult = TRUE;
break;
case eUnlock:
TRACE(L"User was allowed to unlock.\n");
EndDialog(hwndDlg, IDOK);
bResult = TRUE;
break;
 
case eLetMSGINAHandleIt:
default:
TRACE(L"Will be handled by MSGINA.\n");
//Most of the time, we end up here with nothing to do
break;
}
 
SecureZeroMemory(password, sizeof password);
}
}
}
 
if (!bResult)
bResult = pfWlxWkstaLockedSASDlgProc(hwndDlg, uMsg, wParam, lParam);
 
return bResult;
}
 
//
// Redirected WlxDialogBoxParam() function.
//
int WINAPI MyWlxDialogBoxParam(HANDLE hWlx, HANDLE hInst, LPWSTR lpszTemplate, HWND hwndOwner, DLGPROC dlgprc, LPARAM dwInitParam)
{
DLGPROC proc2use = dlgprc;
LPARAM lparam2use = dwInitParam;
DialogLParamHook myInitParam = {0};
DWORD dlgid = 0;
int result = 0;
DLGPROC saved_pfWlxWkstaLockedSASDlgProc;
 
//We might doint this for nothing (if dialog is not hooked)
myInitParam.HookedLPARAM = dwInitParam;
myInitParam.Winlogon = hWlx;
 
//First user-reported bug !!!
//This function was not re-entrant with regards to pfWlxWkstaLockedSASDlgProc
saved_pfWlxWkstaLockedSASDlgProc = pfWlxWkstaLockedSASDlgProc;
 
pfWlxWkstaLockedSASDlgProc = dlgprc;
 
TRACE(L"About to create the dialog");
//
// We only know MSGINA dialogs by identifiers.
//
if (!HIWORD(lpszTemplate))
{
// Hook appropriate dialog boxes as necessary.
int i;
dlgid = LOWORD(lpszTemplate); //Cast to remove warning C4311
 
//Try to find the dialog
for (i=0; i<nbDialogsAndControlsID; ++i)
{
//Is it one of the ID we know ?
if (gDialogsAndControls[i].IDD_SAS == dlgid)
{
//The dialog that asks if you would like to change password, lock, taskmgr, etc.
TRACEMORE(L" to change password, lock wkst, taskmgr, etc.\n");
gCurrentDlgIndex = i;
 
proc2use = MyWlxWkstaLoggedOnSASDlgProc;
lparam2use = (LPARAM)&myInitParam;
 
break;
}
else if (gDialogsAndControls[i].IDD_UNLOCKPASSWORD == dlgid)
{
//The dialog where you enter your password
TRACEMORE(L" where you try to unlock a locked session\n");
 
gCurrentDlgIndex = i;
 
if (ShouldHookUnlockPasswordDialog(pgAucunContext->mCurrentUser))
{
TRACE(L"Hooking the unlock dialog\n");
proc2use = MyWlxWkstaLockedSASDlgProc; //Use our proc instead
lparam2use = (LPARAM)&myInitParam;
}
 
//No need to go on, even if nothing was hooked
break;
}
}
}
 
if (proc2use == dlgprc)
{
TRACE(L"(%d). it was not hooked.\n", dlgid);
}
 
result = pfWlxDialogBoxParam(hWlx, hInst, lpszTemplate, hwndOwner, proc2use, lparam2use);
pfWlxWkstaLockedSASDlgProc = saved_pfWlxWkstaLockedSASDlgProc;
if (proc2use != dlgprc)
{
TRACE(L"Hooked dialog returned %d\n", result);
}
else
{
TRACE(L"Regular dialog returned %d\n", result);
}
 
return result;
}
/tags/1.4.7/trunk/global.h
0,0 → 1,41
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#ifndef __GLOBAL_H__
#define __GLOBAL_H__
 
#include "extern.h"
 
EXTERN PVOID g_pWinlogon;
EXTERN MyGinaContext *pgAucunContext;
EXTERN HINSTANCE hDll;
EXTERN HINSTANCE hResourceDll;
 
#endif
 
 
/tags/1.4.7/trunk/GinaHook.Def
0,0 → 1,22
EXPORTS
DllMain
WlxNegotiate
WlxInitialize
WlxDisplaySASNotice
WlxLoggedOutSAS
WlxActivateUserShell
WlxLoggedOnSAS
WlxDisplayLockedNotice
WlxWkstaLockedSAS
WlxIsLockOk
WlxIsLogoffOk
WlxLogoff
WlxShutdown
WlxNetworkProviderLoad
WlxDisplayStatusMessage
WlxGetStatusMessage
WlxRemoveStatusMessage
WlxGetConsoleSwitchCredentials
WlxReconnectNotify
WlxStartApplication
WlxDisconnectNotify
/tags/1.4.7/trunk/Settings.c
0,0 → 1,80
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#include <windows.h>
#include "settings.h"
 
const wchar_t* gUnlockGroupName = L"unlock";
const wchar_t* gForceLogoffGroupName = L"force logoff";
const wchar_t* gExcludedGroupName = L"excluded";
 
 
 
//Will return one of the following
//S_OK We have retrieved a group name
//E_FAIL We have not retrieved a value
HRESULT GetGroupName(const wchar_t *name, wchar_t *group, DWORD size)
{
return GetSettingText(L"SOFTWARE\\Paralint.com\\Aucun\\Groups", name, group, size);
}
 
HRESULT GetNoticeText(const wchar_t *name, wchar_t *text, DWORD size)
{
return GetSettingText(L"SOFTWARE\\Paralint.com\\Aucun\\Notice", name, text, size);
}
 
HRESULT GetDebugSetting(const wchar_t *name, wchar_t *text, DWORD size)
{
return GetSettingText(L"SOFTWARE\\Paralint.com\\Aucun\\Debug", name, text, size);
}
 
 
HRESULT GetSettingText(const wchar_t *key, const wchar_t *name, wchar_t *text, DWORD size)
{
HRESULT result = E_FAIL;
DWORD type;
DWORD returnedsize = size;
 
HKEY reg;
 
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &reg) == ERROR_SUCCESS)
{
if (RegQueryValueEx(reg, name, 0, &type, (LPBYTE)text, &returnedsize) == ERROR_SUCCESS)
{
if ((type == REG_SZ) && (returnedsize < size) && (returnedsize > 0))
{
result = S_OK;
}
}
 
RegCloseKey(reg);
}
 
return result;
}
 
/tags/1.4.7/trunk/Settings.h
0,0 → 1,54
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#ifndef __SETTINGS_H__
#define __SETTINGS_H__
 
#ifndef EXTERN
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
#endif
 
#define MAX_DOMAIN 512
#define MAX_USERNAME 512
#define MAX_PASSWORD 512
#define MAX_GROUPNAME 512
 
EXTERN HRESULT GetGroupName(const wchar_t *key, wchar_t *group, DWORD size);
EXTERN HRESULT GetNoticeText(const wchar_t *name, wchar_t *text, DWORD size);
EXTERN HRESULT GetDebugSetting(const wchar_t *name, wchar_t *text, DWORD size);
EXTERN HRESULT GetSettingText(const wchar_t *key, const wchar_t *name, wchar_t *text, DWORD size);
 
EXTERN const wchar_t* gUnlockGroupName;
EXTERN const wchar_t* gForceLogoffGroupName;
EXTERN const wchar_t* gExcludedGroupName;
 
#endif
/tags/1.4.7/trunk/AnyUserUnlockGina.vcproj
0,0 → 1,443
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="AnyUserCanUnlockNowGina"
ProjectGUID="{D818D87C-2DFB-47CE-8944-49A220F2F365}"
RootNamespace="RemoteUnlockGina"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_WIN32_WINNT=0x0501;_DEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
UseFullPaths="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Advapi32.lib user32.lib netapi32.lib Secur32.lib"
OutputFile="$(OutDir)\aucun.dll"
LinkIncremental="2"
GenerateManifest="false"
ModuleDefinitionFile="$(SolutionDir)\GinaHook.def"
GenerateDebugInformation="true"
GenerateMapFile="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_WIN32_WINNT=0x0501;_DEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
UseFullPaths="false"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Advapi32.lib user32.lib netapi32.lib Secur32.lib"
OutputFile="$(OutDir)\aucun64.dll"
LinkIncremental="2"
GenerateManifest="false"
ModuleDefinitionFile="$(SolutionDir)\GinaHook.def"
GenerateDebugInformation="true"
GenerateMapFile="true"
SubSystem="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;_WIN32_WINNT=0x0501;NDEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Advapi32.lib user32.lib netapi32.lib Secur32.lib"
OutputFile="$(OutDir)\aucun.dll"
LinkIncremental="1"
GenerateManifest="false"
ModuleDefinitionFile="$(SolutionDir)\GinaHook.def"
GenerateDebugInformation="true"
GenerateMapFile="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="2"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;_WIN32_WINNT=0x0501;NDEBUG;_WINDOWS;_USRDLL;REMOTEUNLOCKGINA_EXPORTS;_CRT_SECURE_NO_WARNINGS;_CRT_SECURE_NO_DEPRECATE;SECURITY_WIN32"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="Advapi32.lib user32.lib netapi32.lib Secur32.lib"
OutputFile="$(OutDir)\aucun64.dll"
LinkIncremental="1"
GenerateManifest="false"
ModuleDefinitionFile="$(SolutionDir)\GinaHook.def"
GenerateDebugInformation="true"
GenerateMapFile="true"
SubSystem="2"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
EmbedManifest="false"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\debug.c"
>
</File>
<File
RelativePath=".\GinaDlg.c"
>
</File>
<File
RelativePath=".\GinaHook.c"
>
</File>
<File
RelativePath=".\GinaHook.Def"
>
</File>
<File
RelativePath=".\SecurityHelper.cpp"
>
</File>
<File
RelativePath=".\Settings.c"
>
</File>
<File
RelativePath=".\Trace.c"
>
</File>
<File
RelativePath=".\UnlockPolicy.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\debug.h"
>
</File>
<File
RelativePath=".\extern.h"
>
</File>
<File
RelativePath=".\GinaDlg.h"
>
</File>
<File
RelativePath=".\GinaHook.h"
>
</File>
<File
RelativePath=".\global.h"
>
</File>
<File
RelativePath=".\resource.h"
>
</File>
<File
RelativePath=".\SecurityHelper.h"
>
</File>
<File
RelativePath=".\Settings.h"
>
</File>
<File
RelativePath=".\Trace.h"
>
</File>
<File
RelativePath=".\UnlockPolicy.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
<File
RelativePath=".\AnyUserCanUnlockNowGina.rc"
>
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
/tags/1.4.7/trunk/test.vcproj
0,0 → 1,397
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9,00"
Name="test"
ProjectGUID="{F1F2E1B6-B42F-46C9-A778-47E77EFA8A6C}"
RootNamespace="test"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
<Platform
Name="x64"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SECURITY_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib Advapi32.lib user32.lib netapi32.lib credui.lib secur32.lib"
LinkIncremental="2"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;SECURITY_WIN32"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib Advapi32.lib user32.lib netapi32.lib credui.lib secur32.lib"
LinkIncremental="1"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Debug|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;SECURITY_WIN32"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="1"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib Advapi32.lib user32.lib netapi32.lib credui.lib secur32.lib"
LinkIncremental="2"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|x64"
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
ConfigurationType="1"
CharacterSet="1"
WholeProgramOptimization="1"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
TargetEnvironment="3"
/>
<Tool
Name="VCCLCompilerTool"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;SECURITY_WIN32"
RuntimeLibrary="0"
UsePrecompiledHeader="0"
WarningLevel="3"
DebugInformationFormat="3"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="kernel32.lib Advapi32.lib user32.lib netapi32.lib credui.lib secur32.lib"
LinkIncremental="1"
IgnoreAllDefaultLibraries="false"
GenerateDebugInformation="true"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="17"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\debug.c"
>
</File>
<File
RelativePath=".\SecurityHelper.cpp"
>
</File>
<File
RelativePath=".\Settings.c"
>
</File>
<File
RelativePath=".\test.cpp"
>
</File>
<File
RelativePath=".\Trace.c"
>
</File>
<File
RelativePath=".\UnlockPolicy.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\debug.h"
>
</File>
<File
RelativePath=".\extern.h"
>
</File>
<File
RelativePath=".\SecurityHelper.h"
>
</File>
<File
RelativePath=".\Settings.h"
>
</File>
<File
RelativePath=".\Trace.h"
>
</File>
<File
RelativePath=".\UnlockPolicy.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>
/tags/1.4.7/trunk/GinaHook.h
0,0 → 1,84
/*
Copyright (c) 2008, Guillaume Seguin (gui[email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#ifndef __GINAHOOK_H__
#define __GINAHOOK_H__
 
//
// Function prototypes for the GINA interface.
//
 
typedef BOOL(WINAPI * PFWLXNEGOTIATE)(DWORD, DWORD *);
typedef BOOL(WINAPI * PFWLXINITIALIZE)(LPWSTR, HANDLE, PVOID, PVOID, PVOID *);
typedef VOID(WINAPI * PFWLXDISPLAYSASNOTICE)(PVOID);
typedef int(WINAPI * PFWLXLOGGEDOUTSAS)(PVOID, DWORD, PLUID, PSID, PDWORD,
PHANDLE, PWLX_MPR_NOTIFY_INFO,
PVOID *);
typedef BOOL(WINAPI * PFWLXACTIVATEUSERSHELL)(PVOID, PWSTR, PWSTR, PVOID);
typedef int(WINAPI * PFWLXLOGGEDONSAS)(PVOID, DWORD, PVOID);
typedef VOID(WINAPI * PFWLXDISPLAYLOCKEDNOTICE)(PVOID);
typedef int(WINAPI * PFWLXWKSTALOCKEDSAS)(PVOID, DWORD);
typedef BOOL(WINAPI * PFWLXISLOCKOK)(PVOID);
typedef BOOL(WINAPI * PFWLXISLOGOFFOK)(PVOID);
typedef VOID(WINAPI * PFWLXLOGOFF)(PVOID);
typedef VOID(WINAPI * PFWLXSHUTDOWN)(PVOID, DWORD);
 
//
// New for version 1.1
//
 
typedef BOOL(WINAPI * PFWLXSCREENSAVERNOTIFY)(PVOID, BOOL *);
typedef BOOL(WINAPI * PFWLXSTARTAPPLICATION)(PVOID, PWSTR, PVOID, PWSTR);
 
//
// New for version 1.3
//
 
typedef BOOL(WINAPI * PFWLXNETWORKPROVIDERLOAD)(PVOID, PWLX_MPR_NOTIFY_INFO);
typedef BOOL(WINAPI * PFWLXDISPLAYSTATUSMESSAGE)(PVOID, HDESK, DWORD, PWSTR, PWSTR);
typedef BOOL(WINAPI * PFWLXGETSTATUSMESSAGE)(PVOID, DWORD *, PWSTR, DWORD);
typedef BOOL(WINAPI * PFWLXREMOVESTATUSMESSAGE)(PVOID);
 
//
// New for version 1.4
//
 
typedef BOOL(WINAPI * PWLXGETCONSOLESWITCHCREDENTIALS)(PVOID, PVOID);
typedef VOID(WINAPI * PWLXRECONNECTNOTIFY)(PVOID);
typedef VOID(WINAPI * PWLXDISCONNECTNOTIFY)(PVOID);
 
typedef struct
{
HANDLE mCurrentUser;
HANDLE Winlogon;
HANDLE mLSA;
PVOID mHookedContext;
} MyGinaContext;
 
 
#endif
/tags/1.4.7/trunk/GinaDlg.h
0,0 → 1,32
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
//
// Function prototypes.
//
void HookWlxDialogBoxParam(PVOID pWinlogonFunctions, DWORD dwWlxVersion);
/tags/1.4.7/trunk/UnlockPolicy.c
0,0 → 1,235
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#include <windows.h>
#include "Settings.h"
#include "UnlockPolicy.h"
#include "trace.h"
#include "debug.h"
#include "SecurityHelper.h"
 
//Converts a token to an impersonation token, if it is not already one
//
HANDLE ConvertToImpersonationToken(HANDLE token)
{
HANDLE result = token;
 
SECURITY_IMPERSONATION_LEVEL sil;
DWORD cbsil = sizeof sil;
 
//If we are not impersonating
if(GetTokenInformation(token, TokenImpersonationLevel, (LPVOID)&sil, sizeof sil, &cbsil) == 0)
{
HANDLE imptoken = 0;
 
//Change to an impersonation token
if(DuplicateToken(token, SecurityIdentification, &imptoken))
{
result = imptoken;
CloseHandle(token);
}
}
 
return result;
}
 
 
EXTERN int ShouldUnlockForUser(HANDLE lsa, HANDLE current_user, const wchar_t *domain, const wchar_t *username, const wchar_t *password)
{
int result = eLetMSGINAHandleIt; //secure by default
HANDLE token = 0;
 
wchar_t unlock[MAX_GROUPNAME] = L"";
wchar_t logoff[MAX_GROUPNAME] = L"";
 
//Get the groups early to ensure fail fast if GINA is not configured
GetGroupName(gUnlockGroupName, unlock, sizeof unlock / sizeof *unlock);
GetGroupName(gForceLogoffGroupName, logoff, sizeof logoff / sizeof *logoff);
 
//Do we have anything to work with ?
if(*unlock || *logoff)
{
BOOL logged_on = FALSE;
DWORD win32Error;
TRACE(L"We have the %s and %s group.\n", (unlock&&*unlock)?unlock:L"--", (logoff&&*logoff)?logoff:L"--");
 
//Let's see if we can authenticate the user (this will generate a event log entry if the policy requires it)
if(lsa)
{
logged_on = CallLsaLogonUser(lsa, domain, username, password, Unlock, 0, &token, 0, &win32Error);
}
else
{
logged_on = LogonUser(username, domain, password, LOGON32_LOGON_UNLOCK, LOGON32_PROVIDER_DEFAULT, &token);
win32Error = GetLastError();
}
 
if(logged_on)
{
BOOL is_same_user;
 
TRACE(L"User logged in.\n");
token = ConvertToImpersonationToken(token);
 
//Sometimes, AUCUN failed to get the current logged on user
//This is a fail safe. If something goes wrong with the detection, then
//the regulare MSGINA logic will take over.
if(current_user)
{
IsSameUser(current_user, token, &is_same_user);
 
if(is_same_user)
{
TRACE(L"Same user, unlocking.\n");
result = eUnlock;
}
else
{
TRACE(L"Different user, ");
if(UsagerEstDansGroupe(token, unlock) == S_OK)
{
TRACEMORE(L"in the unlock group, unlocking.\n");
result = eUnlock;
}
else if(UsagerEstDansGroupe(token, logoff) == S_OK)
{
TRACEMORE(L"in the logoff group, forcing a logoff.\n");
result = eForceLogoff;
}
else
{
TRACEMORE(L"no privileges we can handle.\n");
}
}
}
 
CloseHandle(token);
}
else
{
TRACEMSG(win32Error);
}
}
 
return result;
}
 
 
//----------------------------------------------------------------------
// Name : UsagerEstDansGroupe
// Description : Genere un SID a partir du nom de groupe puis verifie
// l'appartenance au groupe de l'usager. Si on nom d'usager
// est passé au lieu du nom de groupe, cette fonction le
// traite comme un groupe ne contenant que cet usager.
// Attention au leaks si vous jouez la dedans... les SID
// c'est pas joli
// Parametre : [in] HANDLE usager
// Parametre : [in] BSTR groupe
// Returns : S_OK si l'usager est dans le groupe
// S_FALSE si l'usager n'est pas dans le groupe
// E_FAIL s'il y a un bobo (on ne trouve pas le groupe)
//----------------------------------------------------------------------
HRESULT UsagerEstDansGroupe(HANDLE usager, const wchar_t *groupe)
{
HRESULT result = E_FAIL;
SID_NAME_USE snu;
WCHAR szDomain[256];
DWORD dwSidSize =0;
 
DWORD dwSize = sizeof szDomain / sizeof *szDomain;
 
if ((LookupAccountNameW(NULL, groupe, 0, &dwSidSize, szDomain, &dwSize, &snu) == 0)
&& (ERROR_INSUFFICIENT_BUFFER == GetLastError()))
{
SID *pSid = (SID*)malloc(dwSidSize);
 
if (LookupAccountNameW(NULL, groupe, pSid, &dwSidSize, szDomain, &dwSize, &snu))
{
BOOL b;
 
if (CheckTokenMembership(usager, pSid, &b))
{
if (b == TRUE)
result = S_OK;
}
else
{
result = S_FALSE;
}
}
 
//Si tout vas bien (la presque totalitée des cas), on delete notre pointeur
//avec le bon operateur.
free(pSid);
}
 
return result;
}
 
 
BOOLEAN ShouldHookUnlockPasswordDialog(HANDLE token)
{
BOOLEAN result = FALSE;
 
wchar_t unlock[MAX_GROUPNAME] = L"";
wchar_t excluded[MAX_GROUPNAME] = L"";
wchar_t forcelogoff[MAX_GROUPNAME] = L"";
 
//If there is either an unlock or force logoff group,
if((GetGroupName(gUnlockGroupName, unlock, sizeof unlock / sizeof *unlock) == S_OK)
|| (GetGroupName(gForceLogoffGroupName, forcelogoff, sizeof forcelogoff / sizeof *forcelogoff) == S_OK))
{
TRACE(L"Groups are set, ");
//User must not be in the excluded group
if(GetGroupName(gExcludedGroupName, excluded, sizeof excluded / sizeof *excluded) == S_OK)
{
//If is not blacklisted, return TRUE (so the dialog will be hooked)
if(UsagerEstDansGroupe(token, excluded) != S_OK)
{
TRACEMORE(L"user is not excluded, should hook.\n");
result = TRUE;
}
else
{
TRACEMORE(L"user is excluded and will get standard MSGINA behavior.\n");
}
}
else
{
//There is no excluded group, let's hook !
TRACEMORE(L"but there is no excluded group, should hook.\n");
result = TRUE;
}
}
else
{
TRACE(L"Neither %s or %s group present, shouldn't hook.\n", gUnlockGroupName, gForceLogoffGroupName);
}
 
return result;
}
/tags/1.4.7/trunk/UnlockPolicy.h
0,0 → 1,53
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#ifndef __UNLOCKPOLICY_H_
#define __UNLOCKPOLICY_H_
 
#ifndef EXTERN
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
#endif
 
 
enum
{
eLetMSGINAHandleIt=1,
eUnlock,
eForceLogoff,
};
 
EXTERN HANDLE ConvertToImpersonationToken(HANDLE token);
EXTERN int ShouldUnlockForUser(HANDLE lsa, HANDLE current_user, const wchar_t *domain, const wchar_t *username, const wchar_t *password);
EXTERN BOOLEAN ShouldHookUnlockPasswordDialog(HANDLE token);
EXTERN HRESULT UsagerEstDansGroupe(HANDLE usager, const wchar_t *groupe);
 
#endif
/tags/1.4.7/trunk/debug.c
0,0 → 1,302
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#ifdef _DEBUG
#include <windows.h>
#include "trace.h"
#include "debug.h"
 
typedef struct tagMessageList
{
LPCWSTR pMessageID; // Text based ID
UINT dMessageNo; // Numeric ID
BOOL bFilter; // Filter: 0=Show message, 1=Do not show
LPCWSTR pMessageDesc; // Text based description
BYTE dWParam; // wParam Signature
BYTE dLParam; // lParam Signature
BYTE dLResult; // lResult Signature
} MessageList;
 
static const MessageList g_mlTable[] =
{
{ L"WM_NULL", 0, 0, L"No operation", 0, 0, 0 },
{ L"WM_CREATE", 1, 0, L"Window created and about to be displayed", 0, 0, 0 },
{ L"WM_DESTROY", 2, 0, L"Window is being destroy and has been removed from the screen", 0, 0, 0 },
{ L"WM_MOVE", 3, 0, L"Window has been moved", 0, 0, 0 },
{ L"WM_SIZE", 5, 0, L"Window size has been changed", 0, 0, 0 },
{ L"WM_ACTIVATE", 6, 0, L"Window is either being activated for deactivated", 0, 0, 0 },
{ L"WM_SETFOCUS", 7, 0, L"Window has keyboard focus", 0, 0, 0 },
{ L"WM_KILLFOCUS", 8, 0, L"Window is about to lose focus", 0, 0, 0 },
{ L"WM_ENABLE", 10, 0, L"Window enabled state is changing", 0, 0, 0 },
{ L"WM_SETREDRAW", 11, 0, L"Allow or prevent redraws to take place", 0, 0, 0 },
{ L"WM_SETTEXT", 12, 0, L"Set the text of the window", 0, 0, 0 },
{ L"WM_GETTEXT", 13, 0, L"Retrieve corresponding window text", 0, 0, 0 },
{ L"WM_GETTEXTLENGTH", 14, 0, L"Return length, in characters, of associated text", 0, 0, 0 },
{ L"WM_PAINT", 15, 0, L"Paint a portion of the client area", 0, 0, 0 },
{ L"WM_CLOSE", 16, 0, L"Window or application should terminate", 0, 0, 0 },
{ L"WM_QUERYENDSESSION", 17, 0, L"User chose to end current Windows session", 0, 0, 0 },
{ L"WM_QUIT", 18, 0, L"Terminate application request", 0, 0, 0 },
{ L"WM_QUERYOPEN", 19, 0, L"User requested that iconic window be restored", 0, 0, 0 },
{ L"WM_ERASEBKGND", 20, 0, L"Window background must be erased", 0, 0, 0 },
{ L"WM_SYSCOLORCHANGE", 21, 0, L"A change has been made to a system color setting", 0, 0, 0 },
{ L"WM_ENDSESSION", 22, 0, L"Windows session might be ending", 0, 0, 0 },
{ L"WM_SHOWWINDOW", 24, 0, L"Window is about to be hidden or shown", 0, 0, 0 },
{ L"WM_SETTINGCHANGE", 26, 0, L"A system wide setting has changed", 0, 0, 0 },
{ L"WM_WININICHANGE", 26, 0, L"A system wide setting has changed", 0, 0, 0 },
{ L"WM_DEVMODECHANGE", 27, 0, L"User changed device-mode settings", 0, 0, 0 },
{ L"WM_ACTIVATEAPP", 28, 0, L"A window belonging to another application is about to be activated", 0, 0, 0 },
{ L"WM_FONTCHANGE", 29, 0, L"Pool of font resources has changed", 0, 0, 0 },
{ L"WM_TIMECHANGE", 30, 0, L"System time has changed", 0, 0, 0 },
{ L"WM_CANCELMODE", 31, 0, L"Window is to cancel its current mode", 0, 0, 0 },
{ L"WM_SETCURSOR", 32, 0, L"Cursor moved within window and is not captured", 0, 0, 0 },
{ L"WM_MOUSEACTIVATE", 33, 0, L"Window activation via mouse click", 0, 0, 0 },
{ L"WM_CHILDACTIVATE", 34, 0, L"MDI child window has been activated, moved, or sized", 0, 0, 0 },
{ L"WM_QUEUESYNC", 35, 0, L"Separate user-input messages from other journal playback hook messages", 0, 0, 0 },
{ L"WM_GETMINMAXINFO", 36, 0, L"Return minimum or maximum tracking size", 0, 0, 0 },
{ L"WM_PAINTICON", 38, 0, L"Icon is to be painted of minimized window", 0, 0, 0 },
{ L"WM_ICONERASEBKGND", 39, 0, L"Background of the minimized window icon must be painted", 0, 0, 0 },
{ L"WM_NEXTDLGCTL", 40, 0, L"Set the keyboard focus to a different control", 0, 0, 0 },
{ L"WM_SPOOLERSTATUS", 42, 0, L"Job as been added or removed from the Print Manager queue", 0, 0, 0 },
{ L"WM_DRAWITEM", 43, 0, L"Visual aspect of control has changed", 0, 0, 0 },
{ L"WM_MEASUREITEM", 44, 0, L"Provide measurements of owner drawn control", 0, 0, 0 },
{ L"WM_DELETEITEM", 45, 0, L"Items removed from the list/combo box", 0, 0, 0 },
{ L"WM_VKEYTOITEM", 46, 0, L"List box want keyboard input notification", 0, 0, 0 },
{ L"WM_CHARTOITEM", 47, 0, L"List box with keyboard input enabled received a character message", 0, 0, 0 },
{ L"WM_SETFONT", 48, 0, L"Set desired font window is to use while drawing text", 0, 0, 0 },
{ L"WM_GETFONT", 49, 0, L"Return the font with which the window is currently drawing its text", 0, 0, 0 },
{ L"WM_SETHOTKEY", 50, 0, L"Associate hot key", 0, 0, 0 },
{ L"WM_GETHOTKEY", 51, 0, L"Hot key association query", 0, 0, 0 },
{ L"WM_QUERYDRAGICON", 55, 0, L"Minimized iconic window is about to be dragged by user", 0, 0, 0 },
{ L"WM_COMPAREITEM", 57, 0, L"Report the relative item position in a sorted list of an owner-draw combo or list box", 0, 0, 0 },
{ L"WM_COMPACTING", 65, 0, L"System memory is low", 0, 0, 0 },
{ L"WM_WINDOWPOSCHANGING",70, 0, L"Size, position, or Z order is about to change", 0, 0, 0 },
{ L"WM_WINDOWPOSCHANGED",71, 0, L"Size, position, or Z order has changed", 0, 0, 0 },
{ L"WM_POWER", 72, 0, L"System is about to enter suspended mode", 0, 0, 0 },
{ L"WM_COPYDATA", 74, 0, L"Data has be passed to application ", 0, 0, 0 },
{ L"WM_CANCELJOURNAL", 75, 0, L"User cancelled journaling activities", 0, 0, 0 },
{ L"WM_NOTIFY", 78, 0, L"Control event occurred or requires information", 0, 0, 0 },
{ L"WM_INPUTLANGCHANGEREQUEST",80,0, L"User requests to change the current input language", 0, 0, 0 },
{ L"WM_INPUTLANGCHANGE", 81, 0, L"Input language has changed", 0, 0, 0 },
{ L"WM_TCARD", 82, 0, L"User clicked an authorable button on a WinHelp Training Card", 0, 0, 0 },
{ L"WM_HELP", 83, 0, L"User pressed F1", 0, 0, 0 },
{ L"WM_USERCHANGED", 84, 0, L"User has logged on or off", 0, 0, 0 },
{ L"WM_NOTIFYFORMAT", 85, 0, L"Return whether should use ANSI or Unicode structures", 0, 0, 0 },
{ L"WM_CONTEXTMENU", 123, 0, L"User clicked the right mouse button in the window", 0, 0, 0 },
{ L"WM_STYLECHANGING", 124, 0, L"One or more of the window's styles is about to change", 0, 0, 0 },
{ L"WM_STYLECHANGED", 125, 0, L"Window's style has changed", 0, 0, 0 },
{ L"WM_DISPLAYCHANGE", 126, 0, L"Display resolution has changed", 0, 0, 0 },
{ L"WM_GETICON", 127, 0, L"Return the handle of the large or small associated icon", 0, 0, 0 },
{ L"WM_SETICON", 128, 0, L"Set large or small icon", 0, 0, 0 },
{ L"WM_NCCREATE", 129, 0, L"Non-client area created and is about to be displayed", 0, 0, 0 },
{ L"WM_NCDESTROY", 130, 0, L"Non-client area is being destroyed", 0, 0, 0 },
{ L"WM_NCCALCSIZE", 131, 0, L"Size and position of client area must be calculated", 0, 0, 0 },
{ L"WM_NCHITTEST", 132, 0, L"Mouse cursor moved or button was pressed or released", 0, 0, 0 },
{ L"WM_NCPAINT", 133, 0, L"Frame must be painted", 0, 0, 0 },
{ L"WM_NCACTIVATE", 134, 0, L"Nonclient area needs to be changed to reflect active state", 0, 0, 0 },
{ L"WM_GETDLGCODE", 135, 0, L"Chance to override default behavior to dialog box input", 0, 0, 0 },
{ L"WM_NCMOUSEMOVE", 160, 0, L"User moved mouse within non-client area", 0, 0, 0 },
{ L"WM_NCLBUTTONDOWN", 161, 0, L"User pressed left mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCLBUTTONUP", 162, 0, L"User released left mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCLBUTTONDBLCLK", 163, 0, L"User double clicked left mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCRBUTTONDOWN", 164, 0, L"User pressed right mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCRBUTTONUP", 165, 0, L"User released right mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCRBUTTONDBLCLK", 166, 0, L"User double clicked right mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCMBUTTONDOWN", 167, 0, L"User pressed middle mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCMBUTTONUP", 168, 0, L"User released middle mouse button in non-client area", 0, 0, 0 },
{ L"WM_NCMBUTTONDBLCLK", 169, 0, L"User double clicked middle mouse button in non-client area", 0, 0, 0 },
{ L"WM_KEYDOWN", 256, 0, L"Non-system key pressed", 0, 0, 0 },
{ L"WM_KEYUP", 257, 0, L"Non-system key released", 0, 0, 0 },
{ L"WM_CHAR", 258, 0, L"Key down message has been translated", 0, 0, 0 },
{ L"WM_DEADCHAR", 259, 0, L"Dead character code translated", 0, 0, 0 },
{ L"WM_SYSKEYDOWN", 260, 0, L"System key has been pressed (F10 or ALT-key)", 0, 0, 0 },
{ L"WM_SYSKEYUP", 261, 0, L"System key has been released (F10 or ALT-key)", 0, 0, 0 },
{ L"WM_SYSCHAR", 262, 0, L"System ALT key has been translated", 0, 0, 0 },
{ L"WM_SYSDEADCHAR", 263, 0, L"Dead system character code translated", 0, 0, 0 },
{ L"WM_IME_STARTCOMPOSITION",269,0, L"IME is about to generate a composition string due to a keystroke", 0, 0, 0 },
{ L"WM_IME_ENDCOMPOSITION",270, 0, L"IME ended composition", 0, 0, 0 },
{ L"WM_IME_COMPOSITION", 271, 0, L"IME changed composition status as a result of a key stroke", 0, 0, 0 },
{ L"WM_INITDIALOG", 272, 0, L"Dialog box is about to be displayed", 0, 0, 0 },
{ L"WM_COMMAND", 273, 0, L"Window received a command notification", 0, 0, 0 },
{ L"WM_SYSCOMMAND", 274, 0, L"User chose a command from the system menu", 0, 0, 0 },
{ L"WM_TIMER", 275, 0, L"Timer expired", 0, 0, 0 },
{ L"WM_HSCROLL", 276, 0, L"Scroll event occurred in the horizontal scroll bar", 0, 0, 0 },
{ L"WM_VSCROLL", 277, 0, L"Scroll event occurred in the vertical scroll bar", 0, 0, 0 },
{ L"WM_INITMENU", 278, 0, L"Menu is about to become active", 0, 0, 0 },
{ L"WM_INITMENUPOPUP", 279, 0, L"Drop-down or sub-menu is about to become active", 0, 0, 0 },
{ L"WM_MENUSELECT", 287, 0, L"Menu item has been selected", 0, 0, 0 },
{ L"WM_MENUCHAR", 288, 0, L"User pressed an unknown menu key", 0, 0, 0 },
{ L"WM_ENTERIDLE", 289, 0, L"Child modal dialog or menu is entering an idle state", 0, 0, 0 },
{ L"WM_CTLCOLORMSGBOX", 306, 0, L"Message box is about to be drawn", 0, 0, 0 },
{ L"WM_CTLCOLOREDIT", 307, 0, L"Edit box is about to be drawn", 0, 0, 0 },
{ L"WM_CTLCOLORLISTBOX", 308, 0, L"List box is about to be drawn", 0, 0, 0 },
{ L"WM_CTLCOLORBTN", 309, 0, L"Button is about to be drawn", 0, 0, 0 },
{ L"WM_CTLCOLORDLG", 310, 0, L"Dialog box is about to be drawn", 0, 0, 0 },
{ L"WM_CTLCOLORSCROLLBAR",311, 0, L"Scroll bar is about to be drawn", 0, 0, 0 },
{ L"WM_CTLCOLORSTATIC", 312, 0, L"Static control is about to be drawn", 0, 0, 0 },
{ L"WM_MOUSEMOVE", 512, 0, L"Mouse cursor moved", 0, 0, 0 },
{ L"WM_LBUTTONDOWN", 513, 0, L"User pressed left mouse button in client area", 0, 0, 0 },
{ L"WM_LBUTTONUP", 514, 0, L"User released left mouse button in client area", 0, 0, 0 },
{ L"WM_LBUTTONDBLCLK", 515, 0, L"User double clicked left mouse button in client area", 0, 0, 0 },
{ L"WM_RBUTTONDOWN", 516, 0, L"User pressed right mouse button in client area", 0, 0, 0 },
{ L"WM_RBUTTONUP", 517, 0, L"User released right mouse button in client area", 0, 0, 0 },
{ L"WM_RBUTTONDBLCLK", 518, 0, L"User double clicked right mouse button in client area", 0, 0, 0 },
{ L"WM_MBUTTONDOWN", 519, 0, L"User pressed middle mouse button in client area", 0, 0, 0 },
{ L"WM_MBUTTONUP", 520, 0, L"User released middle mouse button in client area", 0, 0, 0 },
{ L"WM_MBUTTONDBLCLK", 521, 0, L"User double clicked middle mouse button in client area", 0, 0, 0 },
{ L"WM_MOUSEWHEEL", 522, 0, L"Mouse wheel rotated", 0, 0, 0 },
{ L"WM_PARENTNOTIFY", 528, 0, L"Child window created or destroyed, or mouse click event occurred to child", 0, 0, 0 },
{ L"WM_ENTERMENULOOP", 529, 0, L"Menu modal loop has been entered", 0, 0, 0 },
{ L"WM_EXITMENULOOP", 530, 0, L"Menu modal loop has been exited", 0, 0, 0 },
{ L"WM_NEXTMENU", 531, 0, L"Right or left arrow key was used to switch between menu bar and system menu", 0, 0, 0 },
{ L"WM_SIZING", 532, 0, L"Window is resizing", 0, 0, 0 },
{ L"WM_CAPTURECHANGED", 533, 0, L"Window is losing mouse capture", 0, 0, 0 },
{ L"WM_MOVING", 534, 0, L"Window is moving", 0, 0, 0 },
{ L"WM_POWERBROADCAST", 536, 0, L"Power-management event notification", 0, 0, 0 },
{ L"WM_DEVICECHANGE", 537, 0, L"Hardware configuration has changed", 0, 0, 0 },
{ L"WM_MDICREATE", 544, 0, L"Create a MDI child window", 0, 0, 0 },
{ L"WM_MDIDESTROY", 545, 0, L"Destroy MDI child window", 0, 0, 0 },
{ L"WM_MDIACTIVATE", 546, 0, L"Activate a different MDI child window", 0, 0, 0 },
{ L"WM_MDIRESTORE", 547, 0, L"Restore MDI child window size", 0, 0, 0 },
{ L"WM_MDINEXT", 548, 0, L"Activate the next or previous MDI child window", 0, 0, 0 },
{ L"WM_MDIMAXIMIZE", 549, 0, L"Maximize a MDI child window", 0, 0, 0 },
{ L"WM_MDITILE", 550, 0, L"Arrange all MDI children in a tile format", 0, 0, 0 },
{ L"WM_MDICASCADE", 551, 0, L"Arrange all MDI child windows in cascade format", 0, 0, 0 },
{ L"WM_MDIICONARRANGE", 552, 0, L"Arrange all minimized MDI child windows", 0, 0, 0 },
{ L"WM_MDIGETACTIVE", 553, 0, L"Return handle of active MDI child window", 0, 0, 0 },
{ L"WM_MDISETMENU", 560, 0, L"Replace entire menu of the MDI frame", 0, 0, 0 },
{ L"WM_ENTERSIZEMOVE", 561, 0, L"Entered moving or sizing modal loop", 0, 0, 0 },
{ L"WM_EXITSIZEMOVE", 562, 0, L"Window exited the moving or sizing modal loop", 0, 0, 0 },
{ L"WM_DROPFILES", 563, 0, L"Dropped file notification", 0, 0, 0 },
{ L"WM_MDIREFRESHMENU", 564, 0, L"Refresh the MDI menu of the frame", 0, 0, 0 },
{ L"WM_IME_SETCONTEXT", 641, 0, L"IME window is about to be activated", 0, 0, 0 },
{ L"WM_IME_NOTIFY", 642, 0, L"IME window change notification", 0, 0, 0 },
{ L"WM_IME_CONTROL", 643, 0, L"IME window must carry out requested command", 0, 0, 0 },
{ L"WM_IME_COMPOSITIONFULL",644, 0, L"IME cannot extend the area of the composition window", 0, 0, 0 },
{ L"WM_IME_SELECT", 645, 0, L"System is about to change the current IME", 0, 0, 0 },
{ L"WM_IME_CHAR", 646, 0, L"IME got a character of the conversion result", 0, 0, 0 },
{ L"WM_IME_KEYDOWN", 656, 0, L"IME key press notification", 0, 0, 0 },
{ L"WM_IME_KEYUP", 657, 0, L"IME key release notification", 0, 0, 0 },
{ L"WM_MOUSEHOVER", 673, 0, L"Mouse cursor is hovering", 0, 0, 0 },
{ L"WM_MOUSELEAVE", 675, 0, L"Mouse cursor moved out of window", 0, 0 ,0 },
{ L"WM_CUT", 768, 0, L"Delete current selection", 0, 0, 0 },
{ L"WM_COPY", 769, 0, L"Copy current selection into the clipboard in text format", 0, 0, 0 },
{ L"WM_PASTE", 770, 0, L"Copy current content of the clipboard to control", 0, 0, 0 },
{ L"WM_CLEAR", 771, 0, L"Clear the current selection, if any, from the edit control", 0, 0, 0 },
{ L"WM_UNDO", 772, 0, L"Undo last operation", 0, 0, 0 },
{ L"WM_RENDERFORMAT", 773, 0, L"Render data in the specified clipboard format", 0, 0, 0 },
{ L"WM_RENDERALLFORMATS",774, 0, L"Render data in all clipboard formats", 0, 0, 0 },
{ L"WM_DESTROYCLIPBOARD",775, 0, L"Clipboard has been emptied", 0, 0, 0 },
{ L"WM_DRAWCLIPBOARD", 776, 0, L"Content of the clipboard changed", 0, 0, 0 },
{ L"WM_PAINTCLIPBOARD", 777, 0, L"Clipboard viewer's client area needs repainting", 0, 0, 0 },
{ L"WM_VSCROLLCLIPBOARD",778, 0, L"Event occurred in the clipboard viewer's vertical scroll bar", 0, 0, 0 },
{ L"WM_SIZECLIPBOARD", 779, 0, L"Clipboard viewer's client area has changed size", 0, 0, 0 },
{ L"WM_ASKCBFORMATNAME", 780, 0, L"Request of an owner displayed clipboard format", 0, 0, 0 },
{ L"WM_CHANGECBCHAIN", 781, 0, L"A window is being removed from the clipboard viewer chain", 0, 0, 0 },
{ L"WM_HSCROLLCLIPBOARD",782, 0, L"Event occurred in the clipboard viewer's horizontal scroll bar", 0, 0, 0 },
{ L"WM_QUERYNEWPALETTE", 783, 0, L"Window may realize its logical palette what focus is received", 0, 0, 0 },
{ L"WM_PALETTEISCHANGING",784, 0, L"A window is about to realize its logical palette", 0, 0, 0 },
{ L"WM_PALETTECHANGED", 785, 0, L"A window has realized its logical palette", 0, 0, 0 },
{ L"WM_HOTKEY", 786, 0, L"User pressed registered hotkey", 0, 0, 0 },
{ L"WM_PRINT", 791, 0, L"Render image in current device context request", 0, 0, 0 },
{ L"WM_PRINTCLIENT", 792, 0, L"Render client area in current device context request", 0, 0, 0 },
{ L"WM_DDE_INITIATE", 992, 0, L"Initiate a conversation with a DDE client", 0, 0, 0 },
{ L"WM_DDE_TERMINATE", 993, 0, L"Terminate a DDE conversation", 0, 0, 0 },
{ L"WM_DDE_ADVISE", 994, 0, L"DDE server data item update notification request", 0, 0, 0 },
{ L"WM_DDE_UNADVISE", 995, 0, L"Data or clipboard format client item should no longer be updated", 0, 0, 0 },
{ L"WM_DDE_ACK", 996, 0, L"DDE message has been received and processed", 0, 0, 0 },
{ L"WM_DDE_DATA", 997, 0, L"Data item received or data item available", 0, 0, 0 },
{ L"WM_DDE_REQUEST", 998, 0, L"Client requests the value of a data item", 0, 0, 0 },
{ L"WM_DDE_POKE", 999, 0, L"Client requests unsolicited data be accepted", 0, 0, 0 },
{ L"WM_DDE_EXECUTE", 1000, 0, L"Process a string as a series of commands", 0, 0, 0 },
{ L"Unknown", -1, 0, L"Unknown message", 0, 0, 0 }
};
 
static const int nbMessages = sizeof g_mlTable / sizeof *g_mlTable;
 
LPCWSTR GetWindowsMessageName(UINT msg)
{
LPCWSTR result = g_mlTable[nbMessages-1].pMessageID;
 
int i;
for (i=0; i<nbMessages; ++i)
{
if (g_mlTable[i].dMessageNo == msg)
{
result = g_mlTable[i].pMessageID;
}
}
 
return result;
}
 
 
BOOLEAN GetLUIDFromToken(HANDLE token, PLUID session)
{
BOOLEAN result = FALSE;
TOKEN_STATISTICS stats = {0};
DWORD nbstats = sizeof stats;
GetTokenInformation(token, TokenStatistics, &stats, sizeof stats, &nbstats);
 
*session = stats.AuthenticationId;
 
return result;
}
 
void OutputGetSessionUserName(PLUID session)
{
PSECURITY_LOGON_SESSION_DATA sessionData = NULL;
NTSTATUS retval;
 
// Check for a valid session.
if (!session ) {
OutputDebugString(L"Error - Invalid logon session identifier.\n");
return;
}
// Get the session information.
retval = LsaGetLogonSessionData (session, &sessionData);
if (!retval)
{
// Determine whether there is session data to parse.
if (!sessionData)
{ // no data for session
OutputDebugString(L"Invalid logon session data. \n");
}
if (sessionData->UserName.Buffer != NULL)
{
OutputDebugString(L"User from LUID is ");
OutputDebugString((sessionData->UserName).Buffer);
OutputDebugString(L"\n");
}
// Free the memory returned by the LSA.
}
if (sessionData)
LsaFreeReturnBuffer(sessionData);
return;
}
 
#endif
/tags/1.4.7/trunk/AnyUserCanUnlockNowGina.rc
0,0 → 1,132
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
// Microsoft Visual C++ generated resource script.
//
#include "resource.h"
 
#define APSTUDIO_READONLY_SYMBOLS
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 2 resource.
//
//#include "afxres.h"
 
/////////////////////////////////////////////////////////////////////////////
#undef APSTUDIO_READONLY_SYMBOLS
 
/////////////////////////////////////////////////////////////////////////////
// English (U.S.) resources
 
//#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
//#ifdef _WIN32
//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
//#pragma code_page(1252)
//#endif //_WIN32
 
#ifdef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// TEXTINCLUDE
//
 
1 TEXTINCLUDE
BEGIN
"resource.h\0"
END
 
2 TEXTINCLUDE
BEGIN
"#include ""afxres.h""\r\n"
"\0"
END
 
3 TEXTINCLUDE
BEGIN
"\r\n"
"\0"
END
 
#endif // APSTUDIO_INVOKED
 
 
/////////////////////////////////////////////////////////////////////////////
//
// Version
//
 
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,0,0
PRODUCTVERSION 1,2,0,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
#else
FILEFLAGS 0x0L
#endif
FILEOS 0x4L
FILETYPE 0x2L
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "040904b0"
BEGIN
VALUE "Comments", "http://www.paralint.com/projects/aucun/"
VALUE "CompanyName", "Paralint.com"
VALUE "FileDescription", "Replacement GINA DLL that allows ordinary users to unlock or force logoff a locked workstation"
VALUE "FileVersion", "1.2.0"
VALUE "InternalName", "aucun.dll"
VALUE "LegalCopyright", "Copyright (C) 2008"
VALUE "LegalTrademarks", "BSD Licenced"
VALUE "OriginalFilename", "aucun.dll"
VALUE "ProductName", " Any User Can Unlock Now"
VALUE "ProductVersion", "1.2.0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x409, 1200
END
END
 
//#endif // English (U.S.) resources
/////////////////////////////////////////////////////////////////////////////
 
 
 
#ifndef APSTUDIO_INVOKED
/////////////////////////////////////////////////////////////////////////////
//
// Generated from the TEXTINCLUDE 3 resource.
//
 
 
/////////////////////////////////////////////////////////////////////////////
#endif // not APSTUDIO_INVOKED
 
/tags/1.4.7/trunk/debug.h
0,0 → 1,47
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
#ifdef _DEBUG
#ifndef __DEBUG_H__
#define __DEBUG_H__
 
#include <windows.h>
#include <Ntsecapi.h>
 
#include "extern.h"
 
EXTERN LPCWSTR GetWindowsMessageName(UINT msg);
 
EXTERN BOOLEAN GetLUIDFromToken(HANDLE token, PLUID session);
EXTERN void OutputGetSessionUserName(PLUID session);
EXTERN BOOLEAN ExtractTokenOwner( HANDLE token, wchar_t *csOwner_o, size_t size);
EXTERN void OutputDebugStringError(DWORD dw);
 
 
#endif
#endif
/tags/1.4.7/trunk/resource.h
0,0 → 1,42
/*
Copyright (c) 2008, Guillaume Seguin ([email protected])
All rights reserved.
 
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
 
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
 
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
 
THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
*/
 
//{{NO_DEPENDENCIES}}
// Microsoft Visual C++ generated include file.
// Used by AnyUserCanUnlockNowGina.rc
 
// Next default values for new objects
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 101
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1001
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif
/tags/1.4.7/trunk/Trace.c
0,0 → 1,90
#include <windows.h>
#include <stdio.h>
#include <stdarg.h>
#include <string.h>
#include <tchar.h>
#include "trace.h"
#include "settings.h"
 
#define MAX_TRACE_BUFFER 1024
 
typedef int (*WriteBufferProc)(LPCWSTR buffer);
 
int WriteBufferToStream(const wchar_t *buffer)
{
//Targetted for release 1.5
return 0;
}
 
int WriteBufferToOutputDebugString(const wchar_t *buffer)
{
OutputDebugString(buffer);
return 1;
}
 
 
/* -------------------------------------------------------------------------- */
/** @brief Reads the registry and returns a function that will do the logging
*
* @return
*/
/* ---------------------------------------------------------------------------- */
WriteBufferProc GetOutputWriter()
{
WriteBufferProc result = 0;
 
wchar_t buffer[512];
if (GetDebugSetting(L"Output", buffer, sizeof buffer / sizeof *buffer) == S_OK)
{
//Is it output debug string ?
if (_wcsicmp(L"OutputDebugString", buffer) == 0)
{
result = &WriteBufferToOutputDebugString;
}
}
 
return result;
}
 
 
void Trace(const wchar_t* file, int line, const wchar_t *format, ...)
{
WriteBufferProc output_proc = GetOutputWriter();
 
if (output_proc)
{
wchar_t buffer[MAX_TRACE_BUFFER];
va_list args;
 
if (file && line)
{
swprintf_s(buffer, sizeof buffer / sizeof *buffer, L"[%s:%ld] ", file, line);
output_proc(buffer);
}
 
va_start(args, format);
 
if (format && vswprintf_s(buffer, sizeof buffer / sizeof *buffer, format, args) >= 0)
{
output_proc(buffer);
}
}
}
 
void TraceMessage(const wchar_t* file, int line, DWORD dw)
{
LPVOID lpMsgBuf;
 
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM,
NULL,
dw,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR) &lpMsgBuf,
0, NULL );
 
Trace(file, line, L"0x%08X: %s", dw, lpMsgBuf);
 
LocalFree(lpMsgBuf);
}
/tags/1.4.7/trunk/update.cmd
0,0 → 1,32
@echo off
 
setlocal
rem ------------------------------
rem Make a time based file name
rem ------------------------------
set AUCUN_DLL_NAME=AUCUN-%RANDOM%.dll
 
rem ------------------------------
rem Delete any old DLL, but one...
rem ------------------------------
del /q %windir%\system32\aucun*.dll
 
echo F | xcopy /v .\debug\aucun.dll "%windir%\system32\%AUCUN_DLL_NAME%"
 
rem ------------------------------
rem Edit the registry
rem ------------------------------
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v GinaDLL /t REG_SZ /d "%AUCUN_DLL_NAME%" /f > nul
 
if %ERRORLEVEL%==0 (
 
reg query "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon" /v GinaDLL
dir /od %windir%\system32\aucun*.dll | findstr /I /c:aucun
 
shutdown /r /t 5 /f
 
)
 
endlocal
 
 
/tags/1.4.7/trunk/Trace.h
0,0 → 1,21
#ifndef __TRACE_H__
#define __TRACE_H__
 
#define WIDEN2(x) L ## x
#define WIDEN(x) WIDEN2(x)
#define __WFILE__ WIDEN(__FILE__)
 
#define TRACE(s, ...) Trace(__WFILE__, __LINE__, s, __VA_ARGS__)
#define TRACEMORE(s, ...) Trace(0, 0, s, __VA_ARGS__)
 
#define TRACEMSG(d) TraceMessage(__WFILE__, __LINE__, d)
 
 
#include "extern.h"
 
EXTERN void Trace(const wchar_t* file, int line, const wchar_t *format, ...);
EXTERN void TraceMessage(const wchar_t* file, int line, DWORD dw);
 
 
#endif
/tags/1.4.7/trunk/SecurityHelper.cpp
0,0 → 1,482
// SecurityHelper.cpp
//
// Routines that interface with Win32 and LSA security APIs
//
 
#include "SecurityHelper.h"
#include "trace.h"
 
 
// excerpt from a DDK header file that we can't easily include here
#define STATUS_PASSWORD_EXPIRED ((NTSTATUS)0xC0000071L)
 
int _stringLenInBytes(const wchar_t* s)
{
if (!s) return 0;
return (lstrlen(s)+1) * sizeof *s;
}
 
void _initUnicodeString(UNICODE_STRING* target, wchar_t* source, USHORT cbMax)
{
target->Length = cbMax - sizeof *source;
target->MaximumLength = cbMax;
target->Buffer = source;
}
 
MSV1_0_INTERACTIVE_LOGON* _allocLogonRequest(
const wchar_t* domain,
const wchar_t* user,
const wchar_t* pass,
DWORD* pcbRequest)
{
 
const DWORD cbHeader = sizeof(MSV1_0_INTERACTIVE_LOGON);
const DWORD cbDom = _stringLenInBytes(domain);
const DWORD cbUser = _stringLenInBytes(user);
const DWORD cbPass = _stringLenInBytes(pass);
 
// sanity check string lengths
if (cbDom > USHRT_MAX || cbUser > USHRT_MAX || cbPass > USHRT_MAX)
{
TRACE(L"Input string was too long.\n");
return 0;
}
 
*pcbRequest = cbHeader + cbDom + cbUser + cbPass;
 
MSV1_0_INTERACTIVE_LOGON* pRequest = (MSV1_0_INTERACTIVE_LOGON*)new char[*pcbRequest];
if (!pRequest)
{
TRACE(L"Out of memory, wtf?.\n");
return 0;
}
 
pRequest->MessageType = MsV1_0InteractiveLogon;
 
char* p = (char*)(pRequest + 1); // point past MSV1_0_INTERACTIVE_LOGON header
 
wchar_t* pDom = (wchar_t*)(p);
wchar_t* pUser = (wchar_t*)(p + cbDom);
wchar_t* pPass = (wchar_t*)(p + cbDom + cbUser);
 
CopyMemory(pDom, domain, cbDom);
CopyMemory(pUser, user, cbUser);
CopyMemory(pPass, pass, cbPass);
 
_initUnicodeString(&pRequest->LogonDomainName, pDom, (USHORT)cbDom);
_initUnicodeString(&pRequest->UserName, pUser, (USHORT)cbUser);
_initUnicodeString(&pRequest->Password, pPass, (USHORT)cbPass);
 
return pRequest;
}
 
BOOL _newLsaString(LSA_STRING* target, const char* source)
{
if (0 == source) return FALSE;
 
const int cch = lstrlenA(source);
const int cchWithNullTerminator = cch + 1;
 
// UNICODE_STRINGs have a size limit
if (cchWithNullTerminator * sizeof(*source) > USHRT_MAX) return FALSE;
 
char* newStr = new char[cchWithNullTerminator];
if (!newStr)
{
TRACE(L"Out of memory, wtf?.\n");
return FALSE;
}
 
CopyMemory(newStr, source, cchWithNullTerminator * sizeof *newStr);
 
target->Length = (USHORT)cch * sizeof *newStr;
target->MaximumLength = (USHORT)cchWithNullTerminator * sizeof *newStr;
target->Buffer = newStr;
 
return TRUE;
}
 
void _deleteLsaString(LSA_STRING* target)
{
delete target->Buffer;
target->Buffer = 0;
}
 
BOOL RegisterLogonProcess(const char* logonProcessName, HANDLE* phLsa)
{
*phLsa = 0;
 
LSA_STRING name;
if (!_newLsaString(&name, logonProcessName)) return FALSE;
 
LSA_OPERATIONAL_MODE unused;
NTSTATUS status = LsaRegisterLogonProcess(&name, phLsa, &unused);
 
_deleteLsaString(&name);
 
if (status)
{
*phLsa = 0;
TRACE(L"LsaRegisterLogonProcess failed: %d\n", LsaNtStatusToWinError(status));
return FALSE;
}
return TRUE;
}
 
BOOL CallLsaLogonUser(HANDLE hLsa, const wchar_t* domain, const wchar_t* user, const wchar_t* pass,
SECURITY_LOGON_TYPE logonType, LUID* pLogonSessionId, HANDLE* phToken, MSV1_0_INTERACTIVE_PROFILE** ppProfile, DWORD* pWin32Error)
{
 
BOOL result = FALSE;
DWORD win32Error = 0;
*phToken = 0;
 
LUID ignoredLogonSessionId;
 
// optional arguments
if (ppProfile) *ppProfile = 0;
if (pWin32Error) *pWin32Error = 0;
if (!pLogonSessionId) pLogonSessionId = &ignoredLogonSessionId;
 
LSA_STRING logonProcessName = { 0 };
TOKEN_SOURCE sourceContext = { 'P', 'a', 'r', 'a', 'l', 'i', 'n', 't' };
 
MSV1_0_INTERACTIVE_PROFILE* pProfile = 0;
ULONG cbProfile = 0;
QUOTA_LIMITS quotaLimits;
NTSTATUS substatus;
DWORD cbLogonRequest;
 
MSV1_0_INTERACTIVE_LOGON* pLogonRequest =
_allocLogonRequest(domain, user, pass, &cbLogonRequest);
if (!pLogonRequest)
{
win32Error = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
 
if (!_newLsaString(&logonProcessName, LOGON_PROCESS_NAME))
{
win32Error = ERROR_NOT_ENOUGH_MEMORY;
goto cleanup;
}
 
// LsaLogonUser - the function from hell
NTSTATUS status = LsaLogonUser(
hLsa,
&logonProcessName, // we use our logon process name for the "origin name"
logonType,
LOGON32_PROVIDER_DEFAULT, // we use MSV1_0 or Kerb, whichever is supported
pLogonRequest,
cbLogonRequest,
0, // we do not add any group SIDs
&sourceContext,
(void**)&pProfile, // caller must free this via LsaFreeReturnBuffer
&cbProfile,
pLogonSessionId,
phToken,
&quotaLimits, // we ignore this, but must pass in anyway
&substatus);
 
if (status)
{
win32Error = LsaNtStatusToWinError(status);
 
if ((ERROR_ACCOUNT_RESTRICTION == win32Error && STATUS_PASSWORD_EXPIRED == substatus))
{
win32Error = ERROR_PASSWORD_EXPIRED;
}
 
*phToken = 0;
pProfile = 0;
TRACEMSG(win32Error);
 
goto cleanup;
}
 
if (ppProfile)
{
*ppProfile = (MSV1_0_INTERACTIVE_PROFILE*)pProfile;
pProfile = 0;
}
result = TRUE;
 
cleanup:
// if caller cares about the details, pass them on
if (pWin32Error) *pWin32Error = win32Error;
 
if (pLogonRequest)
{
SecureZeroMemory(pLogonRequest, cbLogonRequest);
delete pLogonRequest;
}
if (pProfile) LsaFreeReturnBuffer(pProfile);
_deleteLsaString(&logonProcessName);
 
return result;
}
 
/*
BOOL GetLogonSid(HANDLE htok, void* psid, DWORD cbMax)
{
DWORD cb;
GetTokenInformation(htok, TokenGroups, 0, 0, &cb);
TOKEN_GROUPS* ptg = (TOKEN_GROUPS*)LocalAlloc(LMEM_FIXED, cb);
if (!ptg)
{
TRACE(L"Out of memory, wtf?.\n");
return FALSE;
}
 
BOOL success = FALSE;
if (GetTokenInformation(htok, TokenGroups, ptg, cb, &cb))
{
DWORD i;
// search for the logon SID
for (i = 0; i < ptg->GroupCount; ++i)
{
if (ptg->Groups[i].Attributes & SE_GROUP_LOGON_ID)
{
void* logonSid = ptg->Groups[i].Sid;
const DWORD cb = GetLengthSid(logonSid);
if (cbMax < cb) return FALSE; // sanity check caller's buffer size
if (!CopySid(cb, psid, logonSid))
{
TRACE(L"CopySid failed: %d\n", GetLastError());
break;
}
success = TRUE;
break;
}
}
if (i == ptg->GroupCount)
{
TRACE(L"Failed to find a logon SID in the user's access token!.\n");
}
}
else TRACE(L"GetTokenInformation(TokenGroups) failed: %d\n", GetLastError());
 
LocalFree(ptg);
 
return success;
}
 
BOOL GetLogonSessionId(HANDLE htok, LUID* pluid)
{
TOKEN_STATISTICS stats;
DWORD cb = sizeof stats;
if (GetTokenInformation(htok, TokenStatistics, &stats, cb, &cb))
{
*pluid = stats.AuthenticationId;
return TRUE;
}
else
{
TRACE(L"GetTokenInformation(TokenStatistics) failed: %d\n", GetLastError());
return FALSE;
}
}
 
// caller must free *ppProfilePath using LocalFree
BOOL ExtractProfilePath(wchar_t** ppProfilePath, MSV1_0_INTERACTIVE_PROFILE* pProfile)
{
*ppProfilePath = 0;
if (0 == pProfile->ProfilePath.Length)
{
// no profile path was specified, so return a null pointer to WinLogon
// to indicate that *it* should figure out the appropriate path
return TRUE;
}
BOOL result = FALSE;
 
const int cch = pProfile->ProfilePath.Length / sizeof(wchar_t);
wchar_t* profilePath = (wchar_t*)LocalAlloc(LMEM_FIXED, sizeof(wchar_t) * (cch + 1)); // I never assume a UNICODE_STRING is null terminated
if (profilePath)
{
// copy the string data and manually null terminate it
CopyMemory(profilePath, pProfile->ProfilePath.Buffer, pProfile->ProfilePath.Length);
profilePath[cch] = L'\0';
 
*ppProfilePath = profilePath;
}
else TRACE(L"Out of memory, wtf?.\n");
 
return result;
}
 
BOOL AllocWinLogonProfile(WLX_PROFILE_V1_0** ppWinLogonProfile, const wchar_t* profilePath)
{
 
*ppWinLogonProfile = 0;
if (!profilePath)
{
// no profile path was specified, so return a null pointer to WinLogon
// to indicate that *it* should figure out the appropriate path
return TRUE;
}
BOOL result = FALSE;
 
// must use LocalAlloc for this - WinLogon will use LocalFree
WLX_PROFILE_V1_0* profile = (WLX_PROFILE_V1_0*)LocalAlloc(LMEM_FIXED, sizeof(WLX_PROFILE_V1_0));
if (profile)
{
profile->dwType = WLX_PROFILE_TYPE_V1_0;
 
const int cch = lstrlen(profilePath) + 1;
 
wchar_t* newProfilePath = (wchar_t*)LocalAlloc(LMEM_FIXED, cch * sizeof *newProfilePath);
if (newProfilePath)
{
// copy the string data and manually null terminate it
CopyMemory(newProfilePath, profilePath, cch * sizeof *newProfilePath);
 
profile->pszProfile = newProfilePath;
*ppWinLogonProfile = profile;
 
result = TRUE;
}
else TRACE(L"Out of memory, wtf?.\n");
}
else TRACE(L"Out of memory, wtf?.\n");
 
return result;
}
 
BOOL CreateProcessAsUserOnDesktop(HANDLE hToken, wchar_t* programImage, wchar_t* desktop, void* env)
{
// impersonate the user to ensure that they are allowed
// to execute the program in the first place
if (!ImpersonateLoggedOnUser(hToken))
{
TRACE(L"ImpersonateLoggedOnUser failed: %d\n", GetLastError());
return FALSE;
}
 
STARTUPINFO si = { sizeof si, 0, desktop };
PROCESS_INFORMATION pi;
if (!CreateProcessAsUser(hToken, programImage, programImage, 0, 0, FALSE,
CREATE_UNICODE_ENVIRONMENT, env, 0, &si, &pi))
{
RevertToSelf();
TRACE(L"CreateProcessAsUser failed for image %s with error code %d\n", programImage, GetLastError());
return FALSE;
}
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
 
RevertToSelf();
 
TRACE(L"Successfully launched %s\n", programImage);
return TRUE;
}
 
BOOL ImpersonateAndGetUserName(HANDLE hToken, wchar_t* name, int cch)
{
BOOL result = FALSE;
if (ImpersonateLoggedOnUser(hToken))
{
DWORD cchName = cch;
if (GetUserName(name, &cchName))
result = TRUE;
else TRACE(L"GetUserName failed: %d", GetLastError());
RevertToSelf();
}
else TRACE(L"ImpersonateLoggedOnUser failed: %d\n", GetLastError());
 
return result;
}
*/
 
// checks user SID in both tokens for equality
BOOL IsSameUser(HANDLE hToken1, HANDLE hToken2, BOOL* pbIsSameUser)
{
*pbIsSameUser = FALSE;
BOOL result = FALSE;
 
const DWORD bufSize = sizeof(TOKEN_USER) + SECURITY_MAX_SID_SIZE;
char buf1[bufSize];
char buf2[bufSize];
 
DWORD cb;
if (GetTokenInformation(hToken1, TokenUser, buf1, bufSize, &cb) &&
GetTokenInformation(hToken2, TokenUser, buf2, bufSize, &cb))
{
*pbIsSameUser = EqualSid(((TOKEN_USER*)buf1)->User.Sid, ((TOKEN_USER*)buf2)->User.Sid) ? TRUE : FALSE;
result = TRUE;
}
else TRACE(L"GetTokenInformation failed: %d\n", GetLastError());
 
return result;
}
 
/*
void* _administratorsAlias()
{
const int subAuthCount = 2;
static char sid[sizeof(SID) + subAuthCount * sizeof(DWORD)];
 
SID* psid = (SID*)sid;
if (0 == psid->Revision)
{
// first time called, initialize the sid
psid->IdentifierAuthority.Value[5] = 5; // NT Authority
psid->SubAuthorityCount = subAuthCount;
psid->SubAuthority[0] = SECURITY_BUILTIN_DOMAIN_RID;
psid->SubAuthority[1] = DOMAIN_ALIAS_RID_ADMINS;
psid->Revision = 1;
}
return sid;
}
 
// checks for presence of local admin group (must have TOKEN_DUPLICATE perms on hToken)
BOOL IsAdmin(HANDLE hToken)
{
// we can pretty much assume all tokens will be primary tokens in this application
// and CheckTokenMembership requires an impersonation token (which is really annoying)
// so we'll just duplicate any token we get into an impersonation token before continuing...
BOOL isAdmin = FALSE;
HANDLE hImpToken;
if (DuplicateTokenEx(hToken, TOKEN_QUERY, 0, SecurityIdentification, TokenImpersonation, &hImpToken))
{
BOOL isMember;
if (CheckTokenMembership(hImpToken, _administratorsAlias(), &isMember) && isMember)
{
isAdmin = TRUE;
}
else TRACE(L"CheckTokenMembership failed: %d\n", GetLastError());
 
CloseHandle(hImpToken);
}
else TRACE(L"DuplicateTokenEx failed: %d\n", GetLastError());
 
return isAdmin;
}
*/
int GetUsernameAndDomainFromToken(HANDLE token, wchar_t *domain, DWORD domain_len, wchar_t *username, DWORD username_len)
{
int result;
TOKEN_USER *user;
DWORD size = 0;
GetTokenInformation(token, TokenUser, NULL, 0, &size);
if (size)
{
user = (TOKEN_USER *)malloc(size);
if (user)
{
if(GetTokenInformation(token, TokenUser, user, size, &size))
{
if(IsValidSid(user->User.Sid))
{
SID_NAME_USE name_use;
*domain = *username = 0;
if(LookupAccountSid(0, user->User.Sid, username, &username_len, domain, &domain_len, &name_use))
{
result = (*username != 0) + (*domain != 0);
}
}
}
free(user);
}
}
return result;
}
/tags/1.4.7/trunk/extern.h
0,0 → 1,7
#ifndef EXTERN
#ifdef __cplusplus
#define EXTERN extern "C"
#else
#define EXTERN extern
#endif
#endif
/tags/1.4.7/trunk/SecurityHelper.h
0,0 → 1,30
// SecurityHelper.h
//
// Routines that interface with Win32 and LSA security APIs
//
 
#ifndef __SECURITY_HELPER_H__
#define __SECURITY_HELPER_H__
 
#include <windows.h>
#include <ntsecapi.h>
#include <winwlx.h>
#include "extern.h"
 
#define LOGON_PROCESS_NAME "AUCUN-http://paralint.com"
 
 
EXTERN BOOL RegisterLogonProcess(const char* logonProcessName, HANDLE* phLsa);
EXTERN BOOL CallLsaLogonUser(HANDLE hLsa,
const wchar_t* domain,
const wchar_t* user,
const wchar_t* pass,
SECURITY_LOGON_TYPE logonType,
LUID* pLogonSessionId,
HANDLE* phToken,
MSV1_0_INTERACTIVE_PROFILE** ppProfile,
DWORD* pWin32Error);
EXTERN BOOL IsSameUser(HANDLE hToken1, HANDLE hToken2, BOOL* pbIsSameUser);
EXTERN int GetUsernameAndDomainFromToken(HANDLE token, wchar_t *domain, DWORD domain_len, wchar_t *username, DWORD username_len);
 
#endif
/tags/1.4.7/trunk/test.cpp
0,0 → 1,206
// test.cpp : Defines the entry point for the console application.
//
 
#include <windows.h>
#include <wincred.h>
#include <tchar.h>
#include <stdio.h>
#include <security.h>
#include <lm.h>
#include "settings.h"
#include "unlockpolicy.h"
#include "trace.h"
#include "debug.h"
#include "SecurityHelper.h"
 
 
//BEGIN - Found on Google Code search, now 404 http://www.cybertech.net/~sh0ksh0k/projects_new/TRET-1.0-PUBSRC/Shared/utils/security.c
BOOL EnablePrivilegeInToken(HANDLE hToken, const wchar_t *PrivilegeName)
{
LUID Privilege;
TOKEN_PRIVILEGES TokenPrivileges;
 
if (!LookupPrivilegeValue(NULL, PrivilegeName, &Privilege)) return FALSE;
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = Privilege;
TokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
if (!AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, sizeof(TokenPrivileges), NULL, NULL)) return FALSE;
else if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) return FALSE;
return TRUE;
}
 
 
 
BOOL EnablePrivilege(const wchar_t *PrivilegeName)
{
BOOL Result;
HANDLE hToken;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return FALSE;
Result = EnablePrivilegeInToken(hToken, PrivilegeName);
CloseHandle(hToken);
return Result;
}
 
BOOL DisablePrivilegeInToken(HANDLE hToken, const wchar_t *PrivilegeName)
{
LUID Privilege;
TOKEN_PRIVILEGES TokenPrivileges;
 
if (!LookupPrivilegeValue(NULL, PrivilegeName, &Privilege)) return FALSE;
TokenPrivileges.PrivilegeCount = 1;
TokenPrivileges.Privileges[0].Luid = Privilege;
TokenPrivileges.Privileges[0].Attributes = 0;
if (!AdjustTokenPrivileges(hToken, FALSE, &TokenPrivileges, sizeof(TokenPrivileges), NULL, NULL)) return FALSE;
else if (GetLastError() == ERROR_NOT_ALL_ASSIGNED) return FALSE;
return TRUE;
}
 
BOOL DisablePrivilege(const wchar_t *PrivilegeName)
{
BOOL Result;
HANDLE hToken;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) return FALSE;
Result = DisablePrivilegeInToken(hToken, PrivilegeName);
CloseHandle(hToken);
return Result;
}
 
 
//END - Found on Google Code search, now 404 http://www.cybertech.net/~sh0ksh0k/projects_new/TRET-1.0-PUBSRC/Shared/utils/security.c
 
 
 
BOOL IsWindowsServer()
{
OSVERSIONINFOEX osvi;
DWORDLONG dwlConditionMask = 0;
 
// Initialize the OSVERSIONINFOEX structure.
ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
osvi.dwMajorVersion = 5;
osvi.wProductType = VER_NT_SERVER;
 
// Initialize the condition mask.
VER_SET_CONDITION(dwlConditionMask, VER_MAJORVERSION, VER_GREATER_EQUAL);
VER_SET_CONDITION(dwlConditionMask, VER_PRODUCT_TYPE, VER_EQUAL);
 
// Perform the test.
return VerifyVersionInfo(&osvi, VER_MAJORVERSION | VER_PRODUCT_TYPE, dwlConditionMask);
}
 
 
 
int _tmain(int argc, _TCHAR* argv[])
{
int result = -1;
 
HANDLE lsa = 0;
//wchar_t unlock[MAX_GROUPNAME] = L"";
 
TRACE(L"-------------------------\n");
 
//EnablePrivilege(L"SeTcbPrivilege");
if(!RegisterLogonProcess(LOGON_PROCESS_NAME, &lsa))
TRACEMSG(GetLastError());
 
if(IsWindowsServer())
{
TRACE(L"Windows Server\n");
}
else
{
TRACE(L"Windows pas Server\n");
}
 
/*
if(GetGroupName(gUnlockGroupName, unlock, sizeof unlock / sizeof *unlock) == S_OK)
{
wchar_t caption[512];
wchar_t text[2048];
 
OutputDebugString(L"Group name ");
OutputDebugString(unlock);
OutputDebugString(L"\n");
 
if((GetNoticeText(L"Caption", caption, sizeof caption / sizeof *caption) == S_OK)
&& (GetNoticeText(L"Text", text, sizeof text / sizeof *text) == S_OK))
{
wchar_t message[MAX_USERNAME + sizeof text / sizeof *text];
wchar_t *read = text;
wchar_t *write = text;
 
while(*read)
{
if((*read == '\\') && (*(read+1) == 'n'))
{
*write++ = '\n';
read += 2;
}
else
{
*write++ = *read++;
}
}
 
*write = 0;
 
wsprintf(message, text, unlock); //Will insert group name if there is a %s in the message
MessageBox(0, message, caption, MB_YESNOCANCEL|MB_ICONEXCLAMATION);
}
}
*/
if(argc > 1) for(int i=1; i<argc; ++i)
{
// wchar_t user[MAX_USERNAME];
// wchar_t domain[MAX_DOMAIN];
wchar_t passwd[MAX_PASSWORD];
wchar_t username[512];
wchar_t domain[512];
 
HANDLE current_user = 0;
 
OpenProcessToken(GetCurrentProcess(), TOKEN_READ, &current_user);
 
GetUsernameAndDomainFromToken(current_user, username, sizeof username / sizeof *username, domain, sizeof domain / sizeof *domain);
 
if(ShouldHookUnlockPasswordDialog(current_user))
{
TRACE(L"Should hook.\n");
}
 
if (_getws_s(passwd, MAX_PASSWORD) == passwd)
{
result = ShouldUnlockForUser(lsa, current_user, L".", argv[i], passwd);
 
switch(result)
{
case eLetMSGINAHandleIt:
TRACE(L"TEST result is eLetMSGINAHandleIt\n");
wprintf(L"Actual result : eLetMSGINAHandleIt\n");
break;
case eUnlock:
TRACE(L"TEST result is eUnlock\n");
wprintf(L"Actual result : eUnlock\n");
break;
case eForceLogoff:
TRACE(L"TEST result is eForceLogoff\n");
wprintf(L"Actual result : eForceLogoff\n");
break;
}
}
else
{
TRACE(L"Unable to read password\n");
break;
}
 
CloseHandle(current_user);
}
 
LsaDeregisterLogonProcess(lsa);
//DisablePrivilege(L"SeTcbPrivilege");
 
return result;
}
 
/tags/1.4.7/trunk/tests.cmd
0,0 → 1,211
@echo off
 
setlocal
 
set TEST_EXE=release\test.exe
set UNLOCK_GROUP=aucun-unlock
set FORCE_LOGOFF_GROUP=aucun-logoff
set EXCLUDED_GROUP=aucun-excluded
 
set eLetMSGINAHandleIt=1
set eUnlock=2
set eForceLogoff=3
 
if "%1" == "" goto TESTS_HELP
 
echo Setting up tests....
echo.
 
rem *------------------------------------------------------------*
rem * Clean the old groups *
rem *------------------------------------------------------------*
net localgroup %UNLOCK_GROUP% /delete 1> nul
net localgroup %FORCE_LOGOFF_GROUP% /delete 1> nul
net localgroup %EXCLUDED_GROUP% /delete 1> nul
 
net localgroup %UNLOCK_GROUP% /add 1> nul
net localgroup %FORCE_LOGOFF_GROUP% /add 1> nul
net localgroup %EXCLUDED_GROUP% /add 1> nul
 
rem *------------------------------------------------------------*
rem * Removing the registry settings *
rem *------------------------------------------------------------*
reg delete HKLM\Software\Paralint.com\Aucun\Groups /va /f 1> nul
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Unlock" 1> nul
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" 1> nul
 
set /p TEST_USER_PASSWORD="Enter the password of %1 : "
echo.
 
rem The tests are ordered so that the hamming distance between
rem any two tests is one. In other words, if we add the user to
rem a group, we don't touch the registry, and we never add or
rem remove more than one user or group at a time.
rem
rem More on this on
rem http://www.paralint.com/blog/2008/08/21/easy-test-coverage-with-constant-hamming-distance-of-1/
 
echo %d User Registry
echo U F U F
 
rem *------------------------------------------------------------*
echo Running test : 0 0 0 0 0 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
echo %TEST_EXE% %1
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 1 0 0 0 1 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f /d %FORCE_LOGOFF_GROUP% 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 3 0 0 1 1 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Unlock" /f /d %UNLOCK_GROUP% 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 2 0 0 1 0 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 6 0 1 1 0 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
net localgroup %FORCE_LOGOFF_GROUP% %1 /add 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 7 0 1 1 1 Expected result : eForceLogoff
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f /d %FORCE_LOGOFF_GROUP% 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eForceLogoff% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 5 0 1 0 1 Expected result : eForceLogoff
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Unlock" /f 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eForceLogoff% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 4 0 1 0 0 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 12 1 1 0 0 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
net localgroup %UNLOCK_GROUP% %1 /add 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 13 1 1 0 1 Expected result : eForceLogoff
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f /d %FORCE_LOGOFF_GROUP% 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eForceLogoff% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 15 1 1 1 1 Expected result : eUnlock
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Unlock" /f /d %UNLOCK_GROUP% 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eUnlock% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 14 1 1 1 0 Expected result : eUnlock
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eUnlock% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 10 1 0 1 0 Expected result : eUnlock
rem *------------------------------------------------------------*
net localgroup %FORCE_LOGOFF_GROUP% %1 /delete 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eUnlock% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 11 1 0 1 1 Expected result : eUnlock
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f /d %FORCE_LOGOFF_GROUP% 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eUnlock% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 9 1 0 0 1 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Unlock" /f 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
 
rem *------------------------------------------------------------*
echo Running test : 8 1 0 0 0 Expected result : eLetMSGINAHandleIt
rem *------------------------------------------------------------*
reg add HKLM\Software\Paralint.com\Aucun\Groups /v "Force logoff" /f 1> nul
echo %TEST_USER_PASSWORD%| %TEST_EXE% %1
if NOT ERRORLEVEL %eLetMSGINAHandleIt% goto TEST_FAILED
echo.
 
goto TEST_FINISHED
 
:TEST_FAILED
echo ***FAILED*** (return code %ERRORLEVEL%)
net localgroup %UNLOCK_GROUP%
net localgroup %FORCE_LOGOFF_GROUP%
reg query HKLM\Software\Paralint.com\Aucun\Groups
 
:TEST_FINISHED
echo TEST FINISHED !!!
goto END
 
:TESTS_HELP
echo Pass the username to use for tests
 
:END
 
endlocal
/tags/1.4.7/trunk/README.txt
0,0 → 1,43
------------------------------------------------
Any user can unlock now, a replacement GINA DLL
------------------------------------------------
 
This file is a summary. Please refer to http://www.paralint.com/projects/aucun/
for more information.
 
Purpose
-------
This replacement GINA will allow members of any group you specify to force
logoff any user who locked his workstation. You can also allow members of any
other group you specify to unlock a locked session.
 
The GUI is provided by entierly by the original MSGINA.DLL. My replacement GINA
just wraps the original DLL and overrides unlock decisions.
Installation
------------
1. Copy AUCUN.DLL anywhere.
2. Add a string value key named GinaDLL under
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon
3. Set the value of the new GinaDLL key to aucun.dll (add the path if it is not
in system32.
4. Modify the file Sample.reg to use your groups. Everything is optionnal. If an
entry is removed, that feature is silently disable (like the warning message).
5. Merge Sample.reg to the registry and reboot
 
Messed up ?
-----------
You can boot in Safe Mode, it will disable any custom GINA.
 
Security
--------
You can break the security of your system if you are not careful:
. If you use the unlock feature, your users will be able to impersonate others
. If you put Aucun.DLL in a user writable directory, they will be able to
elevate their privileges
 
Please refer to http://www.paralint.com/projects/aucun/ for more information.
 
 
--
Guillaume (at paralint.com)
/tags/1.4.7/trunk
Property changes:
Added: svn:mergeinfo
## -0,0 +0,1 ##
Merged /branches/64bits:r54-199