text
stringlengths 2
104M
| meta
dict |
---|---|
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtSystemDebugControl_SysDbgGetTriageDump.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FDE7CF0B-61FE-417C-8AA2-9728D4B119C1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtSystemDebugControl_SysDbgGetTriageDump</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtSystemDebugControl_SysDbgGetTriageDump.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtSystemDebugControl_SysDbgGetTriageDump.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// NtSystemDebugControl_SysDbgGetTriageDump.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "windows.h"
#include "TlHelp32.h"
//from https://crashdmp.wordpress.com/2014/08/04/livedump-1-0-is-available/
typedef struct _SYSDBG_TRIAGE_DUMP
{
ULONG Flags;
ULONG BugCheckCode;
ULONG_PTR BugCheckParam1;
ULONG_PTR BugCheckParam2;
ULONG_PTR BugCheckParam3;
ULONG_PTR BugCheckParam4;
ULONG ProcessHandles;
ULONG ThreadHandles;
PHANDLE Handles;
} SYSDBG_TRIAGE_DUMP, *PSYSDBG_TRIAGE_DUMP;
//from https://github.com/subTee/native-nt-toolkit/blob/cc044793eaa51889c032a52a1590e376f28fa5a7/ndk/kdtypes.h
typedef enum _SYSDBG_COMMAND
{
SysDbgGetTriageDump = 29,
} SYSDBG_COMMAND;
//from http://undocumented.ntinternals.net/index.html?page=UserMode%2FUndocumented%20Functions%2FDebug%2FNtSystemDebugControl.html
typedef NTSTATUS(WINAPI *PNtSystemDebugControl)(
IN SYSDBG_COMMAND Command,
IN PVOID InputBuffer OPTIONAL,
IN ULONG InputBufferLength,
OUT PVOID OutputBuffer OPTIONAL,
IN ULONG OutputBufferLength,
OUT PULONG ReturnLength OPTIONAL);
int main(int argc, char **argv) {
if (argc < 2) {
printf("Target PID required\r\n");
return 1;
}
DWORD dwPID = atoi(argv[1]);
//based off of https://msdn.microsoft.com/en-us/library/windows/desktop/aa446619(v=vs.85).aspx
TOKEN_PRIVILEGES tokenPrivileges = { 0x0 };
LUID luid = { 0x0 };
tokenPrivileges.PrivilegeCount = 1;
if (!LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &luid)) {
printf("Couldn't lookup SE_DEBUG_NAME privilege luid: 0x%X\r\n", GetLastError());
return 1;
}
tokenPrivileges.Privileges[0].Luid = luid;
tokenPrivileges.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
HANDLE hToken = NULL;
if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES, &hToken)) {
printf("Couldn't open own token?: 0x%X\r\n", GetLastError());
return 1;
}
if (!AdjustTokenPrivileges(hToken, FALSE, &tokenPrivileges, 0x10, NULL, NULL)) {
printf("Failed to privesc: 0x%X\r\n", GetLastError());
CloseHandle(hToken);
return 1;
}
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, dwPID);
if (hProcess == NULL) {
printf("Failed to get a handle to target process: 0x%X\r\n", GetLastError());
CloseHandle(hToken);
return 1;
}
printf("Opened target process\r\n");
HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, dwPID);
THREADENTRY32 threadEntry = { 0x0 };
threadEntry.dwSize = sizeof(threadEntry);
if (!Thread32First(hSnapshot, &threadEntry)) {
printf("Failed to enumerate threads for pid: %d, error code: 0x%X\r\n", dwPID, GetLastError());
CloseHandle(hToken);
CloseHandle(hProcess);
return 1;
}
unsigned int uiCountThreadHandles = 0;
HANDLE hThreads[16] = { 0x0 };
HANDLE hThread = NULL;
do {
if (threadEntry.dwSize >= 20) {
hThread = OpenThread(THREAD_ALL_ACCESS, FALSE, threadEntry.th32ThreadID);
if (hThread != INVALID_HANDLE_VALUE) {
hThreads[uiCountThreadHandles] = hThread;
uiCountThreadHandles++;
}
}
} while ((Thread32Next(hSnapshot, &threadEntry)) && uiCountThreadHandles < 16);
printf("Got %d process threads\r\n", uiCountThreadHandles);
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtSystemDebugControl NtSystemDebugControl = (PNtSystemDebugControl)GetProcAddress(ntdll, "NtSystemDebugControl");
if (NtSystemDebugControl == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
printf("Got pointer to NtSystemDebugControl\r\n");
SYSDBG_TRIAGE_DUMP sysDbgDump = { 0 };
ULONG ulInSize = sizeof(SYSDBG_TRIAGE_DUMP);
sysDbgDump.ProcessHandles = 0;
sysDbgDump.ThreadHandles = uiCountThreadHandles;
sysDbgDump.Handles = &hThreads[0];
ULONG ulOutSize = (1024 * 1024) - 1; //needs to be < 1mb
void *pOutBuffer = HeapAlloc(GetProcessHeap(), 0, ulOutSize);
ULONG ulRetLen = 0;
printf("Everything setup - calling NtSystemDebugControl\r\n");
NTSTATUS status = NtSystemDebugControl(SysDbgGetTriageDump, &sysDbgDump, ulInSize, pOutBuffer, ulOutSize, &ulRetLen);
printf("Status code: 0x%llx\r\n", status);
if (status != 0) {
printf("Something bad happened\r\n");
return 1;
}
printf("Function returned %d bytes\r\n", ulRetLen);
HANDLE hOutFile = CreateFile(TEXT("out.dmp"),
GENERIC_WRITE | GENERIC_READ,
0,
NULL,
CREATE_ALWAYS,
FILE_ATTRIBUTE_NORMAL,
NULL);
if (hOutFile == NULL) {
printf("CreateFileW failed: 0x%X\r\n", GetLastError());
return 1;
}
ULONG bytesWritten = 0;
if (!WriteFile(hOutFile, pOutBuffer, ulRetLen, &bytesWritten, NULL)) {
printf("WriteFile failed: 0x%X\r\n", GetLastError());
return 1;
}
FlushFileBuffers(hOutFile);
printf("Wrote %d byte dump file to out.dmp\r\n", bytesWritten);
CloseHandle(hOutFile);
return 0;
} | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtQuerySysInfo_SystemModuleInformation", "NtQuerySysInfo_SystemModuleInformation\NtQuerySysInfo_SystemModuleInformation.vcxproj", "{FE823611-ECFC-45E9-B443-8BA53A6C96DC}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Debug|x64.ActiveCfg = Debug|x64
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Debug|x64.Build.0 = Debug|x64
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Debug|x86.ActiveCfg = Debug|Win32
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Debug|x86.Build.0 = Debug|Win32
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Release|x64.ActiveCfg = Release|x64
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Release|x64.Build.0 = Release|x64
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Release|x86.ActiveCfg = Release|Win32
{FE823611-ECFC-45E9-B443-8BA53A6C96DC}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// NtQuerySysInfo_SystemModuleInformation.cpp : Attempts to use the NtQuerySystemInformation to find the base addresses if loaded modules.
//
#include "stdafx.h"
#include <windows.h>
#define MAXIMUM_FILENAME_LENGTH 255
typedef struct SYSTEM_MODULE {
ULONG Reserved1;
ULONG Reserved2;
#ifdef _WIN64
ULONG Reserved3;
#endif
PVOID ImageBaseAddress;
ULONG ImageSize;
ULONG Flags;
WORD Id;
WORD Rank;
WORD w018;
WORD NameOffset;
CHAR Name[MAXIMUM_FILENAME_LENGTH];
}SYSTEM_MODULE, *PSYSTEM_MODULE;
typedef struct SYSTEM_MODULE_INFORMATION {
ULONG ModulesCount;
SYSTEM_MODULE Modules[1];
} SYSTEM_MODULE_INFORMATION, *PSYSTEM_MODULE_INFORMATION;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemModuleInformation = 11
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *PNtQuerySystemInformation)(
__in SYSTEM_INFORMATION_CLASS SystemInformationClass,
__inout PVOID SystemInformation,
__in ULONG SystemInformationLength,
__out_opt PULONG ReturnLength
);
int main()
{
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQuerySystemInformation query = (PNtQuerySystemInformation)GetProcAddress(ntdll, "NtQuerySystemInformation");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
ULONG len = 0;
query(SystemModuleInformation, NULL, 0, &len);
PSYSTEM_MODULE_INFORMATION pModuleInfo = (PSYSTEM_MODULE_INFORMATION)GlobalAlloc(GMEM_ZEROINIT, len);
if (pModuleInfo == NULL) {
printf("Could not allocate memory for module info.\n");
return 1;
}
NTSTATUS status = query(SystemModuleInformation, pModuleInfo, len, &len);
if (status != (NTSTATUS)0x0) {
printf("NtQuerySystemInformation failed with error code 0x%X\n", status);
return 1;
}
for (unsigned int i = 0; i < pModuleInfo->ModulesCount; i++) {
PVOID kernelImageBase = pModuleInfo->Modules[i].ImageBaseAddress;
PCHAR kernelImage = (PCHAR)pModuleInfo->Modules[i].Name;
printf("Mod name %s ", kernelImage);
#ifdef _WIN64
printf("Base Addr 0x%llx\r\n", kernelImageBase);
#else
printf("Base Addr 0x%X\r\n", kernelImageBase);
#endif
}
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtQuerySysInfo_SystemModuleInformation Project Overview
========================================================================
AppWizard has created this NtQuerySysInfo_SystemModuleInformation application for you.
This file contains a summary of what you will find in each of the files that
make up your NtQuerySysInfo_SystemModuleInformation application.
NtQuerySysInfo_SystemModuleInformation.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtQuerySysInfo_SystemModuleInformation.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtQuerySysInfo_SystemModuleInformation.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtQuerySysInfo_SystemModuleInformation.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtQuerySysInfo_SystemModuleInformation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtQuerySysInfo_SystemModuleInformation.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FE823611-ECFC-45E9-B443-8BA53A6C96DC}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtQuerySysInfo_SystemModuleInformation</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtQuerySysInfo_SystemModuleInformation.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
# NPIEP
NPIEP is a new security feature introduced by Microsoft as part of their Virtualisation Based Security (VBS). We can find this brief summary in the [Hypervisor Top-Level Functional Specification](https://github.com/Microsoft/Virtualization-Documentation/raw/master/tlfs/Hypervisor%20Top%20Level%20Functional%20Specification%20v5.0b.pdf).

Each of these instructions provides information about control data used by the CPU and the OS. The instructions to set this data can only be executed in kernel mode but due to historic design choices user mode software can use the read vesions. As shown below for SGDT.

In summary the instructions have the following purposes.
|Instruction|Name|Purpose|
|-----------|----|-------|
| [SGDT](http://x86.renejeschke.de/html/file_module_x86_id_290.html) | Store [Global Descriptor Table Register](http://wiki.osdev.org/Global_Descriptor_Table) | Stores the content of the global descriptor table register (GDTR) in the destination operand. |
| [SIDT](http://x86.renejeschke.de/html/file_module_x86_id_295.html) | Store [Interrupt Descriptor Table Register](http://wiki.osdev.org/Interrupt_Descriptor_Table) | Stores the content the interrupt descriptor table register (IDTR) in the destination operand. |
| [SLDT](http://x86.renejeschke.de/html/file_module_x86_id_296.html) | Store [Local Descriptor Table Register]() | Stores the segment selector from the local descriptor table register (LDTR) in the destination operand. |
| [SMSW](http://x86.renejeschke.de/html/file_module_x86_id_297.html) | Store Machine Status Word | Stores the machine status word (bits 0 through 15 of control register [CR0](http://wiki.osdev.org/CR0#CR0)) into the destination operand. |
| [STR](http://x86.renejeschke.de/html/file_module_x86_id_307.html) | Store [Task Register](http://wiki.osdev.org/Context_Switching#Hardware_Context_Switching) | Stores the segment selector from the task register (TR) in the destination operand. |
As you can see the information revealed all of these instructions may not be critical in all cases, but still probably shouldn't be exposed to user mode. Details on abusing the Global and Local Descriptor Tables for kernel exploitation can be found [here](http://vexillium.org/dl.php?call_gate_exploitation.pdf) and obviously overwriting entries in the Interrupt Descriptor Table can be great for hooking on key presses, network packets, etc. I used the below C code + asm file in visual studio to run the instructions in windows.
```
// InstructionProtection.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <intrin.h>
extern "C" void sgdt_wrapper(void *);
extern "C" void sidt_wrapper(void *);
extern "C" unsigned long long sldt_wrapper(void);
extern "C" unsigned short smsw_wrapper(void);
extern "C" unsigned long long str_wrapper(void);
#pragma pack(1)
typedef struct _DESCRIPTOR {
unsigned short limit;
unsigned long long base;
} DESCRIPTOR, *PDESCRIPTOR;
int main()
{
printf("SGDT:\n");
PDESCRIPTOR gdtr = (PDESCRIPTOR) malloc(sizeof(DESCRIPTOR));
memset(gdtr, 0x41, sizeof(DESCRIPTOR));
sgdt_wrapper((void *) gdtr);
printf("\tGDTR base: 0x%llx, limit: 0x%X\n", gdtr->base, gdtr->limit);
printf("SIDT:\n");
PDESCRIPTOR idtr = (PDESCRIPTOR) malloc(sizeof(DESCRIPTOR));
memset(idtr, 0x41, sizeof(DESCRIPTOR));
sidt_wrapper((void *) idtr);
printf("\tIDTR base: 0x%llx, limit: 0x%X\n", idtr->base, idtr->limit);
free(idtr);
printf("SLDT:\n");
unsigned long long ldtr = sldt_wrapper();
printf("\tLDTR selector: 0x%llx\n", ldtr);
printf("SMSW:\n");
unsigned short cr0 = smsw_wrapper();
printf("\tCR0.PE = %d\n", cr0 & 1);
printf("\tCR0.MP = %d\n", (cr0 >> 1) & 1);
printf("\tCR0.EM = %d\n", (cr0 >> 2) & 1);
printf("\tCR0.TS = %d\n", (cr0 >> 3) & 1);
printf("\tCR0.ET = %d\n", (cr0 >> 4) & 1);
printf("\tCR0.NE = %d\n", (cr0 >> 5) & 1);
printf("STR:\n");
unsigned long long tr = str_wrapper();
printf("\tTR segment selector: 0x%llx\n", tr);
return 0;
}
```
```
_DATA SEGMENT
_DATA ENDS
_TEXT SEGMENT
PUBLIC sgdt_wrapper
PUBLIC sidt_wrapper
PUBLIC sldt_wrapper
PUBLIC smsw_wrapper
PUBLIC str_wrapper
sgdt_wrapper PROC
sgdt [rcx]
ret
sgdt_wrapper ENDP
sidt_wrapper PROC
sidt [rcx]
ret
sidt_wrapper ENDP
sldt_wrapper PROC
sldt rax
ret
sldt_wrapper ENDP
smsw_wrapper PROC
smsw rax
ret
smsw_wrapper ENDP
str_wrapper PROC
str rax
ret
str_wrapper ENDP
_TEXT ENDS
END
```
Running the resulting binary without VBS enabled, gave me the following.

I then configured and enabled HyperV followed by Device Gaurd on the test system by following this guide: [Deploy Device Guard: enable virtualization-based security](https://docs.microsoft.com/en-us/windows/device-security/device-guard/deploy-device-guard-enable-virtualization-based-security) and using the setup powershell script that can be downloaded here: [Device Guard and Credential Guard hardware readiness tool](https://www.microsoft.com/en-us/download/details.aspx?id=53337).
Once this was setup, I ran the test binary again, getting the following output.

This actually looks completely normal, but then I rebooted and the IDT and GDT addresses were identical and again and again...obviously on a normal system they aren't at static addresses. So it looks like NPIEP is enabled and working.
As a final note, it looks like Intel recently implemented an equivalent feature in hardware ([some would say after far too long](http://www.os2museum.com/wp/better-late-than-never/)):

(Taken from the intel instruction set reference.)
More details pending, some intern stole my test laptop :p | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
# gSharedInfo
## Background
While going through and validating the status of the kernel leaks on versions 1607/1703 of Windows 10, I found that the gSharedInfo table no longer gave us kernel pointers and the table structure had clearly been changed.

Which is very different to what used to be returned on 1607:

Turns out this shouldn't have been much of a surprise, as people had been discussing it during the [preview build releases](https://twitter.com/Blomster81/status/847571032521273345).
So I set out to atleast get a basic idea of what the changes entailed.
## Initial Structure 'Reversing'
With some trial and error purely using Visual Studios debugger it was easy enough to work out the size of the new structure. Increasing the structures size to 256 bits meant that the pHead and pOwner fields both contained what looked like HANDLEs and various fields contained repeating values.
A big help in working this out was 32 bits worth of null bytes which appears at an offset of 224 bits in each entry, this is likely padding to bring the structure up to 256 bits which fits on a 64 bit alignment nicely.
<pre>
typedef struct _HANDLEENTRY {
PVOID pHead;
PVOID pOwner;
BYTE bType;
BYTE bFlags;
WORD wUniq;
WORD unknown;
WORD unknown1;
WORD unknown2;
WORD unknown3;
INT padding;
}HANDLEENTRY, *PHANDLEENTRY;
</pre>
I also modfiied the printf statement used to log values, as shown below.
<pre>
printf("Head: 0x%llp, Owner: 0x%llp, flags: 0x%X, uniq: 0x%X Type: 0x%X, unknown: 0x%x, unknown1: 0x%X, unknown2: 0x%X, unknown3: 0x%X\r\n", entry.phead, entry.pOwner, entry.bFlags, entry.wUniq ,entry.bType, entry.unknown, entry.unknown1, entry.unknown2, entry.unknown3);
</pre>
Running the updated code gives much saner looking output:

At this point the phead and pOwner fields very much look like handles. Additionally a lot of the new fields have recurring values (for example unknown's value is constant for each object type (bType)) so I figured I might be able to get some insight into those at the same time.
## pHead/pOwner Verification
Working with the assumption the pHead and pOwner values are pointers now I decided to validate they were atleast valid pointers. To do this I selected a few entries, for example the one shown next.
<pre>
Head: 0x00000000000009D0, Owner: 0x0000000000000328, flags: 0x0, uniq: 0x0 Type: 0x3, unknown: 0xac39, unknown1: 0x3697, unknown2: 0x1, unknown3: 0x1
</pre>
I then used [NtQuerySystemInformation (SystemHandleInformation)](https://github.com/sam-b/windows_kernel_address_leaks/blob/master/NtQuerySysInfo_SystemHandleInformation/NtQuerySysInfo_SystemHandleInformation/NtQuerySysInfo_SystemHandleInformation.cpp) to dump all the Handles on the system and the corresponding objects addresses.
Looking up the handles I'd picked proved they were all atleast valid handles. Although not knowing what process they corresponded to made proper validation hard. For example I found:
<pre>
PID: 1592 Object 0xffffa103d2b11d50 Handle 0x328
...
PID: 1592 Object 0xffffa103d366d080 Handle 0x9d0
</pre>
Aswell as results for a number of other processes. Looking into win32kfull.sys in IDA and viewing references to gSharedInfo shows it is still heavily in use, with most uses looking similar to the below from 'LockDesktopMenu':

This shows the table being used for handle management, as all of the other uses, atleast a glance do. I have no idea about the unknown fields, unknown1 atleast changes across boots.
So in conclusion pHead and pOwner are probably Handles for the corresponding objects now, rather than addresses as they were pre-Creators update. I have no idea about the other stuff, I might look into this more in the future but I'm not sure there's much point :)
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DesktopHeap", "DesktopHeap\DesktopHeap.vcxproj", "{EABC1843-E192-48AE-A151-652215FD9B11}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{EABC1843-E192-48AE-A151-652215FD9B11}.Debug|x64.ActiveCfg = Debug|x64
{EABC1843-E192-48AE-A151-652215FD9B11}.Debug|x64.Build.0 = Debug|x64
{EABC1843-E192-48AE-A151-652215FD9B11}.Debug|x86.ActiveCfg = Debug|Win32
{EABC1843-E192-48AE-A151-652215FD9B11}.Debug|x86.Build.0 = Debug|Win32
{EABC1843-E192-48AE-A151-652215FD9B11}.Release|x64.ActiveCfg = Release|x64
{EABC1843-E192-48AE-A151-652215FD9B11}.Release|x64.Build.0 = Release|x64
{EABC1843-E192-48AE-A151-652215FD9B11}.Release|x86.ActiveCfg = Release|Win32
{EABC1843-E192-48AE-A151-652215FD9B11}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
//Details from https://github.com/55-AA/CVE-2016-3308 and http://www.geoffchappell.com/studies/windows/win32/ntdll/structs/teb/index.htm
#include "stdafx.h"
#include <Windows.h>
typedef struct _TEB {
#ifdef _WIN64
UCHAR ignored[0x0800];
#else
UCHAR ignored[0x06CC];
#endif
ULONG_PTR Win32ClientInfo[0x3E];
} TEB, *PTEB;
typedef struct _DESKTOPINFO {
PVOID pvDesktopBase;
PVOID pvDesktopLimit;
} DESKTOPINFO, *PDESKTOPINFO;
typedef struct _CLIENTINFO {
ULONG_PTR CI_flags;
ULONG_PTR cSpins;
DWORD dwExpWinVer;
DWORD dwCompatFlags;
DWORD dwCompatFlags2;
DWORD dwTIFlags;
PDESKTOPINFO pDeskInfo;
ULONG_PTR ulClientDelta;
} CLIENTINFO, *PCLIENTINFO;
int main() {
LoadLibraryA("gdi32.dll");
PTEB pTeb = (PTEB)HeapAlloc(GetProcessHeap(), 0, sizeof(TEB));
ReadProcessMemory(GetCurrentProcess(), NtCurrentTeb(), pTeb, sizeof(TEB), NULL);
PCLIENTINFO clientInfo = (PCLIENTINFO) pTeb->Win32ClientInfo;
ULONG_PTR ulClientDelta = clientInfo->ulClientDelta;
PVOID pDeskBase = clientInfo->pDeskInfo->pvDesktopBase;
PVOID pDeskLimit = clientInfo->pDeskInfo->pvDesktopLimit;
#ifdef _WIN64
printf("Client delta: 0x%llx, Desktop Base: 0x%llx, Desktop Limit: 0x%llx\r\n", ulClientDelta, pDeskBase, pDeskLimit);
#else
printf("Client delta: 0x%X, Desktop Base: 0x%X, Desktop Limit: 0x%X\r\n", ulClientDelta, pDeskBase, pDeskLimit);
#endif
return 0;
} | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : DesktopHeap Project Overview
========================================================================
AppWizard has created this DesktopHeap application for you.
This file contains a summary of what you will find in each of the files that
make up your DesktopHeap application.
DesktopHeap.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
DesktopHeap.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
DesktopHeap.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named DesktopHeap.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EABC1843-E192-48AE-A151-652215FD9B11}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>DesktopHeap</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DesktopHeap.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// DesktopHeap.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DesktopHeap.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtQuerySysInfo_SystemBigPoolInformation", "NtQuerySysInfo_SystemBigPoolInformation\NtQuerySysInfo_SystemBigPoolInformation.vcxproj", "{DB103D08-5AE8-404C-85D9-2A9D486122FF}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Debug|x64.ActiveCfg = Debug|x64
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Debug|x64.Build.0 = Debug|x64
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Debug|x86.ActiveCfg = Debug|Win32
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Debug|x86.Build.0 = Debug|Win32
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Release|x64.ActiveCfg = Release|x64
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Release|x64.Build.0 = Release|x64
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Release|x86.ActiveCfg = Release|Win32
{DB103D08-5AE8-404C-85D9-2A9D486122FF}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// NtQuerySysInfo_SystemBigPoolInformation.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
//from http://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/bigpool_entry.htm
typedef struct _SYSTEM_BIGPOOL_ENTRY
{
union {
PVOID VirtualAddress;
ULONG_PTR NonPaged : 1;
};
ULONG_PTR SizeInBytes;
union {
UCHAR Tag[4];
ULONG TagUlong;
};
} SYSTEM_BIGPOOL_ENTRY, *PSYSTEM_BIGPOOL_ENTRY;
//from http://www.geoffchappell.com/studies/windows/km/ntoskrnl/api/ex/sysinfo/bigpool.htm
typedef struct _SYSTEM_BIGPOOL_INFORMATION {
ULONG Count;
SYSTEM_BIGPOOL_ENTRY AllocatedInfo[ANYSIZE_ARRAY];
} SYSTEM_BIGPOOL_INFORMATION, *PSYSTEM_BIGPOOL_INFORMATION;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemBigPoolInformation = 0x42
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *PNtQuerySystemInformation)(
__in SYSTEM_INFORMATION_CLASS SystemInformationClass,
__inout PVOID SystemInformation,
__in ULONG SystemInformationLength,
__out_opt PULONG ReturnLength
);
int main()
{
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQuerySystemInformation query = (PNtQuerySystemInformation)GetProcAddress(ntdll, "NtQuerySystemInformation");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
unsigned int len = sizeof(SYSTEM_BIGPOOL_INFORMATION);
unsigned long out;
PSYSTEM_BIGPOOL_INFORMATION info = NULL;
NTSTATUS status = ERROR;
do {
len *= 2;
info = (PSYSTEM_BIGPOOL_INFORMATION) GlobalAlloc(GMEM_ZEROINIT, len);
status = query(SystemBigPoolInformation, info, len, &out);
} while (status == (NTSTATUS)0xc0000004);
if (!SUCCEEDED(status)) {
printf("NtQuerySystemInformation failed with error code 0x%X\n", status);
return 1;
}
for (unsigned int i = 0; i < info->Count; i++) {
SYSTEM_BIGPOOL_ENTRY poolEntry = info->AllocatedInfo[i];
#ifdef _WIN64
printf("Tag: %.*s, Address: 0x%llx, Size: 0x%x\n", 4, poolEntry.Tag, poolEntry.VirtualAddress, poolEntry.SizeInBytes);
#else
printf("Tag: %.*s, Address: 0x%x, Size: 0x%x\n",4, poolEntry.Tag, poolEntry.VirtualAddress, poolEntry.SizeInBytes);
#endif
}
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtQuerySysInfo_SystemBigPoolInformation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtQuerySysInfo_SystemBigPoolInformation Project Overview
========================================================================
AppWizard has created this NtQuerySysInfo_SystemBigPoolInformation application for you.
This file contains a summary of what you will find in each of the files that
make up your NtQuerySysInfo_SystemBigPoolInformation application.
NtQuerySysInfo_SystemBigPoolInformation.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtQuerySysInfo_SystemBigPoolInformation.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtQuerySysInfo_SystemBigPoolInformation.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtQuerySysInfo_SystemBigPoolInformation.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DB103D08-5AE8-404C-85D9-2A9D486122FF}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtQuerySysInfo_SystemBigPoolInformation</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtQuerySysInfo_SystemBigPoolInformation.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtQuerySysInfo_SystemBigPoolInformation.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DescriptorTables", "DescriptorTables\DescriptorTables.vcxproj", "{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Debug|x64.ActiveCfg = Debug|x64
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Debug|x64.Build.0 = Debug|x64
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Debug|x86.ActiveCfg = Debug|Win32
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Debug|x86.Build.0 = Debug|Win32
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Release|x64.ActiveCfg = Release|x64
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Release|x64.Build.0 = Release|x64
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Release|x86.ActiveCfg = Release|Win32
{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : DescriptorTables Project Overview
========================================================================
AppWizard has created this DescriptorTables application for you.
This file contains a summary of what you will find in each of the files that
make up your DescriptorTables application.
DescriptorTables.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
DescriptorTables.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
DescriptorTables.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named DescriptorTables.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{40E22A70-51F7-4E44-BFA9-C492B4FF8FE8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>DescriptorTables</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="DescriptorTables.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// DescriptorTables.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdlib.h>
#include <Windows.h>
#include <intrin.h>
int main()
{
#ifdef _WIN64
unsigned char idtr[10] = { 0 };
__sidt(idtr);
unsigned long long idtrBase = (unsigned long long)idtr[9] << 56 |
(unsigned long long)idtr[8] << 48 |
(unsigned long long)idtr[7] << 40 |
(unsigned long long)idtr[6] << 32 |
(unsigned long long)idtr[5] << 24 |
(unsigned long long)idtr[4] << 16 |
(unsigned long long)idtr[3] << 8 |
(unsigned long long)idtr[2];
unsigned short idtrLimit = (unsigned int)idtr[1] << 8 |
(unsigned int)idtr[0];
printf("Interrupt Descriptor Table Register base: 0x%llx, limit: 0x%X\r\n", idtrBase, idtrLimit);
#else
unsigned char idtr[6] = { 0 };
__asm {
sidt idtr;
}
unsigned int idtrBase = (unsigned int)idtr[5] << 24 |
(unsigned int)idtr[4] << 16 |
(unsigned int)idtr[3] << 8 |
(unsigned int)idtr[2];
unsigned short idtrLimit = (unsigned int)idtr[1] << 8 |
(unsigned int)idtr[0];
printf("Interrupt Descriptor Table Register base: 0x%X, limit: 0x%X\r\n", idtrBase, idtrLimit);
#endif
#ifdef _WIN64
unsigned char gdtr[10] = { 0 };
_sgdt(gdtr);
unsigned long long gdtrBase = (unsigned long long)gdtr[9] << 56 |
(unsigned long long)gdtr[8] << 48 |
(unsigned long long)gdtr[7] << 40 |
(unsigned long long)gdtr[6] << 32 |
(unsigned long long)gdtr[5] << 24 |
(unsigned long long)gdtr[4] << 16 |
(unsigned long long)gdtr[3] << 8 |
(unsigned long long)gdtr[2];
unsigned short gdtrLimit = (unsigned int)gdtr[1] << 8 |
(unsigned int)gdtr[0];
printf("Global Descriptor Table Register base: 0x%llx, limit: 0x%X\r\n", gdtrBase, gdtrLimit);
#else
unsigned char gdtr[6] = { 0 };
__asm {
sgdt gdtr;
}
unsigned int gdtrBase = (unsigned int)gdtr[5] << 24 |
(unsigned int)gdtr[4] << 16 |
(unsigned int)gdtr[3] << 8 |
(unsigned int)gdtr[2];
unsigned short gdtrLimit = (unsigned int)gdtr[1] << 8 |
(unsigned int)gdtr[0];
printf("Global Descriptor Table Register base: 0x%X, limit: 0x%X\r\n", gdtrBase, gdtrLimit);
#endif
#ifndef _WIN64
WORD tr;
__asm str tr
LDT_ENTRY tss;
GetThreadSelectorEntry(GetCurrentThread(), tr, &tss);
unsigned int tssBase = (tss.HighWord.Bits.BaseHi << 24) +
(tss.HighWord.Bits.BaseMid << 16) +
tss.BaseLow;
unsigned int tssLimit = tss.LimitLow;
printf("TSS base: 0x%X, limit: 0x%X\r\n", tssBase, tssLimit);
return 0;
#endif
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="DescriptorTables.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// DescriptorTables.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtQuerySysInfo_SystemLockInformation", "NtQuerySysInfo_SystemLockInformation\NtQuerySysInfo_SystemLockInformation.vcxproj", "{76BB383D-EBD5-4BEC-A999-024A9A2A812D}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Debug|x64.ActiveCfg = Debug|x64
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Debug|x64.Build.0 = Debug|x64
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Debug|x86.ActiveCfg = Debug|Win32
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Debug|x86.Build.0 = Debug|Win32
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Release|x64.ActiveCfg = Release|x64
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Release|x64.Build.0 = Release|x64
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Release|x86.ActiveCfg = Release|Win32
{76BB383D-EBD5-4BEC-A999-024A9A2A812D}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtQuerySysInfo_SystemLockInformation Project Overview
========================================================================
AppWizard has created this NtQuerySysInfo_SystemLockInformation application for you.
This file contains a summary of what you will find in each of the files that
make up your NtQuerySysInfo_SystemLockInformation application.
NtQuerySysInfo_SystemLockInformation.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtQuerySysInfo_SystemLockInformation.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtQuerySysInfo_SystemLockInformation.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtQuerySysInfo_SystemLockInformation.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtQuerySysInfo_SystemLockInformation.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// NtQuerySysInfo_SystemModuleInformation.cpp : Attempts to use the NtQuerySystemInformation to find the base addresses if loaded modules.
//
#include "stdafx.h"
#include <windows.h>
typedef struct _SYSTEM_LOCK {
PVOID Address;
USHORT Type;
USHORT Reserved1;
ULONG ExclusiveOwnerThreadId;
ULONG ActiveCount;
ULONG ContentionCount;
ULONG Reserved2[2];
#ifdef _WIN64
ULONG Reserved3;
#endif
ULONG NumberOfSharedWaiters;
ULONG NumberOfExclusiveWaiters;
} SYSTEM_LOCK, *PSYSTEM_LOCK;
typedef struct SYSTEM_LOCK_INFORMATION {
ULONG LocksCount;
SYSTEM_LOCK Locks[1];
} SYSTEM_LOCK_INFORMATION, *PSYSTEM_LOCK_INFORMATION;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemLockInformation = 12
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *PNtQuerySystemInformation)(
__in SYSTEM_INFORMATION_CLASS SystemInformationClass,
__inout PVOID SystemInformation,
__in ULONG SystemInformationLength,
__out_opt PULONG ReturnLength
);
int main()
{
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQuerySystemInformation query = (PNtQuerySystemInformation)GetProcAddress(ntdll, "NtQuerySystemInformation");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
PSYSTEM_LOCK_INFORMATION pLockInfo = NULL;
ULONG len = 20;
NTSTATUS status = (NTSTATUS)0xc0000004;
do {
len *= 2;
pLockInfo = (PSYSTEM_LOCK_INFORMATION)GlobalAlloc(GMEM_ZEROINIT, len);
status = query(SystemLockInformation, pLockInfo, len, &len);
} while (status == (NTSTATUS)0xc0000004);
if (status != (NTSTATUS)0x0) {
printf("NtQuerySystemInformation failed with error code 0x%X\n", status);
return 1;
}
for (unsigned int i = 0; i < pLockInfo->LocksCount; i++) {
PVOID lockAddress = pLockInfo->Locks[i].Address;
USHORT lockType = (USHORT)pLockInfo->Locks[i].Type;
#ifdef _WIN64
printf("Lock Address 0x%llx\t", lockAddress);
#else
printf("Lock Address 0x%X\t", lockAddress);
#endif
printf("Lock Type 0x%X\r\n", lockType);
}
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{76BB383D-EBD5-4BEC-A999-024A9A2A812D}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtQuerySysInfo_SystemLockInformation</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtQuerySysInfo_SystemLockInformation.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtQuerySysInfo_SystemLockInformation.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GdiSharedHandleTable", "GdiSharedHandleTable\GdiSharedHandleTable.vcxproj", "{85EA5DD2-11C5-4786-8261-B3BCB4814A65}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Debug|x64.ActiveCfg = Debug|x64
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Debug|x64.Build.0 = Debug|x64
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Debug|x86.ActiveCfg = Debug|Win32
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Debug|x86.Build.0 = Debug|Win32
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Release|x64.ActiveCfg = Release|x64
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Release|x64.Build.0 = Release|x64
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Release|x86.ActiveCfg = Release|Win32
{85EA5DD2-11C5-4786-8261-B3BCB4814A65}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// GdiSharedHandleTable.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
//Mostly from http://www.geoffchappell.com/studies/windows/win32/ntdll/structs/peb/index.htm, other structures etc...
typedef struct _PEB {
#ifdef _WIN64
UCHAR ignored[0xf8];
#else
UCHAR ignored[0x94];
#endif
PVOID GdiSharedHandleTable;
} PEB, *PPEB;
typedef struct _GDICELL
{
PVOID pKernelAddress;
USHORT wProcessId;
USHORT wCount;
USHORT wUpper;
USHORT wType;
PVOID pUserAddress;
} GDICELL, *PGDICELL;
typedef struct _PROCESS_BASIC_INFORMATION {
NTSTATUS ExitStatus;
PVOID PebBaseAddress;
ULONG_PTR AffinityMask;
LONG BasePriority;
HANDLE UniqueProcessId;
HANDLE InheritedFromUniqueProcessId;
} PROCESS_BASIC_INFORMATION, *PPROCESS_BASIC_INFORMATION;
typedef enum _PROCESSINFOCLASS {
SystemProcessBasicInformation = 0
} PROCESSINFOCLASS;
typedef NTSTATUS(WINAPI *PNtQueryInformationProcess)(
_In_ HANDLE ProcessHandle,
_In_ PROCESSINFOCLASS ProcessInformationClass,
_Out_ PVOID ProcessInformation,
_In_ ULONG ProcessInformationLength,
_Out_opt_ PULONG ReturnLength
);
int main() {
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQueryInformationProcess query = (PNtQueryInformationProcess)GetProcAddress(ntdll, "NtQueryInformationProcess");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
LoadLibraryA("gdi32.dll");
ULONG dwReturned = 0;
PROCESS_BASIC_INFORMATION processBasicInfo = { 0x0 };
NTSTATUS status = query(GetCurrentProcess(), SystemProcessBasicInformation, &processBasicInfo, sizeof(PROCESS_BASIC_INFORMATION), &dwReturned);
PPEB peb = (PPEB)HeapAlloc(GetProcessHeap(), 0, sizeof(PEB));
ReadProcessMemory(GetCurrentProcess(), processBasicInfo.PebBaseAddress, peb, sizeof(PEB), NULL);
DWORD count = 0x8fff; //That should do it...
PGDICELL gdiTable = (PGDICELL)HeapAlloc(GetProcessHeap(), 0, sizeof(GDICELL) * count);
ReadProcessMemory(GetCurrentProcess(), peb->GdiSharedHandleTable, gdiTable, sizeof(GDICELL) * count, NULL);
for (unsigned int i = 0; i < count; i++) {
GDICELL cell = gdiTable[i];
if (cell.pKernelAddress == (void *)0xCDCDCDCD) {
break;
}
if (cell.pKernelAddress == 0x00000000) {
continue;
}
HANDLE gdiHandle = (HANDLE)((cell.wUpper << 16) + i);
#ifdef _WIN64
printf("Kernel address: 0x%llx, GDI Handle: 0x%llx, Process ID: %d\r\n", cell.pKernelAddress, gdiHandle, cell.wProcessId);
#else
printf("Kernel address: 0x%X, GDI Handle: 0x%X, Process ID: %d\r\n", cell.pKernelAddress, gdiHandle, cell.wProcessId);
#endif
}
return 0;
} | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : GdiSharedHandleTable Project Overview
========================================================================
AppWizard has created this GdiSharedHandleTable application for you.
This file contains a summary of what you will find in each of the files that
make up your GdiSharedHandleTable application.
GdiSharedHandleTable.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
GdiSharedHandleTable.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
GdiSharedHandleTable.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named GdiSharedHandleTable.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="GdiSharedHandleTable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// GdiSharedHandleTable.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{85EA5DD2-11C5-4786-8261-B3BCB4814A65}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>GdiSharedHandleTable</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="GdiSharedHandleTable.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedInfoHandleTable", "SharedInfoHandleTable\SharedInfoHandleTable.vcxproj", "{AAF05FEA-1411-431E-936F-18D71BE11A02}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Debug|x64.ActiveCfg = Debug|x64
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Debug|x64.Build.0 = Debug|x64
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Debug|x86.ActiveCfg = Debug|Win32
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Debug|x86.Build.0 = Debug|Win32
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Release|x64.ActiveCfg = Release|x64
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Release|x64.Build.0 = Release|x64
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Release|x86.ActiveCfg = Release|Win32
{AAF05FEA-1411-431E-936F-18D71BE11A02}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : SharedInfoHandleTable Project Overview
========================================================================
AppWizard has created this SharedInfoHandleTable application for you.
This file contains a summary of what you will find in each of the files that
make up your SharedInfoHandleTable application.
SharedInfoHandleTable.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
SharedInfoHandleTable.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
SharedInfoHandleTable.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named SharedInfoHandleTable.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{AAF05FEA-1411-431E-936F-18D71BE11A02}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>SharedInfoHandleTable</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="SharedInfoHandleTable.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// SharedInfoHandleTable.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <Windows.h>
typedef struct _HANDLEENTRY {
PVOID phead;
PVOID pOwner;
BYTE bType;
BYTE bFlags;
WORD wUniq;
}HANDLEENTRY, *PHANDLEENTRY;
typedef struct _SERVERINFO {
#ifdef _WIN64
UINT64 dwSRVIFlags;
UINT64 cHandleEntries;
#else
DWORD dwSRVIFlags;
DWORD cHandleEntries;
#endif
WORD wSRVIFlags;
WORD wRIPPID;
WORD wRIPError;
}SERVERINFO, *PSERVERINFO;
typedef struct _SHAREDINFO {
PSERVERINFO psi;
PHANDLEENTRY aheList;
ULONG HeEntrySize;
ULONG_PTR pDispInfo;
ULONG_PTR ulSharedDelta;
ULONG_PTR awmControl;
ULONG_PTR DefWindowMsgs;
ULONG_PTR DefWindowSpecMsgs;
}SHAREDINFO, *PSHAREDINFO;
int main()
{
HMODULE hUser32 = LoadLibraryA("user32.dll");
PSHAREDINFO gSharedInfo = (PSHAREDINFO)GetProcAddress(hUser32, "gSharedInfo");
for (unsigned int i = 0; i < gSharedInfo->psi->cHandleEntries; i++) {
HANDLEENTRY entry = gSharedInfo->aheList[i];
if (entry.bType != 0) { //ignore free entries
#ifdef _WIN64
printf("Head: 0x%llx, Owner: 0x%llx, Type: 0x%X\r\n", entry.phead, entry.pOwner, entry.bType);
#else
printf("Head: 0x%X, Owner: 0x%X, Type: 0x%X\r\n", entry.phead, entry.pOwner, entry.bType);
#endif
}
}
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// SharedInfoHandleTable.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="SharedInfoHandleTable.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NtQuerySysInfo_SystemFirmwareTableInfo", "NtQuerySysInfo_SystemFirmwareTableInfo\NtQuerySysInfo_SystemFirmwareTableInfo.vcxproj", "{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Debug|x64.ActiveCfg = Debug|x64
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Debug|x64.Build.0 = Debug|x64
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Debug|x86.ActiveCfg = Debug|Win32
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Debug|x86.Build.0 = Debug|Win32
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Release|x64.ActiveCfg = Release|x64
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Release|x64.Build.0 = Release|x64
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Release|x86.ActiveCfg = Release|Win32
{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.h : include file for standard system include files,
// or project specific include files that are used frequently, but
// are changed infrequently
//
#pragma once
#include "targetver.h"
#include <stdio.h>
#include <tchar.h>
// TODO: reference additional headers your program requires here
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
========================================================================
CONSOLE APPLICATION : NtQuerySysInfo_SystemFirmwareTableInfo Project Overview
========================================================================
AppWizard has created this NtQuerySysInfo_SystemFirmwareTableInfo application for you.
This file contains a summary of what you will find in each of the files that
make up your NtQuerySysInfo_SystemFirmwareTableInfo application.
NtQuerySysInfo_SystemFirmwareTableInfo.vcxproj
This is the main project file for VC++ projects generated using an Application Wizard.
It contains information about the version of Visual C++ that generated the file, and
information about the platforms, configurations, and project features selected with the
Application Wizard.
NtQuerySysInfo_SystemFirmwareTableInfo.vcxproj.filters
This is the filters file for VC++ projects generated using an Application Wizard.
It contains information about the association between the files in your project
and the filters. This association is used in the IDE to show grouping of files with
similar extensions under a specific node (for e.g. ".cpp" files are associated with the
"Source Files" filter).
NtQuerySysInfo_SystemFirmwareTableInfo.cpp
This is the main application source file.
/////////////////////////////////////////////////////////////////////////////
Other standard files:
StdAfx.h, StdAfx.cpp
These files are used to build a precompiled header (PCH) file
named NtQuerySysInfo_SystemFirmwareTableInfo.pch and a precompiled types file named StdAfx.obj.
/////////////////////////////////////////////////////////////////////////////
Other notes:
AppWizard uses "TODO:" comments to indicate parts of the source code you
should add to or customize.
/////////////////////////////////////////////////////////////////////////////
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="targetver.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="stdafx.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="NtQuerySysInfo_SystemFirmwareTableInfo.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
#pragma once
// Including SDKDDKVer.h defines the highest available Windows platform.
// If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
// set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
#include <SDKDDKVer.h>
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.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="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C67F2BF2-8AB3-4D81-915A-99F060F7DE47}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>NtQuerySysInfo_SystemFirmwareTableInfo</RootNamespace>
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>Use</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>Use</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<Text Include="ReadMe.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="stdafx.h" />
<ClInclude Include="targetver.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="NtQuerySysInfo_SystemFirmwareTableInfo.cpp" />
<ClCompile Include="stdafx.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
</ClCompile>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project> | {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// NtQuerySysInfo_SystemFirmwareTableInfoGet.cpp : Defines the entry point for the console application.
//
// NtQuerySysInfo_SystemFirmwareTableInfo.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <windows.h>
//from https://github.com/hfiref0x/VMDE
typedef enum _SYSTEM_FIRMWARE_TABLE_ACTION
{
SystemFirmwareTable_Enumerate,
SystemFirmwareTable_Get
} SYSTEM_FIRMWARE_TABLE_ACTION, *PSYSTEM_FIRMWARE_TABLE_ACTION;
typedef struct _SYSTEM_FIRMWARE_TABLE_INFORMATION {
ULONG ProviderSignature;
SYSTEM_FIRMWARE_TABLE_ACTION Action;
ULONG TableID;
ULONG TableBufferLength;
UCHAR TableBuffer[ANYSIZE_ARRAY];
} SYSTEM_FIRMWARE_TABLE_INFORMATION, *PSYSTEM_FIRMWARE_TABLE_INFORMATION;
typedef enum _SYSTEM_INFORMATION_CLASS {
SystemFirmwareTableInformation = 76
} SYSTEM_INFORMATION_CLASS;
typedef NTSTATUS(WINAPI *PNtQuerySystemInformation)(
__in SYSTEM_INFORMATION_CLASS SystemInformationClass,
__inout PVOID SystemInformation,
__in ULONG SystemInformationLength,
__out_opt PULONG ReturnLength
);
//from http://grapsus.net/blog/post/Hexadecimal-dump-in-C
#define HEXDUMP_COLS 16
void hexdump(unsigned char *mem, unsigned int len)
{
unsigned int i, j;
for (i = 0; i < len + ((len % HEXDUMP_COLS) ? (HEXDUMP_COLS - len % HEXDUMP_COLS) : 0); i++)
{
/* print offset */
if (i % HEXDUMP_COLS == 0)
{
printf("0x%06x: ", i);
}
/* print hex data */
if (i < len)
{
printf("%02x ", 0xFF & ((char*)mem)[i]);
}
else /* end of block, just aligning for ASCII dump */
{
printf(" ");
}
/* print ASCII dump */
if (i % HEXDUMP_COLS == (HEXDUMP_COLS - 1))
{
for (j = i - (HEXDUMP_COLS - 1); j <= i; j++)
{
if (j >= len) /* end of block, not really printing */
{
putchar(' ');
}
else if (isprint(((char*)mem)[j])) /* printable char */
{
putchar(0xFF & ((char*)mem)[j]);
}
else /* other char */
{
putchar('.');
}
}
putchar('\n');
}
}
}
int main()
{
HMODULE ntdll = GetModuleHandle(TEXT("ntdll"));
PNtQuerySystemInformation query = (PNtQuerySystemInformation)GetProcAddress(ntdll, "NtQuerySystemInformation");
if (query == NULL) {
printf("GetProcAddress() failed.\n");
return 1;
}
ULONG Length = 0x1000;
SYSTEM_FIRMWARE_TABLE_INFORMATION *sfti = (PSYSTEM_FIRMWARE_TABLE_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Length);
if (sfti == NULL) {
return 1;
}
sfti->Action = SystemFirmwareTable_Get;
sfti->ProviderSignature = 'RSMB';
sfti->TableID = 0;
sfti->TableBufferLength = Length;
// Query if info class available and if how many memory we need.
NTSTATUS Status = query(SystemFirmwareTableInformation, sfti, Length, &Length);
if (Status != 0xC0000023 && Status != 0) { //0xC0000023 == Buffer too small
HeapFree(GetProcessHeap(), 0, sfti);
printf("Failed to query SystemFirmwareTableInformation: 0x%X\r\n", Status);
return 1;
}
HeapFree(GetProcessHeap(), 0, sfti);
sfti = (PSYSTEM_FIRMWARE_TABLE_INFORMATION)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, Length);
if (sfti == NULL) {
printf("Failed to allocate memory for sfti 0x%X\r\n", Status);
return 1;
}
sfti->Action = SystemFirmwareTable_Get;
sfti->ProviderSignature = 'RSMB';
sfti->TableID = 0;
sfti->TableBufferLength = Length;
Status = query(SystemFirmwareTableInformation, sfti, Length, &Length);
if (Status != 0) {
HeapFree(GetProcessHeap(), 0, sfti);
printf("Failed to query SystemFirmwareTableInformation: 0x%X\r\n", Status);
return 1;
}
PUCHAR buf = sfti->TableBuffer;
hexdump(buf, Length);
return 0;
}
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
// stdafx.cpp : source file that includes just the standard includes
// NtQuerySysInfo_SystemFirmwareTableInfo.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
// TODO: reference any additional headers you need in STDAFX.H
// and not in this file
| {
"repo_name": "sam-b/windows_kernel_address_leaks",
"stars": "502",
"repo_language": "C++",
"file_name": "stdafx.cpp",
"mime_type": "text/x-c"
} |
all:
gcc -Wall main.c -o main
| {
"repo_name": "mwarning/SimpleDNS",
"stars": "108",
"repo_language": "C",
"file_name": "README.md",
"mime_type": "text/plain"
} |
#include <stdio.h>
#include <stdlib.h>
#include <arpa/inet.h>
#include <sys/socket.h>
#include <netdb.h>
#include <ifaddrs.h>
#include <string.h>
#include <malloc.h>
#include <errno.h>
#include <string.h>
#include <stdint.h>
#define BUF_SIZE 1500
#define MIN(x, y) ((x) <= (y) ? (x) : (y))
/*
* This software is licensed under the CC0.
*
* This is a _basic_ DNS Server for educational use.
* It does not prevent invalid packets from crashing
* the server.
*
* To test start the program and issue a DNS request:
* dig @127.0.0.1 -p 9000 foo.bar.com
*/
/*
* Masks and constants.
*/
static const uint32_t QR_MASK = 0x8000;
static const uint32_t OPCODE_MASK = 0x7800;
static const uint32_t AA_MASK = 0x0400;
static const uint32_t TC_MASK = 0x0200;
static const uint32_t RD_MASK = 0x0100;
static const uint32_t RA_MASK = 0x0080;
static const uint32_t RCODE_MASK = 0x000F;
/* Response Type */
enum {
Ok_ResponseType = 0,
FormatError_ResponseType = 1,
ServerFailure_ResponseType = 2,
NameError_ResponseType = 3,
NotImplemented_ResponseType = 4,
Refused_ResponseType = 5
};
/* Resource Record Types */
enum {
A_Resource_RecordType = 1,
NS_Resource_RecordType = 2,
CNAME_Resource_RecordType = 5,
SOA_Resource_RecordType = 6,
PTR_Resource_RecordType = 12,
MX_Resource_RecordType = 15,
TXT_Resource_RecordType = 16,
AAAA_Resource_RecordType = 28,
SRV_Resource_RecordType = 33
};
/* Operation Code */
enum {
QUERY_OperationCode = 0, /* standard query */
IQUERY_OperationCode = 1, /* inverse query */
STATUS_OperationCode = 2, /* server status request */
NOTIFY_OperationCode = 4, /* request zone transfer */
UPDATE_OperationCode = 5 /* change resource records */
};
/* Response Code */
enum {
NoError_ResponseCode = 0,
FormatError_ResponseCode = 1,
ServerFailure_ResponseCode = 2,
NameError_ResponseCode = 3
};
/* Query Type */
enum {
IXFR_QueryType = 251,
AXFR_QueryType = 252,
MAILB_QueryType = 253,
MAILA_QueryType = 254,
STAR_QueryType = 255
};
/*
* Types.
*/
/* Question Section */
struct Question {
char *qName;
uint16_t qType;
uint16_t qClass;
struct Question *next; // for linked list
};
/* Data part of a Resource Record */
union ResourceData {
struct {
uint8_t txt_data_len;
char *txt_data;
} txt_record;
struct {
uint8_t addr[4];
} a_record;
struct {
uint8_t addr[16];
} aaaa_record;
};
/* Resource Record Section */
struct ResourceRecord {
char *name;
uint16_t type;
uint16_t class;
uint32_t ttl;
uint16_t rd_length;
union ResourceData rd_data;
struct ResourceRecord *next; // for linked list
};
struct Message {
uint16_t id; /* Identifier */
/* Flags */
uint16_t qr; /* Query/Response Flag */
uint16_t opcode; /* Operation Code */
uint16_t aa; /* Authoritative Answer Flag */
uint16_t tc; /* Truncation Flag */
uint16_t rd; /* Recursion Desired */
uint16_t ra; /* Recursion Available */
uint16_t rcode; /* Response Code */
uint16_t qdCount; /* Question Count */
uint16_t anCount; /* Answer Record Count */
uint16_t nsCount; /* Authority Record Count */
uint16_t arCount; /* Additional Record Count */
/* At least one question; questions are copied to the response 1:1 */
struct Question *questions;
/*
* Resource records to be send back.
* Every resource record can be in any of the following places.
* But every place has a different semantic.
*/
struct ResourceRecord *answers;
struct ResourceRecord *authorities;
struct ResourceRecord *additionals;
};
int get_A_Record(uint8_t addr[4], const char domain_name[])
{
if (strcmp("foo.bar.com", domain_name) == 0) {
addr[0] = 192;
addr[1] = 168;
addr[2] = 1;
addr[3] = 1;
return 0;
} else {
return -1;
}
}
int get_AAAA_Record(uint8_t addr[16], const char domain_name[])
{
if (strcmp("foo.bar.com", domain_name) == 0) {
addr[0] = 0xfe;
addr[1] = 0x80;
addr[2] = 0x00;
addr[3] = 0x00;
addr[4] = 0x00;
addr[5] = 0x00;
addr[6] = 0x00;
addr[7] = 0x00;
addr[8] = 0x00;
addr[9] = 0x00;
addr[10] = 0x00;
addr[11] = 0x00;
addr[12] = 0x00;
addr[13] = 0x00;
addr[14] = 0x00;
addr[15] = 0x01;
return 0;
} else {
return -1;
}
}
int get_TXT_Record(char **addr, const char domain_name[])
{
if (strcmp("foo.bar.com", domain_name) == 0) {
*addr = "abcdefg";
return 0;
} else {
return -1;
}
}
/*
* Debugging functions.
*/
void print_hex(uint8_t *buf, size_t len)
{
int i;
printf("%zu bytes:\n", len);
for (i = 0; i < len; ++i)
printf("%02x ", buf[i]);
printf("\n");
}
void print_resource_record(struct ResourceRecord *rr)
{
int i;
while (rr) {
printf(" ResourceRecord { name '%s', type %u, class %u, ttl %u, rd_length %u, ",
rr->name,
rr->type,
rr->class,
rr->ttl,
rr->rd_length
);
union ResourceData *rd = &rr->rd_data;
switch (rr->type) {
case A_Resource_RecordType:
printf("Address Resource Record { address ");
for (i = 0; i < 4; ++i)
printf("%s%u", (i ? "." : ""), rd->a_record.addr[i]);
printf(" }");
break;
case AAAA_Resource_RecordType:
printf("AAAA Resource Record { address ");
for (i = 0; i < 16; ++i)
printf("%s%02x", (i ? ":" : ""), rd->aaaa_record.addr[i]);
printf(" }");
break;
case TXT_Resource_RecordType:
printf("Text Resource Record { txt_data '%s' }",
rd->txt_record.txt_data
);
break;
default:
printf("Unknown Resource Record { ??? }");
}
printf("}\n");
rr = rr->next;
}
}
void print_message(struct Message *msg)
{
struct Question *q;
printf("QUERY { ID: %02x", msg->id);
printf(". FIELDS: [ QR: %u, OpCode: %u ]", msg->qr, msg->opcode);
printf(", QDcount: %u", msg->qdCount);
printf(", ANcount: %u", msg->anCount);
printf(", NScount: %u", msg->nsCount);
printf(", ARcount: %u,\n", msg->arCount);
q = msg->questions;
while (q) {
printf(" Question { qName '%s', qType %u, qClass %u }\n",
q->qName,
q->qType,
q->qClass
);
q = q->next;
}
print_resource_record(msg->answers);
print_resource_record(msg->authorities);
print_resource_record(msg->additionals);
printf("}\n");
}
/*
* Basic memory operations.
*/
size_t get16bits(const uint8_t **buffer)
{
uint16_t value;
memcpy(&value, *buffer, 2);
*buffer += 2;
return ntohs(value);
}
void put8bits(uint8_t **buffer, uint8_t value)
{
memcpy(*buffer, &value, 1);
*buffer += 1;
}
void put16bits(uint8_t **buffer, uint16_t value)
{
value = htons(value);
memcpy(*buffer, &value, 2);
*buffer += 2;
}
void put32bits(uint8_t **buffer, uint32_t value)
{
value = htonl(value);
memcpy(*buffer, &value, 4);
*buffer += 4;
}
/*
* Deconding/Encoding functions.
*/
// 3foo3bar3com0 => foo.bar.com (No full validation is done!)
char *decode_domain_name(const uint8_t **buf, size_t len)
{
char domain[256];
for (int i = 1; i < MIN(256, len); i += 1) {
uint8_t c = (*buf)[i];
if (c == 0) {
domain[i - 1] = 0;
*buf += i + 1;
return strdup(domain);
} else if ((c >= 'a' && c <= 'z') || c == '-') {
domain[i - 1] = c;
} else {
domain[i - 1] = '.';
}
}
return NULL;
}
// foo.bar.com => 3foo3bar3com0
void encode_domain_name(uint8_t **buffer, const char *domain)
{
uint8_t *buf = *buffer;
const char *beg = domain;
const char *pos;
int len = 0;
int i = 0;
while ((pos = strchr(beg, '.'))) {
len = pos - beg;
buf[i] = len;
i += 1;
memcpy(buf+i, beg, len);
i += len;
beg = pos + 1;
}
len = strlen(domain) - (beg - domain);
buf[i] = len;
i += 1;
memcpy(buf + i, beg, len);
i += len;
buf[i] = 0;
i += 1;
*buffer += i;
}
void decode_header(struct Message *msg, const uint8_t **buffer)
{
msg->id = get16bits(buffer);
uint32_t fields = get16bits(buffer);
msg->qr = (fields & QR_MASK) >> 15;
msg->opcode = (fields & OPCODE_MASK) >> 11;
msg->aa = (fields & AA_MASK) >> 10;
msg->tc = (fields & TC_MASK) >> 9;
msg->rd = (fields & RD_MASK) >> 8;
msg->ra = (fields & RA_MASK) >> 7;
msg->rcode = (fields & RCODE_MASK) >> 0;
msg->qdCount = get16bits(buffer);
msg->anCount = get16bits(buffer);
msg->nsCount = get16bits(buffer);
msg->arCount = get16bits(buffer);
}
void encode_header(struct Message *msg, uint8_t **buffer)
{
put16bits(buffer, msg->id);
int fields = 0;
fields |= (msg->qr << 15) & QR_MASK;
fields |= (msg->rcode << 0) & RCODE_MASK;
// TODO: insert the rest of the fields
put16bits(buffer, fields);
put16bits(buffer, msg->qdCount);
put16bits(buffer, msg->anCount);
put16bits(buffer, msg->nsCount);
put16bits(buffer, msg->arCount);
}
int decode_msg(struct Message *msg, const uint8_t *buffer, int size)
{
int i;
decode_header(msg, &buffer);
if (msg->anCount != 0 || msg->nsCount != 0) {
printf("Only questions expected!\n");
return -1;
}
// parse questions
uint32_t qcount = msg->qdCount;
for (i = 0; i < qcount; ++i) {
struct Question *q = malloc(sizeof(struct Question));
q->qName = decode_domain_name(&buffer, size);
q->qType = get16bits(&buffer);
q->qClass = get16bits(&buffer);
if (q->qName == NULL) {
printf("Failed to decode domain name!\n");
return -1;
}
// prepend question to questions list
q->next = msg->questions;
msg->questions = q;
}
// We do not expect any resource records to parse here.
return 0;
}
// For every question in the message add a appropiate resource record
// in either section 'answers', 'authorities' or 'additionals'.
void resolve_query(struct Message *msg)
{
struct ResourceRecord *beg;
struct ResourceRecord *rr;
struct Question *q;
int rc;
// leave most values intact for response
msg->qr = 1; // this is a response
msg->aa = 1; // this server is authoritative
msg->ra = 0; // no recursion available
msg->rcode = Ok_ResponseType;
// should already be 0
msg->anCount = 0;
msg->nsCount = 0;
msg->arCount = 0;
// for every question append resource records
q = msg->questions;
while (q) {
rr = malloc(sizeof(struct ResourceRecord));
memset(rr, 0, sizeof(struct ResourceRecord));
rr->name = strdup(q->qName);
rr->type = q->qType;
rr->class = q->qClass;
rr->ttl = 60*60; // in seconds; 0 means no caching
printf("Query for '%s'\n", q->qName);
// We only can only answer two question types so far
// and the answer (resource records) will be all put
// into the answers list.
// This behavior is probably non-standard!
switch (q->qType) {
case A_Resource_RecordType:
rr->rd_length = 4;
rc = get_A_Record(rr->rd_data.a_record.addr, q->qName);
if (rc < 0)
{
free(rr->name);
free(rr);
goto next;
}
break;
case AAAA_Resource_RecordType:
rr->rd_length = 16;
rc = get_AAAA_Record(rr->rd_data.aaaa_record.addr, q->qName);
if (rc < 0)
{
free(rr->name);
free(rr);
goto next;
}
break;
case TXT_Resource_RecordType:
rc = get_TXT_Record(&(rr->rd_data.txt_record.txt_data), q->qName);
if (rc < 0) {
free(rr->name);
free(rr);
goto next;
}
int txt_data_len = strlen(rr->rd_data.txt_record.txt_data);
rr->rd_length = txt_data_len + 1;
rr->rd_data.txt_record.txt_data_len = txt_data_len;
break;
/*
case NS_Resource_RecordType:
case CNAME_Resource_RecordType:
case SOA_Resource_RecordType:
case PTR_Resource_RecordType:
case MX_Resource_RecordType:
case TXT_Resource_RecordType:
*/
default:
free(rr);
msg->rcode = NotImplemented_ResponseType;
printf("Cannot answer question of type %d.\n", q->qType);
goto next;
}
msg->anCount++;
// prepend resource record to answers list
beg = msg->answers;
msg->answers = rr;
rr->next = beg;
// jump here to omit question
next:
// process next question
q = q->next;
}
}
/* @return 0 upon failure, 1 upon success */
int encode_resource_records(struct ResourceRecord *rr, uint8_t **buffer)
{
int i;
while (rr) {
// Answer questions by attaching resource sections.
encode_domain_name(buffer, rr->name);
put16bits(buffer, rr->type);
put16bits(buffer, rr->class);
put32bits(buffer, rr->ttl);
put16bits(buffer, rr->rd_length);
switch (rr->type) {
case A_Resource_RecordType:
for (i = 0; i < 4; ++i)
put8bits(buffer, rr->rd_data.a_record.addr[i]);
break;
case AAAA_Resource_RecordType:
for (i = 0; i < 16; ++i)
put8bits(buffer, rr->rd_data.aaaa_record.addr[i]);
break;
case TXT_Resource_RecordType:
put8bits(buffer, rr->rd_data.txt_record.txt_data_len);
for (i = 0; i < rr->rd_data.txt_record.txt_data_len; i++)
put8bits(buffer, rr->rd_data.txt_record.txt_data[i]);
break;
default:
fprintf(stderr, "Unknown type %u. => Ignore resource record.\n", rr->type);
return 1;
}
rr = rr->next;
}
return 0;
}
/* @return 0 upon failure, 1 upon success */
int encode_msg(struct Message *msg, uint8_t **buffer)
{
struct Question *q;
int rc;
encode_header(msg, buffer);
q = msg->questions;
while (q) {
encode_domain_name(buffer, q->qName);
put16bits(buffer, q->qType);
put16bits(buffer, q->qClass);
q = q->next;
}
rc = 0;
rc |= encode_resource_records(msg->answers, buffer);
rc |= encode_resource_records(msg->authorities, buffer);
rc |= encode_resource_records(msg->additionals, buffer);
return rc;
}
void free_resource_records(struct ResourceRecord *rr)
{
struct ResourceRecord *next;
while (rr) {
free(rr->name);
next = rr->next;
free(rr);
rr = next;
}
}
void free_questions(struct Question *qq)
{
struct Question *next;
while (qq) {
free(qq->qName);
next = qq->next;
free(qq);
qq = next;
}
}
int main()
{
// buffer for input/output binary packet
uint8_t buffer[BUF_SIZE];
struct sockaddr_in client_addr;
socklen_t addr_len = sizeof(struct sockaddr_in);
struct sockaddr_in addr;
int rc;
ssize_t nbytes;
int sock;
int port = 9000;
struct Message msg;
memset(&msg, 0, sizeof(struct Message));
addr.sin_family = AF_INET;
addr.sin_addr.s_addr = INADDR_ANY;
addr.sin_port = htons(port);
sock = socket(AF_INET, SOCK_DGRAM, 0);
rc = bind(sock, (struct sockaddr*) &addr, addr_len);
if (rc != 0) {
printf("Could not bind: %s\n", strerror(errno));
return 1;
}
printf("Listening on port %u.\n", port);
while (1) {
free_questions(msg.questions);
free_resource_records(msg.answers);
free_resource_records(msg.authorities);
free_resource_records(msg.additionals);
memset(&msg, 0, sizeof(struct Message));
/* Receive DNS query */
nbytes = recvfrom(sock, buffer, sizeof(buffer), 0, (struct sockaddr *) &client_addr, &addr_len);
if (decode_msg(&msg, buffer, nbytes) != 0) {
continue;
}
/* Print query */
print_message(&msg);
/* Resolve query and put the answers into the query message */
resolve_query(&msg);
/* Print response */
print_message(&msg);
uint8_t *p = buffer;
if (encode_msg(&msg, &p) != 0) {
continue;
}
/* Send DNS response */
int buflen = p - buffer;
sendto(sock, buffer, buflen, 0, (struct sockaddr*) &client_addr, addr_len);
}
}
| {
"repo_name": "mwarning/SimpleDNS",
"stars": "108",
"repo_language": "C",
"file_name": "README.md",
"mime_type": "text/plain"
} |
### Introduction
SimpleDNS is a very simple DNS server written in C.
It was made to learn the basics of the DNS protocol.
Features:
* very small
* single-threaded
* very simplistic memory management
* supports A, AAAA and TXT queries
* no full protection against invalid requests :|
### Build
```
git clone https://github.com/mwarning/SimpleDNS.git
cd SimpleDNS
make
```
### Test
Start SimpleDNS:
```
$./main
Listening on port 9000.
```
In another console execute [dig](http://linux.die.net/man/1/dig) to make a DNS request:
```
$ dig @127.0.0.1 -p 9000 foo.bar.com A
; <<>> DiG 9.8.4-rpz2+rl005.12-P1 <<>> @127.0.0.1 -p 9000 foo.bar.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 15287
;; flags: qr; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0
;; QUESTION SECTION:
;foo.bar.com. IN A
;; ANSWER SECTION:
foo.bar.com. 0 IN A 192.168.1.1
;; Query time: 0 msec
;; SERVER: 127.0.0.1#9000(127.0.0.1)
;; WHEN: Mon Apr 15 00:50:38 2013
;; MSG SIZE rcvd: 56
```
Note:
- On Debian Linux, `dig` is part of the dnsutils package.
- Use AAAA instead of A in the dig command line to request the IPv6 address.
## Modify address entries
The code maps the domain `foo.bar.com` to the IPv4 address `192.168.1.1` and IPv6 address `fe80::1`.
It is easy to find it in the code and to add other entries.
### Recommended Reading
The DNS section of the [TCP/IP-Guide](http://www.tcpipguide.com/free/t_TCPIPDomainNameSystemDNS.htm) was very helpful for understanding the protocol.
## Similar Projects
* https://github.com/wfelipe/simple-dns
| {
"repo_name": "mwarning/SimpleDNS",
"stars": "108",
"repo_language": "C",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Orchestra.nvim
### Add another dimension to your coding experience
- [Introduction](#introduction)
- [Installing](#installing)
- [Dependencies](#dependencies)
- [Usage](#usage)
- [Plug and Play](#plugandplay)
- [Configuring](#configuring)
__Status = ALPHA i.e api may change/improve__
#### News
* [New bubbletrouble theme](https://github.com/timeyyy/bubbletrouble.symphony)
## <a id="introduction"></a>Introduction
Orchestra.nvim is a plugin for neovim that lets you bind sound effects
to different actions. The motivation was mostly for fun but it seems
useful for training good vim habits. You can literally hear unproductivity
and when/where you could improve.
## <a id="installing"></a>Installing
I use dein.vim
```VimL
call dein#add('timeyyy/orchestra.nvim')
```
Then run
```VimL
call dein#install()
UpdateRemotePlugins
```
### <a id="dependencies"></a>Dependencies
* python3
* the neovim client for python - `pip install neovim`
* pyaudio - [install instructions](http://people.csail.mit.edu/hubert/pyaudio/)
## <a id="usage"></a>Usage
We have some rudimentary theme (tune) support
```VimL
call dein#add('timeyyy/clacklack.symphony')
call orchestra#prelude()
call orchestra#set_tune('clackclack')
```
[List of Themes](https://github.com/timeyyy/orchestra.nvim/wiki/Themes)
### <a id="configuring"></a>Configuring
Themes are just normal vim plugins with a few requirements.
e.g theme "bumblebee\_flight":
autoload/
bumblebee_flight.vim - the main file
buzz.wav - audio file
flap.wav
flap_1.wav
flap_2.wav
bublebee\_flight.vim:
```VimL
" Absolute path of script file with symbolic links resolved:
let s:current_file = resolve(expand('<sfile>:p'))
call OrchestraAddPath(s:current_file)
```
We can now customize the behavior of our script. For the moment we only have `Ostinato` which is just autocmds.
```VimL
call Ostinato('CursorMovedI', 'flap.wav')
call Ostinato('CursorMoved', 'buzz.wav')
```
If you just don't want to install a theme you can call `Ostinato` from within your vimrc as long as it is after `orchestra#prelude()`
The Ostinato can handle multiple audio files.
Multiple parts suffixed with : \_# will automatically be discovered and played back at random.
**Note** audio files must be saved as 16bit wav, 32bit will NOT work
#### Plans
* Allow binding to specific keys
* Custom Events, i.e bind to a range of chars being deleted/inserted
* More themes
* Figure out why 80% Autcommands are not procing..
* Ability to squelch/prioritize simultaneous events
* Introspection functions i.e see what is registerd
* Unregister Function
| {
"repo_name": "timeyyy/orchestra.nvim",
"stars": "47",
"repo_language": "Python",
"file_name": "nvim-example-python-plugin.txt",
"mime_type": "text/plain"
} |
function! orchestra#prelude()
" Can now use our rmeote plugin functio from within vimrc
runtime! plugin/rplugin.vim
endfunction
function! orchestra#set_tune(theme)
" Python3 function
call OrchestraSetTheme(a:theme)
endfunction
| {
"repo_name": "timeyyy/orchestra.nvim",
"stars": "47",
"repo_language": "Python",
"file_name": "nvim-example-python-plugin.txt",
"mime_type": "text/plain"
} |
import os
import neovim
import orchestra.orchestra as orch
import orchestra.util as util
@neovim.plugin
class Main(util.VimMix, object):
def __init__(self, vim):
# Anything called from this __in__ cannot run
# any commands in vim, otherwise wierd errors happen!!!
self.vim = vim
self.DEBUG = False
self.orch = orch.Orchestra(vim, main=self)
self.orch.DEBUG = self.DEBUG
self.setup_functions()
if self.DEBUG:
self.logger = util.setup_logger('log_orchestra.log')
self.orch.logger= self.logger
self.logger.add('Finish Plugin __init__')
@neovim.function('Ostinato')
def ostinato(self, args):
'''
Register a autocommand to an audio file,
for each audio file you can have multiple
parts which will automatically be added.
e.g call Ensemble('CursorMoved', 'keys.wav')
if keys_1 is present it will also be added.
until keys_n+1 doesn't exist.
starts from _1 not _0
'''
assert len(args) >= 2
self.orch.ostinato(*args)
@neovim.function('OrchestraSetTheme', sync=True)
def set_theme(self, args):
assert len(args) == 1
theme = args[0]
self.orch.set_theme(theme)
@neovim.function('OrchestraAddPath', sync=True)
def add_path(self, args):
assert len(args) == 1
abs_path_theme = args[0]
self.orch.add_path(abs_path_theme)
def setup_functions(self):
'''
For the moment neovim handlers for functions
only get checked at startup.
We define a bunch of functions so autocommands
can we registered to them.
'''
# TODO Remove this when neovim updates
for event in util.AUTOCMDS:
func_name = 'Orchestra_' + event
@neovim.function(func_name)
def func(nvim, audio):
self.orch.queue_audio(audio)
setattr(self, func_name, func)
| {
"repo_name": "timeyyy/orchestra.nvim",
"stars": "47",
"repo_language": "Python",
"file_name": "nvim-example-python-plugin.txt",
"mime_type": "text/plain"
} |
import _thread as thread
# from threading import Thread
# import threading
from concurrent import futures
import queue
import random
import os
import neovim
import orchestra.util as util
class ThemeMix(util.VimMix):
def __init__(self):
super().__init__()
self.audio_paths = {}
self.audio_paths[None] = os.path.dirname(__file__)
self.theme = None
def set_theme(self, theme):
'''
runs the theme file, registering stuff to do
'''
self.theme = theme
self.theme_path = 'autoload'
# TODO MAKE THIS ERROR OUT IF IT DOESN'T FIND ANYTHING
# could be done by messing around with the verbose variable..
self.vim.command('runtime! {0}/{1}.vim'.format(
self.theme_path,
theme))
def add_path(self, abs_path_theme):
'''
registers the theme so we know which
paths to look in for audio files
'''
theme = os.path.basename(abs_path_theme)
theme = os.path.splitext(theme)[0]
path = os.path.dirname(abs_path_theme)
self.audio_paths[theme] = path
def get_audio(self, audio):
'''
returns all audio parts with absolute paths
the current theme has priority, otherwise
search all other paths
'''
# TODO COPY IN THE THE TRACK IF IT DOESNT
# EXIST IN THE THEME THAT IS USING IT
# TODO if multiple tracks with a name exist
# and md5 differ
# and we have to copy one in then just
# raise an error..
found = []
theme_path = self.audio_paths[self.theme]
for track in audio:
audio_parts = util.get_audio_parts(
os.path.join(theme_path, track))
if audio_parts:
found.extend(audio_parts)
else:
# TODO this is untested :(
for theme, path in self.audio_paths.items():
audio_parts = util.get_audio_parts(
os.path.join(path, track))
if audio_parts:
found.extend(audio_parts)
break
else:
raise FileNotFoundError('Could not find: ' + track)
return found
class FunctionsMix(util.VimMix):
def ostinato(self, event, *audio):
audio = self.get_audio(audio)
if event in util.CUSTOMCMDS:
# Custom event type.. spit out into another func?
raise NotImplementedError
else:
assert event in util.AUTOCMDS
# TODO reinstate this and remove setup_functions
# when neovim updates..
# @neovim.autocmd(event)
# def func(nvim):
# self.echom('adding to queue')
# self.queue_audio(audio)
func_name = 'Orchestra_' + event
# setattr(self.main, func_name, func)
# TODO extend for multple aruguments
# assert len(audio) == 1
# cmd = "call {}('{}')".format(
# func_name, *audio)
cmd = self._build_cmd(func_name, audio)
self.vim.command("augroup " + func_name)
self.vim.command("autocmd!")
self.vim.command("autocmd {event} * {cmd}".format(
event=event,
cmd=cmd))
self.vim.command("augroup END")
if self.main.DEBUG:
self.logger.add('made new autocmd for '
+ func_name)
def _build_cmd(self, func_name, audio):
# To handle variable length arugements
parts = ['call {}'.format(func_name)]
parts.append('(')
brackets = "'{}'," * len(audio)
# Remove the last comma
parts.append(brackets[:-1])
parts.append(')')
formatstr = ''.join(parts)
return formatstr.format(*audio)
class Orchestra(ThemeMix, FunctionsMix):
def __init__(self, vim, main):
# cannot run vim comamands here, as this is
# called from pluging __init__, otherwise wierd
# errors happen!!!
super().__init__()
self.vim = vim
self.main = main
self._audio_queue = queue.Queue()
self.ex = futures.ThreadPoolExecutor(max_workers=8)
self.consume()
def consume(self):
'''
check the audio queue for things to play
'''
def do():
while True:
try:
audio = self._audio_queue.get(block=True)
except queue.Empty:
pass
else:
self.ex.submit(self._play_sound, audio)
thread.start_new_thread(do, (),)
def _play_sound(self, audio):
# Pick audio from random
index = random.randint(0, len(audio)-1)
check = util.play_sound(audio[index])
if not check:
raise Exception('should fail in get_audio-parts...')
@util.rate_limited(10, mode='kill')
def queue_audio(self, audio):
self._audio_queue.put(audio)
| {
"repo_name": "timeyyy/orchestra.nvim",
"stars": "47",
"repo_language": "Python",
"file_name": "nvim-example-python-plugin.txt",
"mime_type": "text/plain"
} |
import os
import wave
import platform
import threading
from functools import wraps
import time
import pyaudio
CUSTOMCMDS = (),
AUTOCMDS = (
'BufNewFile', 'BufReadPre', 'BufRead', 'BufReadPost',
'BufReadCmd', 'FileReadPre', 'FileReadPost', 'FileReadCmd',
'FilterReadPre', 'FilterReadPost', 'StdinReadPre',
'StdinReadPost', 'BufWrite', 'BufWritePre', 'BufWritePost',
'BufWriteCmd', 'FileWritePre', 'FileWritePost',
'FileWriteCmd', 'FileAppendPre', 'FileAppendPost',
'FileAppendCmd', 'FilterWritePre', 'FilterWritePost',
'BufAdd', 'BufCreate', 'BufDelete', 'BufWipeout',
'BufFilePre', 'BufFilePost', 'BufEnter', 'BufLeave',
'BufWinEnter', 'BufWinLeave', 'BufUnload', 'BufHidden',
'BufNew', 'SwapExists', 'TermOpen', 'TermClose',
'FileType', 'Syntax', 'EncodingChanged', 'TermChanged',
'OptionSet', 'VimEnter', 'GUIEnter', 'GUIFailed',
'TermResponse', 'QuitPre', 'VimLeavePre', 'VimLeave',
'FileChangedShell', 'FileChangedShellPost', 'FileChangedRO',
'ShellCmdPost', 'ShellFilterPost', 'CmdUndefined',
'FuncUndefined', 'SpellFileMissing', 'SourcePre', 'SourceCmd',
'VimResized', 'FocusGained', 'FocusLost', 'CursorHold',
'CursorHoldI', 'CursorMoved', 'CursorMovedI', 'WinEnter',
'WinLeave', 'TabEnter', 'TabLeave', 'TabNew',
'TabNewEntered', 'TabClosed', 'CmdwinEnter', 'CmdwinLeave',
'InsertEnter', 'InsertChange', 'InsertLeave', 'InsertCharPre',
'TextYankPost', 'TextChanged', 'TextChangedI', 'ColorScheme',
'RemoteReply', 'QuickFixCmdPre', 'QuickFixCmdPost',
'SessionLoadPost', 'MenuPopup', 'CompleteDone', 'User',)
class VimMix():
def echom(self, thing):
self.vim.command('echom "{0}"'.format(thing))
def play_sound(file):
if not os.path.isfile(file):
return False
# open the file for reading.
wf = wave.open(file, 'rb')
# create an audio object
p = pyaudio.PyAudio()
# open stream based on the wave object which has been input.
stream = p.open(format =
p.get_format_from_width(wf.getsampwidth()),
channels = wf.getnchannels(),
rate = wf.getframerate(),
output = True)
# read data
data = wf.readframes(wf.getnframes())
# play sound
stream.write(data)
# cleanup stuff.
stream.close()
p.terminate()
return True
def etb(func, *args, **kwargs):
'''
error to bool
'''
try:
return func(*args, **kwargs)
except Exception:
return False
def get_audio_parts(file):
'''
see orchestra.__init__.ensemble
'''
def plus1(file):
path, ext = os.path.splitext(file)
split = path.split('_')
old_num = etb(int, split[-1])
if not old_num:
split.append('1')
else:
split[-1] = str(old_num + 1)
return '_'.join(split) + ext
parts = []
if os.path.exists(file):
parts.append(file)
part = plus1(file)
while os.path.exists(part):
parts.append(part)
part = plus1(part)
return parts
class InMemoryWriter(list, object):
"""
simplify editing files
On creation you can read all contents either from:
an open file,
a list
a path/name to a file
While iterating you can set copy=True to edit data
as you iterate over it
you can accesses the current position using self.i, useful if
you are using filter or something like that while iterating
"""
def __init__(self, file=None, copy=False):
list.__init__(self)
self.copy = copy
self.data = self
if isinstance(file, str):
try:
with open(file, 'r') as f:
self.writelines(f)
self.original_filename = file
except FileNotFoundError as err:
raise err
elif file:
self.writelines(file)
def write(self, stuff):
self.append(stuff)
def writelines(self, passed_data):
for item in passed_data:
self.data.append(item)
def __call__(self, copy=None):
if copy:
self.copy = True
return self
def __iter__(self):
self.i = 0
if self.copy:
self.data_copy = self.data[:]
return self
def __next__(self):
if self.i + 1 > len(self.data):
try:
del self.data_copy
except AttributeError:
pass
raise StopIteration
if not self.copy:
requested = self.data[self.i]
else:
requested = self.data_copy[self.i]
self.i += 1
return requested
def close(self):
pass
def readlines(self):
return self.data
def save(self, path=False):
if not path:
path = self.original_filename
with open(path, 'w') as file:
for row in self.data:
file.write(row)
def add(self, thing):
self.write(thing+'\n')
self.save()
def setup_logger(log_file):
'''
couldn't get logging module to work fml...
just call file.add()
'''
if os.path.exists(log_file):
os.remove(log_file)
open(log_file, 'w').close()
file = InMemoryWriter(log_file)
file.add('System is: %s' % platform.platform())
file.add('Python archetecture is: %s' %
platform.architecture()[0])
file.add('Machine archetecture is: %s' %
platform.machine())
return file
def rate_limited(max_per_second, mode='wait', delay_first_call=False):
"""
Decorator that make functions not be called faster than
set mode to 'kill' to just ignore requests that are faster than the
rate.
set mode to 'refresh_timer' to reset the timer on successive calls
set delay_first_call to True to delay the first call as well
"""
lock = threading.Lock()
min_interval = 1.0 / float(max_per_second)
def decorate(func):
last_time_called = [0.0]
@wraps(func)
def rate_limited_function(*args, **kwargs):
def run_func():
lock.release()
ret = func(*args, **kwargs)
last_time_called[0] = time.perf_counter()
return ret
lock.acquire()
elapsed = time.perf_counter() - last_time_called[0]
left_to_wait = min_interval - elapsed
if delay_first_call:
if left_to_wait > 0:
if mode == 'wait':
time.sleep(left_to_wait)
return run_func()
elif mode == 'kill':
lock.release()
return
else:
return run_func()
else:
if not last_time_called[0] or elapsed > min_interval:
return run_func()
elif mode == 'refresh_timer':
print('Ref timer')
lock.release()
last_time_called[0] += time.perf_counter()
return
elif left_to_wait > 0:
if mode == 'wait':
time.sleep(left_to_wait)
return run_func()
elif mode == 'kill':
lock.release()
return
return rate_limited_function
return decorate
if __name__ == '__main__':
play_sound(os.path.abspath('woosh.wav'))
# print(get_audio_parts(['keyboard_slow.wav']))
| {
"repo_name": "timeyyy/orchestra.nvim",
"stars": "47",
"repo_language": "Python",
"file_name": "nvim-example-python-plugin.txt",
"mime_type": "text/plain"
} |
*nvim-example-python-plugin.txt* A template of a remote Python plugin.
Example Remote Python Plugin
==============================================================================
CONTENTS *nvim-example-python-plugin-contents*
1. Introduction .................... |nvim-example-python-plugin-intro|
Original Author: Jacob Simpson
License: The Unlicense
INTRODUCTION *nvim-example-python-plugin-intro*
A very simple example of a Python plugin in the new remote plugin style used by
Neovim.
| {
"repo_name": "timeyyy/orchestra.nvim",
"stars": "47",
"repo_language": "Python",
"file_name": "nvim-example-python-plugin.txt",
"mime_type": "text/plain"
} |
//
// Created by Administrator on 2022.11.30.
//
#include "TimeUtils.h"
#include <windows.h>
u64 currentTimeMillis() {
FILETIME ft = {};
GetSystemTimeAsFileTime(&ft);
u64 ret = ft.dwHighDateTime;
ret <<= 32;
ret |= ft.dwLowDateTime;
ret /= 10000LLU;
return ret - 116444736000000000LLU;
}
u64 currentTimeSeconds() {
return currentTimeMillis() / 1000LLU;
}
void timeMillisToUTCCalendar(u64 timeMillis, int *year, int *month, int *day, int *hour, int *minute, int *second, int *millisecond) {
SYSTEMTIME st = {};
FILETIME ft = {};
u64 fileTime = (timeMillis + 116444736000000000LLU) * 10000LLU;
ft.dwHighDateTime = (DWORD) (fileTime >> 32);
ft.dwLowDateTime = (DWORD) fileTime;
FileTimeToSystemTime(&ft, &st);
if (year != nullptr) {
*year = st.wYear;
}
if (month != nullptr) {
*month = st.wMonth;
}
if (day != nullptr) {
*day = st.wDay;
}
if (hour != nullptr) {
*hour = st.wHour;
}
if (minute != nullptr) {
*minute = st.wMinute;
}
if (second != nullptr) {
*second = st.wSecond;
}
if (millisecond != nullptr) {
*millisecond = st.wMilliseconds;
}
}
static u64 gsTimeBiasSeconds = 0;
static bool gsTimeBiasSecondsInitialized = false;
s32 getLocalTimeBiasSeconds() {
if (!gsTimeBiasSecondsInitialized) {
TIME_ZONE_INFORMATION tzi = {};
GetTimeZoneInformation(&tzi);
gsTimeBiasSeconds = -tzi.Bias * 60LU;
gsTimeBiasSecondsInitialized = true;
}
return gsTimeBiasSeconds;
}
void timeMillisToLocalCalendar(u64 timeMillis, int *year, int *month, int *day, int *hour, int *minute, int *second, int *millisecond) {
u64 timeWithBias = timeMillis + getLocalTimeBiasSeconds() * 1000;
timeMillisToUTCCalendar(timeWithBias, year, month, day, hour, minute, second, millisecond);
}
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
#include "WsaPatch.h"
#include <string>
#include <string_view>
#include <windows.h>
#include "Log.h"
#include "ErrnoRestorer.h"
#include "TimeUtils.h"
static constexpr auto LOG_TAG = L"WsaPatch";
namespace wsapatch {
bool kDebug = false;
HINSTANCE gSelfInstance = nullptr;
HANDLE gConsoleOutput = INVALID_HANDLE_VALUE;
bool gConsoleIsAllocated = false;
HMODULE hNtdll = nullptr;
HMODULE hWsaClient = nullptr;
RTL_OSVERSIONINFOEXW gOsVersionInfo = {0};
bool gIsPatchVersionNumber = false;
bool gIsPatchProductType = false;
#define NT_SUCCESS(Status) (((NTSTATUS)(Status)) >= 0)
#define STATUS_SUCCESS ((NTSTATUS)0x00000000L)
void defaultLogHandler(Log::Level level, const WCHAR *tag, const WCHAR *msg) {
HANDLE handle = gConsoleOutput;
if (handle == nullptr || handle == INVALID_HANDLE_VALUE) {
return;
}
WCHAR buffer[1024] = {};
u64 now = currentTimeMillis();
const WCHAR *levelName = Log::levelName(level);
// MM-dd HH:mm:ss.SSS [level] tag: msg
int month = 0, day = 0, hour = 0, minute = 0, second = 0, millisecond = 0;
timeMillisToLocalCalendar(now, nullptr, &month, &day, &hour, &minute, &second, &millisecond);
StringCchPrintfW(buffer, _countof(buffer),
L"%02d-%02d %02d:%02d:%02d.%03d %c %s: %s\n",
month, day, hour, minute, second, millisecond,
WCHAR(*levelName), tag, msg);
DWORD written = 0;
WriteConsoleW(handle, buffer, static_cast<DWORD>(wcslen(buffer)), &written, nullptr);
}
using FuncRtlGetVersion = NTSYSAPI NTSTATUS(*)(PRTL_OSVERSIONINFOW lpVersionInformation);
NTSTATUS WINAPI FakeRtlGetVersion(PRTL_OSVERSIONINFOW lpVersionInformation) {
// The minimal version is 10.0.22000.120 VER_NT_WORKSTATION
LOGD(L"-FakeRtlGetVersion");
DWORD size = lpVersionInformation->dwOSVersionInfoSize;
memcpy(lpVersionInformation, &gOsVersionInfo, size);
lpVersionInformation->dwOSVersionInfoSize = size;
if (gIsPatchVersionNumber) {
lpVersionInformation->dwBuildNumber = 22000;
}
if (gIsPatchProductType && size >= sizeof(OSVERSIONINFOEXW)) {
((PRTL_OSVERSIONINFOEXW) lpVersionInformation)->wProductType = VER_NT_WORKSTATION;
}
return STATUS_SUCCESS;
}
FARPROC WINAPI BadGetProcAddress(_In_ HMODULE hModule, _In_ LPCSTR lpProcName) {
FARPROC result;
if (hModule == hNtdll && lpProcName != nullptr && strcmp(lpProcName, "RtlGetVersion") == 0) {
result = reinterpret_cast<FARPROC>(FakeRtlGetVersion);
SetLastError(0);
} else {
result = GetProcAddress(hModule, lpProcName);
if (result == nullptr) {
ErrnoRestorer errnoRestorer;
if (hModule != nullptr) {
WCHAR buffer[1024] = {};
GetModuleFileNameW(hModule, buffer, _countof(buffer));
LOGW(L"-GetProcAddress: hModule=%s(%p), lpProcName=%hs, result=NULL", buffer, hModule, lpProcName);
} else {
LOGW(L"-GetProcAddress: hModule=NULL, lpProcName=%hs, result=NULL", lpProcName ? lpProcName : "NULL");
}
}
}
return result;
}
usize kPageSize = 0;
bool isAddressReadable(void *address) {
if (kPageSize == 0) {
SYSTEM_INFO si = {};
GetSystemInfo(&si);
kPageSize = si.dwPageSize;
}
void *pageBase = reinterpret_cast<void *>(reinterpret_cast<uintptr>(address) & ~(kPageSize - 1));
MEMORY_BASIC_INFORMATION info = {};
if (VirtualQuery(pageBase, &info, sizeof(info)) == 0) {
return false;
}
return (info.Protect & PAGE_READONLY) != 0 || (info.Protect & PAGE_READWRITE) != 0;
}
int HookIATProcedure(HMODULE hModule, LPCSTR procName, FARPROC replacement) {
if (hModule == nullptr || procName == nullptr || replacement == nullptr) {
LOGE(L"HookIATProcedure: invalid arguments: hModule=%p, procName=%hs, replacement=%p",
hModule, procName ? procName : "(NULL)", replacement);
return 0;
}
LOGI(L"HookIATProcedure: start, hModule=%p, procName=%hs, replacement=%p", hModule, procName, replacement);
PIMAGE_DOS_HEADER pDosHeader = (PIMAGE_DOS_HEADER) hModule;
PIMAGE_NT_HEADERS pNtHeaders = (PIMAGE_NT_HEADERS) ((BYTE *) hModule + pDosHeader->e_lfanew);
PIMAGE_IMPORT_DESCRIPTOR pImportDesc = (PIMAGE_IMPORT_DESCRIPTOR)
((BYTE *) hModule + pNtHeaders->OptionalHeader.DataDirectory[IMAGE_DIRECTORY_ENTRY_IMPORT].VirtualAddress);
int count = 0;
for (; pImportDesc->Name != 0; pImportDesc++) {
PIMAGE_THUNK_DATA pThunk = (PIMAGE_THUNK_DATA) ((BYTE *) hModule + pImportDesc->FirstThunk);
PIMAGE_THUNK_DATA pOrgThunk = (PIMAGE_THUNK_DATA) ((BYTE *) hModule + pImportDesc->OriginalFirstThunk);
for (; pThunk->u1.Function != 0; pThunk++, pOrgThunk++) {
if (IMAGE_SNAP_BY_ORDINAL(pOrgThunk->u1.Ordinal)) {
continue;
}
PIMAGE_IMPORT_BY_NAME pImport = (PIMAGE_IMPORT_BY_NAME) ((BYTE *) hModule + pOrgThunk->u1.AddressOfData);
if (!isAddressReadable((char *) pImport->Name)) {
LOGE(L"HookIATProcedure: pImport->Name is not readable: %p", pImport->Name);
WCHAR buffer[1024] = {};
GetModuleFileNameW(hModule, buffer, _countof(buffer));
LOGE(L"HookIATProcedure: abort IAT hook, hModule=%s(%p), procName=%hs, replacement=%p",
buffer, hModule, procName, replacement);
return -1;
}
if (strcmp((char *) pImport->Name, procName) == 0) {
LOGI(L"HookIATProcedure: Found %hs at %p", procName, pThunk);
DWORD oldProtect = 0;
VirtualProtect(pThunk, sizeof(PVOID), PAGE_READWRITE, &oldProtect);
pThunk->u1.Function = (DWORD_PTR) replacement;
VirtualProtect(pThunk, sizeof(PVOID), oldProtect, &oldProtect);
count++;
}
}
}
LOGI(L"HookIATProcedure: end, count=%d", count);
return count;
}
void checkEnableDebugConsole() {
WCHAR exePath[1024] = {};
if (GetModuleFileNameW(nullptr, exePath, 1024) != 0) {
std::wstring path = exePath;
auto dirLen = path.find_last_of('\\');
if (dirLen == std::wstring::npos) {
dirLen = 0;
}
std::wstring enableDebugConsole = path.substr(0, dirLen) + L"\\EnableDebugConsole";
if (GetFileAttributesW(enableDebugConsole.c_str()) != INVALID_FILE_ATTRIBUTES) {
kDebug = true;
}
}
}
bool OnLoad(HINSTANCE hInstDLL) {
gSelfInstance = hInstDLL;
hNtdll = GetModuleHandleW(L"ntdll.dll");
if (hNtdll == nullptr) {
return false;
}
checkEnableDebugConsole();
hWsaClient = GetModuleHandleW(L"WsaClient.exe");
if (kDebug) {
if (AllocConsole()) {
gConsoleIsAllocated = true;
}
gConsoleOutput = CreateFileW(L"CONOUT$", GENERIC_WRITE, FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, nullptr);
if (gConsoleOutput != INVALID_HANDLE_VALUE) {
Log::setLogHandler(&defaultLogHandler);
} else {
std::wstring msg = std::wstring(L"Error CreateFileW CONOUT$, GetLastError=") + std::to_wstring(GetLastError());
MessageBoxW(nullptr, msg.c_str(), L"wsapatch.dll", MB_OK | MB_ICONERROR);
}
}
LOGD(L"OnLoad, hInstDLL=%p, hNtdll=%p, hWsaClient=%p", hInstDLL, hNtdll, hWsaClient);
if (hWsaClient == nullptr) {
// check if we are loaded into the correct process
WCHAR filename[MAX_PATH];
GetModuleFileNameW(nullptr, filename, MAX_PATH);
// get lower case filename
for (int i = 0; filename[i] != 0; i++) {
filename[i] = towlower(filename[i]);
}
if (wcsstr(filename, L"\\wsaclinent.exe") == nullptr) {
WCHAR buf[1024] = {};
StringCbPrintfW(buf, 1024, L"GetModuleHandleW(L\"WsaClient.exe\") is NULL.\nIs wsapatch.dll loaded into wrong process?\n%s", filename);
MessageBoxW(nullptr, buf, L"wsapatch.dll", MB_OK | MB_ICONERROR);
return false;
}
return false;
}
LOGD(L"ntdll.dll = %p", hNtdll);
LOGD(L"WsaClient.exe = %p", hWsaClient);
FuncRtlGetVersion funcRtlGetVersion = reinterpret_cast<FuncRtlGetVersion>(GetProcAddress(hNtdll, "RtlGetVersion"));
if (funcRtlGetVersion == nullptr) {
LOGE(L"GetProcAddress(NTDLL.DLL, \"RtlGetVersion\") failed, GetLastError=%d", GetLastError());
return false;
}
gOsVersionInfo.dwOSVersionInfoSize = sizeof(gOsVersionInfo);
NTSTATUS status = funcRtlGetVersion(reinterpret_cast<PRTL_OSVERSIONINFOW>(&gOsVersionInfo));
if (!NT_SUCCESS(status)) {
LOGE(L"funcRtlGetVersion(&osVersionInfo) failed, status=%d", status);
return false;
}
LOGD(L"RtlGetVersion: dwMajorVersion=%d, dwMinorVersion=%d, dwBuildNumber=%d, dwPlatformId=%d",
gOsVersionInfo.dwMajorVersion, gOsVersionInfo.dwMinorVersion, gOsVersionInfo.dwBuildNumber, gOsVersionInfo.dwPlatformId);
bool isWin11 = gOsVersionInfo.dwMajorVersion >= 10 && gOsVersionInfo.dwMinorVersion >= 0 && gOsVersionInfo.dwBuildNumber >= 22000;
gIsPatchVersionNumber = !isWin11;
gIsPatchProductType = (gOsVersionInfo.wProductType != VER_NT_WORKSTATION);
if (!gIsPatchVersionNumber && !gIsPatchProductType) {
LOGW(L"Windows 11 workstation detected, no need to patch");
return true;
}
LOGD(L"Need to patch, gIsPatchVersionNumber=%d, gIsPatchProductType=%d", gIsPatchVersionNumber, gIsPatchProductType);
int count = HookIATProcedure(hWsaClient, "GetProcAddress", reinterpret_cast<FARPROC>(&BadGetProcAddress));
if (count == 0) {
LOGE(L"HookIATProcedure failed, count=%d", count);
return false;
} else {
LOGI(L"HookIATProcedure success, count=%d", count);
}
// auxiliary hooks
// HookIATProcedure(GetModuleHandleW(L"winhttp.dll"), "GetProcAddress", reinterpret_cast<FARPROC>(&BadGetProcAddress));
// HookIATProcedure(GetModuleHandleW(L"icu.dll"), "GetProcAddress", reinterpret_cast<FARPROC>(&BadGetProcAddress));
return true;
}
void OnUnload() {
HANDLE handle = gConsoleOutput;
if (handle != nullptr && handle != INVALID_HANDLE_VALUE) {
CloseHandle(handle);
if (gConsoleIsAllocated) {
FreeConsole();
gConsoleIsAllocated = false;
}
gConsoleOutput = INVALID_HANDLE_VALUE;
}
gSelfInstance = nullptr;
}
}
EXPORT_C void NS_WsaPatch_UnusedSymbol() {
// nothing
}
BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpvReserved) {
// Perform actions based on the reason for calling.
switch (fdwReason) {
case DLL_PROCESS_ATTACH:
return wsapatch::OnLoad(hInstDLL);
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
// no-op
break;
case DLL_PROCESS_DETACH:
if (lpvReserved != nullptr) {
// do not do cleanup if process termination scenario
break;
}
wsapatch::OnUnload();
break;
default:
break;
}
return true;
}
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
//
// Created by Administrator on 2022.11.30.
//
#ifndef WSAPATCH_ERRNORESTORER_H
#define WSAPATCH_ERRNORESTORER_H
#include <windows.h>
class ErrnoRestorer {
public:
ErrnoRestorer() : saved_errno_(GetLastError()) {}
~ErrnoRestorer() {
SetLastError(saved_errno_);
}
// disable copy and assign
ErrnoRestorer(const ErrnoRestorer &) = delete;
ErrnoRestorer &operator=(const ErrnoRestorer &) = delete;
ErrnoRestorer(ErrnoRestorer &&) = delete;
ErrnoRestorer &operator=(ErrnoRestorer &&) = delete;
// Allow this object to be used as part of && operation.
explicit operator bool() const { return true; }
private:
const DWORD saved_errno_;
};
#endif //WSAPATCH_ERRNORESTORER_H
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
cmake_minimum_required(VERSION 3.23)
project(WsaPatch)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_C_STANDARD 11)
add_library(WsaPatch SHARED WsaPatch.cpp Log.cpp TimeUtils.cpp ErrnoRestorer.h)
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
//
// Created by Administrator on 2022.11.30.
//
#include "Log.h"
volatile Log::LogHandler Log::mHandler = nullptr;
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
//
// Created by Administrator on 2022.11.30.
//
#ifndef WSAPATCH_LOG_H
#define WSAPATCH_LOG_H
#include <cstdarg>
#include <cstdio>
#include <cstring>
#include <malloc.h>
#include <strsafe.h>
#ifndef _MAC
typedef wchar_t WCHAR; // wc, 16-bit UNICODE character
#else
// some Macintosh compilers don't define wchar_t in a convenient location, or define it as a char
typedef unsigned short WCHAR; // wc, 16-bit UNICODE character
#endif
#ifdef ERROR
#define MACRO_PUSH_ERROR 1
#pragma push_macro("ERROR")
#undef ERROR
#endif
class Log {
public:
enum class Level {
UNKNOWN = 0,
VERBOSE = 2,
DEBUG = 3,
INFO = 4,
WARN = 5,
ERROR = 6
};
using LogHandler = void (*)(Level level, const WCHAR *tag, const WCHAR *msg);
private:
static volatile LogHandler mHandler;
public:
static void format(Level level, const WCHAR *tag, _Printf_format_string_ const WCHAR *fmt, ...) {
va_list varg1;
LogHandler h = mHandler;
if (h == nullptr || fmt == nullptr) {
return;
}
WCHAR buffer[1024] = {};
va_start(varg1, fmt);
StringCchVPrintfW(buffer, 1024, fmt, varg1);
va_end(varg1);
h(level, tag, buffer);
}
static void logBuffer(Level level, const WCHAR *tag, const WCHAR *msg) {
LogHandler h = mHandler;
if (h == nullptr) {
return;
}
h(level, tag, msg);
}
static inline LogHandler getLogHandler() noexcept {
return mHandler;
}
static inline void setLogHandler(LogHandler h) noexcept {
mHandler = h;
}
static constexpr const WCHAR *levelName(Level level) noexcept {
switch (level) {
case Level::UNKNOWN:
return L"UNKNOWN";
case Level::VERBOSE:
return L"VERBOSE";
case Level::DEBUG:
return L"DEBUG";
case Level::INFO:
return L"INFO";
case Level::WARN:
return L"WARN";
case Level::ERROR:
return L"ERROR";
default:
return L"UNKNOWN";
}
}
};
#define LOGE(...) Log::format(static_cast<Log::Level>(6), LOG_TAG, __VA_ARGS__)
#define LOGW(...) Log::format(Log::Level::WARN, LOG_TAG, __VA_ARGS__)
#define LOGI(...) Log::format(Log::Level::INFO, LOG_TAG, __VA_ARGS__)
#define LOGD(...) Log::format(Log::Level::DEBUG, LOG_TAG, __VA_ARGS__)
#define LOGV(...) Log::format(Log::Level::VERBOSE, LOG_TAG, __VA_ARGS__)
#ifdef MACRO_PUSH_ERROR
#pragma pop_macro("ERROR")
#endif
#endif //WSAPATCH_LOG_H
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
# 适用于 Windows 10 的 WSA 补丁
[English version](./README.md)
这是一个可以让 Windows 10 运行 WSA (Windows Subsystem for Android) 的补丁及其使用方法。
本人测试过 Windows 10 22H2 10.0.19045.2311 x64 + WSA 2210.40000.7.0 以及 10.0.19045.2364 + 2211.40000.10.0.
### 操作步骤
1. 将你的系统更新到 Windows 10 22H2 10.0.19045.2311 或更高版本.
- 你可以通过 `winver` 命令查看您当前的 Windows 版本.
- 如果您的 Windows 版本低于 10.0.19045.2311, 请将您的系统更新到 10.0.19045.2311 或以上.
2. 安装 WSL2 (我用的 Ubuntu 22.04 LTS, 当然你也可以选择你喜欢的发行版,下一步要用到).
3. 按照 https://github.com/LSPosed/MagiskOnWSALocal 的步骤,得到集成了 Magisk 的 WSA AppX 包.
- 注:你需要在你的 WSL2 里进行操作,WSA 版本建议选 Insider Fast/Dev Channel.
4. 把你的 WSA AppX 包从 WSL2 里复制出来, 它应该是一个压缩包, 解压到你希望安装 WSA 的地方.
- 位于 `MagiskOnWSALocal/output`, 文件名类似于 `WSA-with-magisk-stable-MindTheGapps_2210.40000.7.0_x64_Release-Nightly.7z`.
5. 用 Visual Studio 编译本仓库的代码,得到 WsaPatch.dll (用 MSVC 工具链编译,如果你不想自己编译,你可以去 release 里下).
6. 想办法从 Windows 11 22H2 的 System32 里复制一个 icu.dll 过来,找一个 PE32+ 编辑工具给它的导入表加一个 WsaPatch.dll.
- 你必须用 Windows 11 22H2 里的 icu.dll, 因为 Windows 10 的 icu.dll 缺符号;
- 如果你没有 Windows 11 22H2, 本仓库的 original.dll.win11.22h2 就有原版带微软签名的 icu.dll;
- 如果你不想自己搞,你可以用 release 里已经修改过的 icu.dll.
7. 把编译好的 WsaPatch.dll 和修改过的 icu.dll 复制到 WSA 的 WsaClient 文件夹.
8. 按以下要求修改 AppxManifest.xml:
1. 在 `AppxManifest.xml` 找到 `TargetDeviceFamily` 节点
```xml
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.22000.120" MaxVersionTested="10.0.22000.120"/>
```
把 `MinVersion` 从 `10.0.22000.120` 改成 `10.0.19045.2311`.
2. 在 `AppxManifest.xml` 删除 "customInstall" 相关节点,一共有两个.
找到以下内容,然后删掉.
```xml
<rescap:Capability Name="customInstallActions"/>
```
```xml
<desktop6:Extension Category="windows.customInstall">
<desktop6:CustomInstall Folder="CustomInstall" desktop8:RunAsUser="true">
<desktop6:RepairActions>
<desktop6:RepairAction File="WsaSetup.exe" Name="Repair" Arguments="repair"/>
</desktop6:RepairActions>
<desktop6:UninstallActions>
<desktop6:UninstallAction File="WsaSetup.exe" Name="Uninstall" Arguments="uninstall"/>
</desktop6:UninstallActions>
</desktop6:CustomInstall>
</desktop6:Extension>
```
9. 运行 `Run.bat` (需要管理员权限).
编译好的 WsaPatch.dll 和修改过的 icu.dll 可以从 [release 页面](https://github.com/cinit/WSAPatch/releases) 下载.
### 注意事项
1. WSA 只能安装在 NTFS 分区 (请勿安装在 exFAT 分区).
2. 在 `Add-AppxPackage -Register .\AppxManifest.xml` 完成 WSA 的安装后, 你原先解压 WSA 的文件夹不可以删除.
因为 `Add-AppxPackage -Register .\AppxManifest.xml` 的作用是注册 appx 应用包,它只登记注册,不会复制文件.
参考 https://learn.microsoft.com/en-us/powershell/module/appx/add-appxpackage?view=windowsserver2022-ps
3. 在解压 WSA 后第一次启动之前, 你需要注册 WSA appx 包 (上文第 9 步).
对于 [MagiskOnWSALocal](https://github.com/LSPosed/MagiskOnWSALocal) 用户, 你只需要运行解压目录下的 `Run.bat` 即可.
如果报错失败, 你可以进行以下操作进行错误诊断(需要管理员权限).
1. 以管理员身份打开 PowerShell, 切换工作目录到 WSA 的解压目录.
2. 在 PowerShell 中运行 `Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml`.
该命令应该会失败并提供一个这次错误的 ActivityID (是个 UUID).
3. 在 PowerShell 中运行 `Get-AppPackageLog -ActivityID <UUID>` 获取刚才的错误的日志.
4. 根据日志的内容进行修复.
#### 关于 winhttp.dll
- WsaClient.exe 会用 GetProcAddress 从 winhttp.dll 动态获取一些符号.
- 有些符号是只有在 Windows 11 的 winhttp.dll 里才有,Windows 10 的 winhttp.dll 缺少这些符号.
- 如果你在 WsaClient 文件夹建一个名为 `EnableDebugConsole` 的文件(没有扩展名)或者把 [WsaPatch.cpp](WsaPatch.cpp) 里的 `wsapatch::kDebug` 改成 true,
你能看到 GetProcAddress 有些结果是 NULL.
- 如果你找一个 Windows 11 22H2 的 winhttp.dll 放到 WsaClient 文件夹里(或者 WSA 安装目录),WsaClient.exe 就能找到这些符号了.
- 但是不管 WsaClient.exe 能否找得到这些符号,它都能用.
```text
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpRegisterProxyChangeNotification, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpUnregisterProxyChangeNotification, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpGetProxySettingsEx, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpGetProxySettingsResultEx, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpFreeProxySettingsEx, result=NULL
```
### 可能遇到的问题
1. 如果老版本的 WSA 2209.40000.26.0 开了开发者模式也连不上 ADB (端口没有进程监听), 更新到 WSA 2210.40000.7.0 就可以了.
2. 移动 WSA 的设置窗口可以通过按住窗口最小化按钮左边的一小块空白区域然后拖动, 也可以通过按快捷键 Alt+Space 然后点弹出菜单里的 "移动".
[#1](https://github.com/cinit/WSAPatch/issues/1) [#2](https://github.com/cinit/WSAPatch/issues/2)
3. 如果你的 WSA 在启动时闪退且没有任何提示,请将 Windows 10 更新到 22H2 10.0.19045.2311 或更高版本.
(有人反应过 WSA 在 22H2 19045.2251 闪退, 但更新到 22H2 19045.2311 就能用了).
如果你遇到了其他问题或者有什么建议,欢迎在 Issue/PR 中提出.
### 截图

| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
# WSA patch for Windows 10
[中文版本](./README_zhs.md)
This is a patch for WSA to enable WSA (Windows Subsystem for Android) to run on Windows 10.
### Compatibility
Below is a list of versions of WSA and versions of Windows 10 that have been tested together.
| WSA version | Windows version |
|-----------------|------------------------|
| 2210.40000.7.0 | 10.0.19045.2311 (22H2) |
| 2211.40000.10.0 | 10.0.19045.2364 (22H2) |
| 2302.40000.9.0 | 10.0.19044.2728 (21H2) |
In theory, this should work with any version of Windows 10 version 2004 (20H1) and above. This is because every update since then has been very minor, and the build number even still shows as 19041 (20H1's build number) in some places, such as the desktop build number watermark if that is enabled.
### Instructions
1. Make sure your Windows version is at least Windows 10 22H2 10.0.19045.2311.
- You can check your Windows version with command `winver`.
- If your Windows version is lower than 10.0.19045.2311, please update your Windows to at least 10.0.19045.2311.
2. Get WSA appx zip. You can do this by following instructions in https://github.com/LSPosed/MagiskOnWSALocal
(You need to "build" this yourself with your local WSL2).
3. Get "icu.dll" from Windows 11 22H2. Note that you MUST use icu.dll from Windows 11.
The icu.dll from Windows 10 will NOT work.
(I have made a copy of these DLLs in the original.dll.win11.22h2 dir. They are digitally signed by Microsoft.)
4. Build WsaPatch.dll with source code in this repo.
(Build with MSVC toolchain, not MinGW or something else.)
5. Patch icu.dll: add WsaPatch.dll as an import DLL as icu.dll.
6. Copy patched icu.dll and WsaPatch.dll to WsaClient dir.
7. Patch AppxManifest.xml.
1. Find TargetDeviceFamily node in AppxManifest.xml.
```xml
<TargetDeviceFamily Name="Windows.Desktop" MinVersion="10.0.22000.120" MaxVersionTested="10.0.22000.120"/>
```
Change the `MinVersion` from `10.0.22000.120` to `10.0` plus the OS Build number that appears in `winver`. For example, if `winver` shows `Version 21H2 (OS Build 19044.2728)`, you'd change it to `10.0.19044.2728`.
2. Delete all nodes about "customInstall" extension (see below) in AppxManifest.xml.
```xml
<rescap:Capability Name="customInstallActions"/>
```
```xml
<desktop6:Extension Category="windows.customInstall">
<desktop6:CustomInstall Folder="CustomInstall" desktop8:RunAsUser="true">
<desktop6:RepairActions>
<desktop6:RepairAction File="WsaSetup.exe" Name="Repair" Arguments="repair"/>
</desktop6:RepairActions>
<desktop6:UninstallActions>
<desktop6:UninstallAction File="WsaSetup.exe" Name="Uninstall" Arguments="uninstall"/>
</desktop6:UninstallActions>
</desktop6:CustomInstall>
</desktop6:Extension>
```
8. Run "Run.bat" to register your WSA appx.
9. You should be able to run WSA now.
If you don't want to build WsaPatch.dll and patch icu.dll yourself,
you can download the prebuilt binaries from the [release page](https://github.com/cinit/WSAPatch/releases).
### Notice
1. You can only install WSA on a NTFS partition, not on an exFAT partition.
2. You can NOT delete the WSA installation folder.
What `Add-AppxPackage -Register .\AppxManifest.xml` does is to register an appx package with some existing unpackaged files,
so you need to keep them as long as you want to use WSA.
Check https://learn.microsoft.com/en-us/powershell/module/appx/add-appxpackage?view=windowsserver2022-ps for more details.
3. You need to register your WSA appx package before you can run WSA (the 8th step in the instructions).
For [MagiskOnWSALocal](https://github.com/LSPosed/MagiskOnWSALocal) users, you need to run `Run.bat` in the extracted dir.
If the script fails, you can take the following steps for diagnosis (admin privilege required):
1. Open a PowerShell window and change working directory to your WSA directory.
2. Run `Add-AppxPackage -ForceApplicationShutdown -ForceUpdateFromAnyVersion -Register .\AppxManifest.xml` in PowerShell.
This should fail with an ActivityID, which is a UUID required for the next step.
3. Run `Get-AppPackageLog -ActivityID <UUID>` in PowerShell.
This should print the log of the failed operation.
4. Check the log for the reason of failure and fix it.
#### About winhttp.dll
- WsaClient.exe does use GetProcAddress to get some functions from winhttp.dll.
- Some functions exist in winhttp.dll of Windows 11 22H2, but not in Windows 10 22H2.
- If you create a file `EnableDebugConsole` in WsaClient directory or set `wsapatch::kDebug` in [WsaPatch.cpp](WsaPatch.cpp) to true,
you will see the following message from log console.
- If you copy a winhttp.dll from Windows 11 22H2 to WsaClient directory, WsaClient.exe will be able to find these functions.
- WSA will still run even if you don't copy a winhttp.dll with these symbols.
```text
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpRegisterProxyChangeNotification, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpUnregisterProxyChangeNotification, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpGetProxySettingsEx, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpGetProxySettingsResultEx, result=NULL
12-10 16:16:29.474 W WsaPatch: -GetProcAddress: hModule=C:\WINDOWS\SYSTEM32\WINHTTP.dll(00007FFC64780000), lpProcName=WinHttpFreeProxySettingsEx, result=NULL
```
### Problems I met
1. When using WSA 2209.40000.26.0, I was able to run applications in WSA,
but I was not able to connect to WSA ADB after enabling Developer Mode,
since netstat shows that no process is listening on port 58526.
After I upgraded to WSA 2210.40000.7.0, I was able to connect to WSA ADB.
2. The WSA settings window does not hava a draggable title,
but you can move the WSA window if you hold the cursor left near the "minimize" button,
or press Alt+Space, then click "Move" in the context
menu. [#1](https://github.com/cinit/WSAPatch/issues/1) [#2](https://github.com/cinit/WSAPatch/issues/2)
3. If your WSA crashes(or suddenly disappears) when starting up, try to upgrade your Windows to Windows 10 22H2 10.0.19045.2311.
(Someone has reported that WSA failed to start on 22H2 19045.2251, but worked after upgrading to 19045.2311.)
If you encounter any problems or have any suggestions, please open an issue or pull request.
### Screenshot

| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
#ifndef WSAPATCH_WSAPATCH_H
#define WSAPATCH_WSAPATCH_H
#include "macros.h"
EXPORT_C void NS_WsaPatch_UnusedSymbol();
#endif //WSAPATCH_WSAPATCH_H
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
#include <stdint.h>
typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;
typedef size_t usize;
typedef ptrdiff_t isize;
typedef uintptr_t uintptr;
#ifdef __cplusplus
#define EXTERN_C extern "C"
#else
#define EXTERN_C
#endif
#if defined(_MSC_VER)
#define EXPORT __declspec(dllexport)
#elif defined(__GNUC__)
#define EXPORT __attribute__((visibility("default"), used))
#else
#error "Unsupported compiler"
#endif
#define EXPORT_C EXTERN_C EXPORT
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
//
// Created by Administrator on 2022.11.30.
//
#ifndef WSAPATCH_TIMEUTILS_H
#define WSAPATCH_TIMEUTILS_H
#include "macros.h"
u64 currentTimeMillis();
u64 currentTimeSeconds();
void timeMillisToLocalCalendar(u64 timeMillis, int *year, int *month, int *day, int *hour, int *minute, int *second, int *millisecond);
void timeMillisToUTCCalendar(u64 timeMillis, int *year, int *month, int *day, int *hour, int *minute, int *second, int *millisecond);
s32 getLocalTimeBiasSeconds();
#endif //WSAPATCH_TIMEUTILS_H
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
name: Build WsaPatch.dll
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
# Path to the solution file relative to the root of the project.
SOLUTION_FILE_PATH: .
BUILD_CONFIGURATION: Release
permissions:
contents: read
jobs:
build:
runs-on: windows-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Configure
run: |
cmake -G "Visual Studio 17 2022" -A x64 -B build
- name: Build Release
run: cmake --build build --config Release --verbose
- name: Upload WsaPatch.dll
uses: actions/upload-artifact@v3
with:
name: WsaPatch-build
path: .\build
| {
"repo_name": "cinit/WSAPatch",
"stars": "1216",
"repo_language": "C++",
"file_name": "build.yml",
"mime_type": "text/plain"
} |
# Contributing
Please read carefully the guides for contributing to this project. Before you create a Pull Request, search for already created ones so there won't be any duplicate.
Add only courses, books, softwares that you really think is awesome, don't just add any resource that contains words like "Network, Networking, etc.". It would be even better if you have personal experience with that resource, because after all, this is a list of awesome things.
If you are adding some book, software or anything else that is purchasable, **DO NOT** add links that leads to the illegal sites and illegal resources. Provide a link to the either official shop's/author's website, or other official sellers of that content (e.g. Book on Amazon).
## Guidelines
1. Find a link to the resource you consider is awesome.
2. Add it to the proper category at the end of the list (two new).
3. Use format `* [name](http://example.com/) - A short description ends with a period.`
4. If there is no section for your resource but you thing there should be, then add it right before **Miscellaneous** category.
5. Check your spelling and grammar.
6. Send a Pull Request with the proper name and description (**Do not name Pull Request like "Update Readme.md"**).
7. Be patient. It may take a few days for me to review it.
| {
"repo_name": "facyber/awesome-networking",
"stars": "434",
"repo_language": "None",
"file_name": "README.md",
"mime_type": "text/plain"
} |
CC0 1.0 Universal
Statement of Purpose
The laws of most jurisdictions throughout the world automatically confer
exclusive Copyright and Related Rights (defined below) upon the creator and
subsequent owner(s) (each and all, an "owner") of an original work of
authorship and/or a database (each, a "Work").
Certain owners wish to permanently relinquish those rights to a Work for the
purpose of contributing to a commons of creative, cultural and scientific
works ("Commons") that the public can reliably and without fear of later
claims of infringement build upon, modify, incorporate in other works, reuse
and redistribute as freely as possible in any form whatsoever and for any
purposes, including without limitation commercial purposes. These owners may
contribute to the Commons to promote the ideal of a free culture and the
further production of creative, cultural and scientific works, or to gain
reputation or greater distribution for their Work in part through the use and
efforts of others.
For these and/or other purposes and motivations, and without any expectation
of additional consideration or compensation, the person associating CC0 with a
Work (the "Affirmer"), to the extent that he or she is an owner of Copyright
and Related Rights in the Work, voluntarily elects to apply CC0 to the Work
and publicly distribute the Work under its terms, with knowledge of his or her
Copyright and Related Rights in the Work and the meaning and intended legal
effect of CC0 on those rights.
1. Copyright and Related Rights. A Work made available under CC0 may be
protected by copyright and related or neighboring rights ("Copyright and
Related Rights"). Copyright and Related Rights include, but are not limited
to, the following:
i. the right to reproduce, adapt, distribute, perform, display, communicate,
and translate a Work;
ii. moral rights retained by the original author(s) and/or performer(s);
iii. publicity and privacy rights pertaining to a person's image or likeness
depicted in a Work;
iv. rights protecting against unfair competition in regards to a Work,
subject to the limitations in paragraph 4(a), below;
v. rights protecting the extraction, dissemination, use and reuse of data in
a Work;
vi. database rights (such as those arising under Directive 96/9/EC of the
European Parliament and of the Council of 11 March 1996 on the legal
protection of databases, and under any national implementation thereof,
including any amended or successor version of such directive); and
vii. other similar, equivalent or corresponding rights throughout the world
based on applicable law or treaty, and any national implementations thereof.
2. Waiver. To the greatest extent permitted by, but not in contravention of,
applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and
unconditionally waives, abandons, and surrenders all of Affirmer's Copyright
and Related Rights and associated claims and causes of action, whether now
known or unknown (including existing as well as future claims and causes of
action), in the Work (i) in all territories worldwide, (ii) for the maximum
duration provided by applicable law or treaty (including future time
extensions), (iii) in any current or future medium and for any number of
copies, and (iv) for any purpose whatsoever, including without limitation
commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes
the Waiver for the benefit of each member of the public at large and to the
detriment of Affirmer's heirs and successors, fully intending that such Waiver
shall not be subject to revocation, rescission, cancellation, termination, or
any other legal or equitable action to disrupt the quiet enjoyment of the Work
by the public as contemplated by Affirmer's express Statement of Purpose.
3. Public License Fallback. Should any part of the Waiver for any reason be
judged legally invalid or ineffective under applicable law, then the Waiver
shall be preserved to the maximum extent permitted taking into account
Affirmer's express Statement of Purpose. In addition, to the extent the Waiver
is so judged Affirmer hereby grants to each affected person a royalty-free,
non transferable, non sublicensable, non exclusive, irrevocable and
unconditional license to exercise Affirmer's Copyright and Related Rights in
the Work (i) in all territories worldwide, (ii) for the maximum duration
provided by applicable law or treaty (including future time extensions), (iii)
in any current or future medium and for any number of copies, and (iv) for any
purpose whatsoever, including without limitation commercial, advertising or
promotional purposes (the "License"). The License shall be deemed effective as
of the date CC0 was applied by Affirmer to the Work. Should any part of the
License for any reason be judged legally invalid or ineffective under
applicable law, such partial invalidity or ineffectiveness shall not
invalidate the remainder of the License, and in such case Affirmer hereby
affirms that he or she will not (i) exercise any of his or her remaining
Copyright and Related Rights in the Work or (ii) assert any associated claims
and causes of action with respect to the Work, in either case contrary to
Affirmer's express Statement of Purpose.
4. Limitations and Disclaimers.
a. No trademark or patent rights held by Affirmer are waived, abandoned,
surrendered, licensed or otherwise affected by this document.
b. Affirmer offers the Work as-is and makes no representations or warranties
of any kind concerning the Work, express, implied, statutory or otherwise,
including without limitation warranties of title, merchantability, fitness
for a particular purpose, non infringement, or the absence of latent or
other defects, accuracy, or the present or absence of errors, whether or not
discoverable, all to the greatest extent permissible under applicable law.
c. Affirmer disclaims responsibility for clearing rights of other persons
that may apply to the Work or any use thereof, including without limitation
any person's Copyright and Related Rights in the Work. Further, Affirmer
disclaims responsibility for obtaining any necessary consents, permissions
or other rights required for any use of the Work.
d. Affirmer understands and acknowledges that Creative Commons is not a
party to this document and has no duty or obligation with respect to this
CC0 or use of the Work.
For more information, please see
<http://creativecommons.org/publicdomain/zero/1.0/>
| {
"repo_name": "facyber/awesome-networking",
"stars": "434",
"repo_language": "None",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# Awesome Networking [](https://awesome.re)
An awesome collection of courses, books, tutorials, software, and other resources about networking.
## Contents
* [TCP/IP Protocols](#tcpip-protocols)
* [Courses](#courses)
* [Tutorials](#tutorials)
* [Books](#books)
* [Software](#software)
* [Certifications](#certifications)
* [Miscellaneous](#miscellaneous)
* [License](#license)
## TCP/IP Protocols
**Note**: Links without description are official RFCs from the Internet Engineering Task Force (IETF).
* [Address Resolution Protocol (ARP)](https://datatracker.ietf.org/doc/rfc826/)
* [Border Gateway Protocol (BGP)](https://datatracker.ietf.org/doc/rfc4271/)
* [Domain Name System (DNS)](https://datatracker.ietf.org/doc/rfc1035/)
* [Dynamic Host Configuration Protocol (DHCP)](https://datatracker.ietf.org/doc/rfc2131/)
* [File Transfer Protocol (FTP)](https://datatracker.ietf.org/doc/rfc959/)
* [Hypertext Transfer Protocol (HTTP/1.1)](https://datatracker.ietf.org/doc/rfc2616/)
* [Hypertext Transfer Protocol Version 2 (HTTP/2)](https://datatracker.ietf.org/doc/rfc7540/)
* [Internet Protocol Version 4 (IPv4)](https://tools.ietf.org/html/rfc791/)
* [Internet Protocol Version 6 (IPv6)](https://datatracker.ietf.org/doc/rfc2460/)
* [Network Address Translator (NAT)](https://datatracker.ietf.org/doc/rfc1631/)
* [Simple Mail Transfer Protocol (SMTP)](https://datatracker.ietf.org/doc/rfc5321/)
* [Simple Network Management Protocol (SNMP)](https://datatracker.ietf.org/doc/rfc1157/)
* [Secure Shell (SSH)](https://datatracker.ietf.org/doc/rfc4251/)
* [Transmission Control Protocol (TCP)](https://datatracker.ietf.org/doc/rfc793/)
* [Telnet](https://datatracker.ietf.org/doc/rfc854/)
* [User Datagram Protocol (UDP)](https://datatracker.ietf.org/doc/rfc768/)
## Courses
* [Cisco Networking Academy Courses](https://www.netacad.com/courses/networking) - A various networking courses (Essentials, CCNA, CCNP, etc.).
* [CBT Nuggets](https://www.cbtnuggets.com/) - An excellent place to start with the courses on various topics (Cisco, Juniper, CompTIA, etc.).
* [ipSpace](https://www.ipspace.net/) - Contains excellent courses and webinars on various network topics, for both beginners and advanced people.
* [GNS3 Academy](https://academy.gns3.com/) - A various number of courses related to networking with GNS3 software.
* [The Complete Networking Fundamentals Course](https://www.udemy.com/complete-networking-fundamentals-course-ccna-start/) - The most popular Networking Essentials course on Udemy.
## Tutorials
* [Networking](https://www.youtube.com/watch?v=rL8RSFQG8do&list=PLF360ED1082F6F2A5) - A series of YouTube tutorials about networking by Eli the Computer Guy.
* [Wireshark Tutorial for Beginners](https://www.youtube.com/watch?v=flDzURAm8wQ&list=PL6gx4Cwl9DGBI2ZFuyZOl5Q7sptR7PwYN) - TheNewBoston Wireshark Tutorial for Beginners.
* [MikroTik WinBox Manual](https://wiki.mikrotik.com/wiki/Manual:Winbox) - The official manual for MikroTik's WinBox software.
## Books
* [Computer Networking: A Top-Down Approach (7th Edition)](https://www.amazon.com/Computer-Networking-Top-Down-Approach-7th/dp/0133594149) - Excellent book for beginners (and advanced people) in networking.
* [Internetworking with TCP/IP Volume One (6th Edition)](https://www.amazon.com/Internetworking-TCP-IP-One-6th/dp/013608530X) - A rich introduction book to the TCP/IP protocols and Internetworking.
* [Network Security Essentials: Applications and Standards (6th Edition)](https://www.amazon.com/Network-Security-Essentials-Applications-Standards/dp/013452733X/) - A practical survey of network security applications and standards.
* [Beej's Guide to Network Programming](https://beej.us/guide/bgnet/) - A free digital book about socket programming by Brian "Beej" Hall.
* [Red Hat Enterprise Linux 7 Networking Guide](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/pdf/networking_guide/Red_Hat_Enterprise_Linux-7-Networking_Guide-en-US.pdf) - The official Red Hat's networking guide for Red Hat Enterprise Linux.
* [Practical Packet Analysis (3rd Edition)](https://nostarch.com/packetanalysis3) - An amazing book about analyzing network packets using Wireshark.
* [Attacking Network Protocols](https://nostarch.com/networkprotocols) - A Hacker's Guide to Capture, Analysis, and Exploitation
by James Forshaw.
* [Cisco Press](https://www.ciscopress.com/) - Cisco authorized book publisher where you can get all books and official guides for Cisco certifications.
* [Automate Your Network: Introducing the Modern Approach to Enterprise Network Management](https://www.amazon.com/Automate-Your-Network-Introducing-Enterprise/dp/1799237885) - Probably one of the best books for network automation by John W. Capobianco.
* [Acing the CCNA Exam](https://www.manning.com/books/acing-the-ccna-exam) - A comprehensive, detailed guide to passing the Cisco Certified Network Associate (CCNA) exam by Jeremy McDowell.
## Software and Tools
### Online tools
* [Online nslookup](https://www.nslookup.io) - An online DNS client to view and debug DNS configuration.
* [Online whois](https://whois.domaintools.com/) - An online whois record tool for getting information about domains.
* [OUI Lookup Tool](https://www.wireshark.org/tools/oui-lookup.html) - An online OUI lookup for searching vendors of MAC addresses.
* [MXToolbox](https://mxtoolbox.com/) - A large number of various tools (DNS lookup, MX lookup, Whois, SPF lookup, and more).
### Packet capture and analysis
* [Wireshark](https://www.wireshark.org/) - The most popular free and open source network protocol analyzer.
* [Tshark](https://tshark.dev/) - A CLI version of Wireshark.
* [tcpdump](http://www.tcpdump.org/) - A powerful open source command-line packet analyzer.
* [NetworkMiner](https://www.netresec.com/?page=NetworkMiner) - A network forensic tool for PCAP file analysis.
* [Malware-Traffic-Analysis.net](https://malware-traffic-analysis.net/) - A large collection of malicious PCAP files that can be used to practice packet capture skills.
* [Publicly Available PCAP files](https://www.netresec.com/?page=PcapFiles) - A list of publicly available PCAP files for additional training.
### Network simulators and emulators
* [GNS3](https://gns3.com/) - A powerful free and open source network simulator.
* [Cisco Packet Tracer](https://www.netacad.com/courses/packet-tracer) - Cross-platform network visual simulation tool designed by Cisco Systems.
* [EVE-NG](https://www.eve-ng.net/) - A powerful network simulator. Both Community and Professional editions are available.
* [Cisco Modeling Labs](https://www.cisco.com/c/en/us/products/cloud-systems-management/modeling-labs/index.html) - An online platform that helps network engineers simulate the behavior of Cisco routers, switches, and access points. It is intended for customers from enterprise backgrounds.
* [Cisco Virtual Internet Routing Lab (VIRL)](https://learningnetwork.cisco.com/s/virl) - It is a Cisco IOS-based comprehensive network simulation environment. It is intended for all individuals and trainees.
### Firewalls and switches
* [pfSense](https://www.pfsense.org/) - An open source firewall/router computer software distribution based on FreeBSD.
* [OPNsense](https://opnsense.org/) - OPNsense is an open source, easy-to-use, and easy-to-build FreeBSD based firewall and routing platform.
* [Open vSwitch](https://www.openvswitch.org/) - Open vSwitch is a production quality, multilayer virtual switch licensed under the open source Apache 2.0 license.
### Remote access and sharing tools
* [Remmina](https://remmina.org/) - An open source remote access tool. It supports RDP, SSH, VNC, and other protocols for remote access.
* [PuTTY](https://www.putty.org/) - One of the most popular SSH and Telnet clients for Windows.
* [FileZilla](https://filezilla-project.org/) - An open source tool for file transfer. Support FTP, FTPS and SFTP protocols.
* [WinSCP](https://winscp.net/eng/index.php) - A popular SFTP client and FTP client for Windows.
* [SecureCRT](https://www.vandyke.com/products/securecrt/) - A commercial SSH and Telnet client and terminal emulator by VanDyke Software.
* [WinBox](https://mikrotik.com/download) - Official MikroTik GUI software for administration of MikroTik RouterOS.
### Other tools
* [Nmap](https://nmap.org/) - A free and open source software for network discovery and security auditing.
* [Zenmap](https://nmap.org/zenmap/) - The official Nmap Security Scanner GUI.
* [Draw.io](https://github.com/jgraph/drawio-desktop) - An open source software for creating network diagrams and topologies.
## Certifications
* [Cisco certifications](https://www.cisco.com/c/en/us/training-events/training-certifications/certifications.html)
* [MikroTik certified training programs](https://mikrotik.com/training/about)
* [Juniper Certification Tracks](https://www.juniper.net/us/en/training/certification/certification-tracks/)
* [CompTIA Network+](https://certification.comptia.org/certifications/network)
## Miscellaneous
* [Network Analysis](https://github.com/briatte/awesome-network-analysis) - An awesome list of network analysis resources.
* [Software Defined Networks (SDN)](https://github.com/sdnds-tw/awesome-sdn) - An awesome list about Software Defined Network (SDN).
* [Reddit Networking](https://www.reddit.com/r/networking/) - Reddit group for networking.
* [Reddit homelabbity](https://www.reddit.com/r/homelab/wiki/introduction/) - Reddit group for homelabs ideas.
* [Network Engineering Stack Exchange](https://networkengineering.stackexchange.com/) - A question and answer site for network engineers.
* [Server Fault](https://serverfault.com/) - A question and answer site for system and network administrators.
## License
This repository is under the [CC0 1.0 Universal](https://creativecommons.org/publicdomain/zero/1.0/) license.
| {
"repo_name": "facyber/awesome-networking",
"stars": "434",
"repo_language": "None",
"file_name": "README.md",
"mime_type": "text/plain"
} |
# frozen_string_literal: true
# Add your own tasks in files placed in lib/tasks ending in .rake,
# and they will automatically be available to Rake.
require_relative 'config/environment'
Rails.application.load_tasks
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# frozen_string_literal: true
source 'https://rubygems.org'
git_source(:github) do |repo_name|
repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?('/')
"https://github.com/#{repo_name}.git"
end
gem 'rails', '~> 6.1.0'
gem 'rake', '~> 13.0.6'
gem 'grape', '~> 1.7.0'
gem 'jbuilder', '~> 2.11.5'
gem 'elasticsearch-api', '~> 6.0'
gem 'elasticsearch-model', '~> 5.0'
gem 'elasticsearch-persistence', '~> 5.0', require: 'elasticsearch/persistence/model'
gem 'elasticsearch-transport', '~> 6.0'
gem 'flickraw', '~> 0.9.8'
gem 'hashie', '~> 3.5.7'
gem 'mock_redis', '~> 0.17.3'
gem 'redis-namespace', '~> 1.10.0' # use redis database index instead?
gem 'sidekiq', '~> 7.1.2'
gem 'sidekiq-failures', '~> 1.0.0'
gem 'sidekiq-unique-jobs', '3.0.11' # sidekiq-unique-jobs > 3.0.11 broke spec
gem 'whenever', '~> 0.9.4', require: false
gem 'newrelic_rpm', '~> 8.16'
gem 'feedjira', '~> 2.2.0'
group :development, :test do
gem 'puma', '~> 5.3'
gem 'binding_of_caller'
gem 'pry-rails'
gem 'rspec-rails', '~> 3.8.2'
gem 'debug'
end
group :development do
gem 'listen', '~> 3.8.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
# Bumping searchgov_style? Be sure to update rubocop, if possible,
# and set the Rubocop channel in .codeclimate.yml to match the updated rubocop version.
gem 'searchgov_style', '~> 0.1', require: false
gem 'rubocop', '1.48.1', require: false
end
group :test do
gem 'rspec-sidekiq', '~> 3.0.1'
gem 'rspec_junit_formatter', '~> 0.4.1'
gem 'simplecov', '~> 0.16.1'
gem 'webmock', '~> 3.18'
end
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
# frozen_string_literal: true
# This file is used by Rack-based servers to start the application.
require_relative 'config/environment'
run Rails.application
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
FROM ruby:3.0.6
WORKDIR /usr/src/app
EXPOSE 3300
ENV OPENSSL_CONF /etc/ssl/
RUN apt install -y curl \
&& gem install bundler:2.4.7
COPY Gemfile* /usr/src/app/
ENV BUNDLE_PATH /gems
RUN bundle install
COPY . /usr/src/app/
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
ASIS Server
==============
[](https://circleci.com/gh/GSA/asis)
[](https://codeclimate.com/github/GSA/asis)
[](https://codeclimate.com/github/GSA/asis)
ASIS (Advanced Social Image Search) indexes Flickr and MRSS images and provides a search API across both indexes.
## Current version
You are reading documentation for ASIS API v1.
## Contribute to the code
The server code that runs the image search component of [Search.gov](https://search.gov/) is here on Github.
[Fork this repo](https://github.com/GSA/oasis/fork) to add features like additional datasets, or to fix bugs.
## Dependencies
### Ruby
Use [rvm](https://rvm.io/) to install the version of Ruby specified in `.ruby-version`.
### Configuration
1. Copy `config/flickr.yml.example` to `config/flickr.yml` and update the fields with your Flickr credentials.
### Docker
Docker can be used to: 1) run just the required services (MySQL, Elasticsearch, etc.) while [running the asis application in your local machine](https://github.com/GSA/asis#developmentusage), and/or 2) run the entire `asis` application in a Docker container. Please refer to [searchgov-services](https://github.com/GSA/search-services) for detailed instructions on centralized configuration for the services.
When running in a Docker container (option 2 above), the `asis` application is configured to run on port [3300](http://localhost:3300/). Required dependencies - ([Ruby](https://github.com/GSA/asis#ruby), and [Gems](https://github.com/GSA/asis#ruby)) - are installed using Docker. However, other data or configuration may need to be setup manually, which can be done in the running container using `bash`.
Any operations (using rails console, running rake commands, etc.) on ASIS application running in Docker container can be performed by executing below command in `search-services`.
$ docker compose run asis bash
For example, to setup DB in Docker:
$ docker compose run asis bash
$ bin/rails oasis:seed_profiles
The Elasticsearch service provided by `searchgov-services` is configured to run on the default port, [9200](http://localhost:9200/). To use a different host (with or without port) or set of hosts, set the `ES_HOSTS` environment variable. For example, use following command to run the specs using Elasticsearch running on `localhost:9207`:
ES_HOSTS=localhost:9207 bundle exec rspec spec
### Gems
We use bundler to manage gems. You can install bundler and other required gems like this:
gem install bundler
bundle install
## Development/Usage
### Seed some image data
You can bootstrap the system with some government Flickr profiles and MRSS feeds to see the system working.
Sample lists are in config/flickr_profiles.csv` and `config/mrss_profiles.csv`.
bundle exec rake oasis:seed_profiles
You can keep the indexes up to date by periodically refreshing the last day's images. To do this manually via the Rails console:
MrssPhotosImporter.refresh
FlickrPhotosImporter.refresh
### Running it
Fire up a server and try it all out.
bundle exec rails s
Here are the profiles you have just bootstrapped. Note: Chrome does a nice job of pretty-printing the JSON response.
<http://localhost:3000/api/v1/flickr_profiles.json>
<http://localhost:3000/api/v1/mrss_profiles.json>
You can add a new profile manually via the REST API:
curl -XPOST "http://localhost:3000/api/v1/flickr_profiles.json?name=commercegov&id=61913304@N07&profile_type=user"
curl -XPOST "http://localhost:3000/api/v1/mrss_profiles.json?url=https://share-ng.sandia.gov/news/resources/news_releases/feed/"
MRSS profiles work a little differently than Flickr profiles. When you create the MRSS profile, Oasis assigns a
short name to it that you will use when performing searches. The JSON result from the POST request will look something like this:
{
"created_at": "2014-10-26T18:25:21.167+00:00",
"updated_at": "2014-10-26T18:25:21.173+00:00",
"name": "72",
"id": "https://share-ng.sandia.gov/news/resources/news_releases/feed/"
}
### Asynchronous job processing
We use [Sidekiq](http://sidekiq.org) for job processing. You can see all your jobs queued up here:
<http://localhost:3000/sidekiq>
Kick off the indexing process:
bundle exec sidekiq
### Searching
In the Rails console, you can query each index manually using the Elasticsearch [Query DSL](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl.html):
bin/rails c
FlickrPhoto.count
MrssPhoto.count
FlickrPhoto.all(query:{term:{owner:'28634332@N05'}}).results
MrssPhoto.all(query:{match:{description:'air'}}).results
### Parameters
These parameters are accepted for the blended search API:
1. query
2. flickr_groups (comma separated)
2. flickr_users (comma separated)
2. mrss_names (comma separated list of Oasis-assigned names)
4. size
5. from
### Results
The top level JSON contains these fields:
* `total`
* `offset`
* `suggestion`: The overridden spelling suggestion
* `results`
Each result contains these fields:
* `type`: FlickrPhoto
* `title`
* `url`
* `thumbnail_url`
* `taken_at`
### API versioning
We support API versioning with the JSON format. The current version is v1. You can specify a specific JSON API version like this:
curl "http://localhost:3000/api/v1/image.json?flickr_groups=1058319@N21&flickr_users=35067687@n04,24662369@n07&mrss_names=72,73&query=earth"
## Tests
These require an [Elasticsearch](http://www.elasticsearch.org/) server and [Redis](http://redis.io) server to be running.
bundle exec rspec
### Code coverage
We track test coverage of the codebase over time, to help identify areas where we could write better tests and to see when poorly tested code got introduced.
After running your tests, view the report by opening `coverage/index.html`.
Click around on the files that have < 100% coverage to see what lines weren't exercised.
### Code Quality
We use [Rubocop](https://rubocop.org/) for static code analysis. Settings specific to ASIS are configured via [.rubocop.yml](.rubocop.yml). Settings that can be shared among all Search.gov repos should be configured via the [searchgov_style](https://github.com/GSA/searchgov_style) gem.
## Code samples
We "eat our own dog food" and use this ASIS API to display image results on the government websites that use [Search.gov](https://search.gov/).
See the results for a search for [*bird* on FWS.gov](https://search.usa.gov/search/images?affiliate=fws.gov&query=bird).
Feedback
--------
You can send feedback via [Github Issues](https://github.com/GSA/oasis/issues).
-----
[Loren Siebert](https://github.com/loren) and [contributors](http://github.com/GSA/oasis/contributors).
| {
"repo_name": "GSA/asis",
"stars": "30",
"repo_language": "Ruby",
"file_name": "500.html",
"mime_type": "text/html"
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.