microsoft / windows-classic-samples Goto Github PK
View Code? Open in Web Editor NEWThis repo contains samples that demonstrate the API used in Windows classic desktop applications.
License: Other
This repo contains samples that demonstrate the API used in Windows classic desktop applications.
License: Other
The presentation page instructs us to run the following command in PowerShell to enable the ProjFS feature:
Enable-WindowsOptionalFeature -Online -FeatureName ProjFS-Client -NoRestart
But this feature name is not correct in windwos 10, as the command returns the error:
Enable-WindowsOptionalFeature : ProjFS-Client : feature name unknown.
The ProjFS support is installable using the "Control Panel>Programs & features>Add/remove Windows features". Note: It is still not proposed in the Settings Panel (which only focuses on basic features for standard users, such as language and fonts support, but not system components for virtualization, like ProjFS, Containers or Hyper-V).
Can you fix the doc with the correct Feature name to use in PowerShell ? Or if this feature requires adding another dependant component (to add it to the local repository of features that can then be enabled) give hints about which powershell command can make this check (notably does it require installing another package name?)
Note: adding the -All
parameter to the command does not work, we still get an unknown feature name error.
I'm running Windows 10 Pro.
Note: using Get-WindowsOptionalFeature -Online
in PowerShell (from an administrator account) to list all the provisioned features (enabled or disable) I noted that the feature is actually named Client-ProjFS
, not ProjFS-Client
.
So I suggest you add a link to Microsoft's documentation for Get-WindowsOptionalFeature
and for Enable-WindowsOptionalFeature
.
Note that the doc is also no longer maintained (according to the top banner). It's very likely that the installation of optional features is under pending changes (due to the different integration with the legacy control panel, where all features provisioned by Windows 10 are listed, but not all in the Settings panel, which is provisioned by Windows Update and other software management and inventory systems; it's very likely that there are now other filters, for other sources, and probably new naming conventions). Still today, the feature name must be fixed, because this is still the one by which it is known (and there's still no evident way to find/enumerate the available optional packages/features, not event a web service (similar to those for Debian/APT packages for Linux where you can also add/remove providers and define possible mirrors/proxies or additional provider signatures for approved components, somrtyhing that is also needed in Windows for corporate environement with their own WSUS repository and cache with approved versions and dependencies).
From Windows-classic-samples/Samples/MediaFoundationTransformDecoder, i'm very glad to see you use separate .cpp files for interfaces implementation (HWMFT_IMFMediaEventGenerator_Impl.cpp/CHWMFT_IMFShutdown_Impl.cpp/CHWMFT_IMFTransform_Impl.cpp/etc...).
I submitted the MFNode project to Github (https://github.com/mofo7777/MFNode) from SourceForge, and i use this coding type for a long time. I do not know if I am one of the first developers to use this technique, but this coding type is really interesting for beginners and maintenance.
this issue is just to say i'm happy.
It uses %s for wild character strings.
It should use %ws instead %s for wild character strings.
Creators Update introduced new api such as IsButtonPressed and SimpleHapticsController for the Surface Dial.
I would like to know how to use these via WRL.
Are there any special considerations when trying to use this project as a DLL rather than a console application? I tried to move the code to a DLL, make wrapper functions to return a pointer to an instance of SimpleConsole, and then use wrapper functions to call ExecuteCommand on that instance. I have not yet been able to get it working from either Golang with the Syscall package, or from another C++ console application using LoadLibrary and GetProcAddress. If this is not doable in theory, can someone please tell me why? Thanks to anyone who can help.
When calling the AmsiStream sample with a large file, it fails with HRESULT 0x80070057 (E_INVALIDARG). Experimentation shows that files up to 16 MB (CONTENT_SIZE
of 16777216) are supported, but larger files lead to this error.
Is this a bug in the sample implementation or a limitation of the AMSI interface/its Windows Defender implementation? After all, the CONTENT_SIZE
attribute is documented to be a 64 bit value?
An interesting observation: IAmsiStream::Read
is always called with a buffer that's exactly as large as CONTENT_SIZE
, which isn't exactly the kind of streaming I thought it would do.
with VolumeShadowCopyServiceWriter run as an administrator an exception is thrown after attempting to list the vss writers using vssadmin list writers. vssadmin completes the request but does not list the entry for the sample.
KernelBase.dll!_RaiseException@16() Unknown Symbols loaded.
msvcrt.dll!__CxxThrowException@8() Unknown Symbols loaded.
vssapi.dll!CVssFunctionTracer::Throw(struct CVssDebugInfo,long,unsigned short * const,...) Unknown Symbols loaded.
vssapi.dll!CVssWriterImpl::GetCallback(struct IDispatch *,struct IVssWriterCallback * *,bool,unsigned short *) Unknown Symbols loaded.
vssapi.dll!CVssWriterImpl::RequestWriterInfoInternal(unsigned short *,int,int,struct IDispatch *) Unknown Symbols loaded.
vssapi.dll!CVssWriterImpl::RequestWriterInfo(unsigned short *,int,int,struct IDispatch *) Unknown Symbols loaded.
rpcrt4.dll!_Invoke@12() Unknown Symbols loaded.
rpcrt4.dll!NdrStubCall2() Unknown Symbols loaded.
combase.dll!CStdStubBuffer_Invoke(IRpcStubBuffer * This, tagRPCOLEMESSAGE * prpcmsg, IRpcChannelBuffer * pRpcChannelBuffer) Line 1530 C++ Symbols loaded.
oleaut32.dll!CUnivStubWrapper::Invoke(struct tagRPCOLEMESSAGE *,struct IRpcChannelBuffer *) Unknown Symbols loaded.
[Inline Frame] combase.dll!InvokeStubWithExceptionPolicyAndTracing::__l6::<lambda_1ba7c1521bf8e7d0ebd8f0b3c0295667>::operator()() Line 1824 C++ Symbols loaded.
combase.dll!ObjectMethodExceptionHandlingAction<<lambda_1ba7c1521bf8e7d0ebd8f0b3c0295667> >(InvokeStubWithExceptionPolicyAndTracing::__l6::<lambda_1ba7c1521bf8e7d0ebd8f0b3c0295667> action, ObjectMethodExceptionHandlingInfo * pExceptionHandlingInfo, ExceptionHandlingResult * pExceptionHandlingResult, void *) Line 91 C++ Symbols loaded.
[Inline Frame] combase.dll!InvokeStubWithExceptionPolicyAndTracing(IRpcStubBuffer * pMsg, tagRPCOLEMESSAGE *) Line 1822 C++ Symbols loaded.
combase.dll!DefaultStubInvoke(bool bIsAsyncBeginMethod, IServerCall * pServerCall, IRpcChannelBuffer * pChannel, IRpcStubBuffer * pStub, unsigned long * pdwFault) Line 1891 C++ Symbols loaded.
[Inline Frame] combase.dll!SyncStubCall::Invoke(IServerCall *) Line 1948 C++ Symbols loaded.
[Inline Frame] combase.dll!SyncServerCall::StubInvoke(IRpcChannelBuffer *) Line 779 C++ Symbols loaded.
[Inline Frame] combase.dll!StubInvoke(tagRPCOLEMESSAGE * pMsg, CStdIdentity * pStdID, IRpcStubBuffer *) Line 2173 C++ Symbols loaded.
combase.dll!ServerCall::ContextInvoke(tagRPCOLEMESSAGE * pMessage, IRpcStubBuffer * pStub, CServerChannel * pChannel, tagIPIDEntry * pIPIDEntry, unsigned long * pdwFault) Line 1541 C++ Symbols loaded.
[Inline Frame] combase.dll!CServerChannel::ContextInvoke(tagRPCOLEMESSAGE *) Line 1437 C++ Symbols loaded.
[Inline Frame] combase.dll!DefaultInvokeInApartment(tagRPCOLEMESSAGE *) Line 3532 C++ Symbols loaded.
combase.dll!AppInvoke(ServerCall * pServerCall, CServerChannel * pChannel, IRpcStubBuffer * pStub, void * pv, void * pStubBuffer, tagIPIDEntry * pIPIDEntry, WireLocalThis * pLocalb) Line 1616 C++ Symbols loaded.
combase.dll!ComInvokeWithLockAndIPID(ServerCall * pServerCall, tagIPIDEntry * pIPIDEntry, bool * pbCallerResponsibleForRequestMessageCleanup) Line 2722 C++ Symbols loaded.
combase.dll!ThreadInvoke(_RPC_MESSAGE * pMessage) Line 7096 C++ Symbols loaded.
rpcrt4.dll!DispatchToStubInCNoAvrf() Unknown Symbols loaded.
rpcrt4.dll!RPC_INTERFACE::DispatchToStubWorker() Unknown Symbols loaded.
rpcrt4.dll!RPC_INTERFACE::DispatchToStubWithObject() Unknown Symbols loaded.
rpcrt4.dll!LRPC_SCALL::DispatchRequest() Unknown Symbols loaded.
rpcrt4.dll!LRPC_SCALL::HandleRequest() Unknown Symbols loaded.
rpcrt4.dll!LRPC_ADDRESS::HandleRequest() Unknown Symbols loaded.
rpcrt4.dll!LRPC_ADDRESS::ProcessIO() Unknown Symbols loaded.
rpcrt4.dll!LrpcIoComplete() Unknown Symbols loaded.
ntdll.dll!TppAlpcpExecuteCallback() Unknown Symbols loaded.
ntdll.dll!TppWorkerThread() Unknown Symbols loaded.
kernel32.dll!@BaseThreadInitThunk@12() Unknown Symbols loaded.
ntdll.dll!__RtlUserThreadStart() Unknown Symbols loaded.
ntdll.dll!__RtlUserThreadStart@8() Unknown Symbols loaded.
Here is the event log entry that is created
Volume Shadow Copy Service error: Unexpected error querying for the IVssWriterCallback interface. hr = 0x80040154, Class not registered
. This is often caused by incorrect security settings in either the writer or requestor process.
Operation:
Gathering Writer Data
Context:
Writer Class Id: {079462f1-1079-48dd-b3fb-ccb2f2934ecf}
Writer Name: MSDNSampleWriter
Writer Instance ID: {5ab9187e-7a13-4630-a696-8a11d35c4049}
I've tried this on a machine with Windows 10 CU and one with FCU but haven't seen any differences.
Hi,
when the fingers move while zooming, they either move towards each other(zoom out) or move apart from each other(zoom in). In case of ANY movement other than these the zoom gesture should end. https://github.com/Microsoft/Windowsclassicsamples/blob/master/Samples/Win7Samples/Touch/MTGestures/cpp/GestureEngine.cpp
Though this sample re-calculates the center of the zoom every time until it receives GF_END message. So, where does the center is exactly located? , shouldn't it be exactly in between the 2 fingers in action ? but then why do we expect it to change in the phase between GF_BEGIN and GF_END ?
Kindly help, TIA.
error c2065; 'CLSID_PortableDeviceFTM' : undeclared identifier DeviceEnumeration.cpp 399
How to fix it?
can't run sln cpp or console
only can run wpf sln
Develop Environment
Visual studio 2017
Windows 10
Hi,
I am struggling with this code, it will be really helpful if you can help me.
I have created a vm on win 2016 server using Hyper Visor and taken a snapshot of my vm using Hyper Visor.
I then run your code by adding the command line arguments as ""ImportSnapshots" "test1" "C:\bktest1\test1\Snapshots""
But when I debug I get the error as "No Msvm_PlannedComputerSystem could be found with name "test1"",
I tried importing the vm but that too fails.
On further debugging into the code I figured out the output of this query is null.
""SELECT * FROM Msvm_PlannedComputerSystem WHERE ElementName="test1"""
I tried changing the query to "SELECT * FROM Msvm_PlannedComputerSystem", but the output of this
query is also null.
Command Line also gives the same error 👍
C:\Samples\PVM\bin\Debug>PVMSamples.exe "ImportSnapshots" "test1" "E:\bktest1\test1\Snapshots"
Unhandled Exception: System.Management.ManagementException: No Msvm_PlannedComputerSystem could be found with name "test1"
at Microsoft.Samples.HyperV.Common.WmiUtilities.GetVmObject(String name, String className, ManagementScope scope) in c:\Samples\PVM\WmiUtilities.cs:line 286
at Microsoft.Samples.HyperV.Common.WmiUtilities.GetPlannedVirtualMachine(String name, ManagementScope scope) in c:\Samples\PVM\WmiUtilities.cs:line 249
at Microsoft.Samples.HyperV.PVM.ImportUtilities.ImportSnasphotDefinitions(String pvmName, String snapshotFolderPath) in c:\Samples\PVM\ImportUtilities.cs:line 117
at Microsoft.Samples.HyperV.PVM.Program.Main(String[] args) in c:\Samples\PVM\Program.cs:line 78
Will it be possible for you to suggest where I am wrong, thanks a lot for your help and support.
In the MFCaptureD3D Sample (in Win7Samples/multimedia/mediafoundation/
), it demonstrates how to preview video from a capture device. It works well, but I wonder if I could create the new demonstration which including some features about some common image processing methods, such as gamma correction, histogram equalization, thresholding, etc? Moreover, is there better to keep code independently (avoid to rely on third party library) in implementation?
Windows SDK file \um\mftransform.h defines both
MF_SA_REQUIRED_SAMPLE_COUNT // {18802c61-324b-4952-abd0-176ff5c696ff}
MF_SA_REQUIRED_SAMPLE_COUNT_PROGRESSIVE // {b172d58e-fa77-4e48-8d2a-1df2d850eac2}
Shouldn't the following code in StreamSink.cpp reflect these?
// Update the required sample count based on the media type (progressive vs. interlaced)
if (m_unInterlaceMode == MFVideoInterlace_Progressive)
{
// XVP will hold on to 1 sample but that's the same sample we will internally hold on to
hr = SetUINT32(MF_SA_REQUIRED_SAMPLE_COUNT, SAMPLE_QUEUE_HIWATER_THRESHOLD);
}
else
{
// Assume we will need a maximum of 3 backward reference frames for deinterlacing
// However, one of the frames is "shared" with SVR
hr = SetUINT32(MF_SA_REQUIRED_SAMPLE_COUNT, SAMPLE_QUEUE_HIWATER_THRESHOLD + MAX_PAST_FRAMES - 1);
}
Instead of this, it seems like this code should do either one of the following:
I'm not sure which of these options is best, since documentation on those attributes is quite thin.
I've been looking into the official sample on the Antimalware Scan Interface (AMSI) but I am having some difficulties with understanding something.
The sample I have been following: https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/AmsiProvider
A blog post by Microsoft which talks about using AMSI against malicious software (https://cloudblogs.microsoft.com/microsoftsecure/2017/12/04/windows-defender-atp-machine-learning-and-amsi-unearthing-script-based-attacks-that-live-off-the-land/) talks about using AMSI to capture deobfuscated JavaScript being executed by the script interpreter.
I've gone through the official documentation on MSDN but the information being provided is extremely bland in the sense that there is a very little documentation. The only other thing I could find which was of use aside from the documentation and the official sample demonstration was an article published by Cylance earlier this year (which mentions how to enable support for capturing VBA through AMSI): https://threatvector.cylance.com/en_us/home/how-to-implement-anti-malware-scanning-interface-provider.html
I've seen many external-source blog posts referencing to scanning of VBScript through AMSI - theoretically -, but the official sample only appears to capture PowerShell execution.
Question: is there a way to capture VBScript/JavaScript or anything else aside from PowerShell and VBA? If so, are there any resources to assist in understanding how one should do this?
It's definitely a possibility that I am doing something wrong - or have missed an obvious elephant in the room - and that the official sample is already capable of capturing VBScript and JavaScript. It'd be definitely helpful to get some assurance if this is the case.
Have a nice day!
Hi team,
I am trying to detect the InputSource from touchpad following https://msdn.microsoft.com/en-US/library/windows/desktop/hh448795 and the IdentifyInputSource sample. Here is my repo https://github.com/chaopeng/IdentifyInputSource. I did change 2 place:
I run it with surfacebook, win10 and vs2017. But when I move pointer with touchpad, the InputSource shows mouse. Am I missing something else? Also can team update the sample please?
Thank you.
Chao
To introduce a little the problem we're having, I'll begin explaining our infrastructure.
Actually, we've got a client that has 4 Hyper-V host(s) using Failover Cluster feature, with Windows 2016.
Microsoft says in releases notes that shared disk replication is only available througth the WMI class Msvm_ReplicationCollectionService, so said, we found this sample and started working on it, .
-- Msvm_CollectionReplicationService Class
https://msdn.microsoft.com/en-us/library/mt167787(v=vs.85).aspx
We've implemented the class following the old model of this same class.
Old namespace: "root/virtualization/v2" (this works well, but no shared disk replication)
New namespace: "root/HyperVCluster/v2" (fails)
As first step we try to create a relationship between the two virtual machines sharing the disk, using previous created collection (ReplicaTestGroup), then we try to call "CreateReplicationRelationship" method of the class.
Issued command: PS C:\REPLICA\1\1> .\ReplicaSamples.exe CreateReplicationRelationship REPLICA1 REPLICA2 7ccff3fe-da17-436a-8f38-8a34833b31e6 hypervdrhost.mydom.local
Method fails with: "The method call failed.", without more details.
Does anyone has any idea of what's going on? Is there any way of debugging WMI so I can see what's wrong?
ERROR:
Unhandled Exception: System.Management.ManagementException: The method call failed. at Microsoft.Samples.HyperV.Common.WmiUtilities.ValidateOutput(ManagementBaseObject outputParameters, ManagementScope scope, Boolean throwIfFailed, Boolean printErrors) in C:\Users\isarria\Documents\Replica\cs\WmiUtilities.cs:line 136 at Microsoft.Samples.HyperV.Common.WmiUtilities.ValidateOutput(ManagementBaseObject outputParameters, ManagementScope scope) in C:\Users\isarria\Documents\Replica\cs\WmiUtilities.cs:line 59 at Microsoft.Samples.HyperV.Replica.ManageReplication.CreateReplicationRelationship(String name, String name2, String CollectionID, String recoveryServerName) in C:\Users\isarria\Documents\Replica\cs\ManageReplication.cs:line 85 at Microsoft.Samples.HyperV.Replica.Program.Main(String[] args) in C:\Users\isarria\Documents\Replica\cs\Program.cs:line 107
USED CODE:
/// <summary>
/// Enables replication for a collection of virtual machines to a specified DRserver using
/// integrated authentication.
/// </summary>
/// <param name="name">Name of VM 1</param>
/// <param name="name2">Name of VM 2</param>
/// <param name="CollectionID">CollectionID to enable replication.</param>
/// <param name="recoveryServerName">The name of the recovery server.</param>
internal static void
CreateReplicationRelationship(
string name,
string name2,
string CollectionID,
string recoveryServerName)
{
ManagementScope scope = new ManagementScope(@"root\HyperVCluster\v2");
ManagementScope oldScope = new ManagementScope(@"root\virtualization\v2");
//
// Retrieve the Msvm_VirtualSystemCollection.
//
using (ManagementObject vm = WmiUtilities.GetVirtualMachine(name, oldScope))
{
using (ManagementObject vm2 = WmiUtilities.GetVirtualMachine(name2, oldScope))
{
string vmPath = vm.Path.Path;
string vmPath2 = vm2.Path.Path;
using (ManagementObject collection = WmiUtilities.GetVMGroup(CollectionID, scope))
{
using (ManagementObject replicationSettingData =
ReplicaUtilities.GetReplicationSettings(vm))
{
replicationSettingData["RecoveryConnectionPoint"] = recoveryServerName;
replicationSettingData["AuthenticationType"] = 1;
replicationSettingData["RecoveryServerPortNumber"] = 80;
replicationSettingData["CompressionEnabled"] = 1;
// Keep 24 recovery points.
replicationSettingData["RecoveryHistory"] = 24;
// Replicate changes after every 300 seconds.
replicationSettingData["ReplicationInterval"] = 300;
// Take VSS snapshot every one hour.
replicationSettingData["ApplicationConsistentSnapshotInterval"] = 1;
// Include all disks for replication.
replicationSettingData["IncludedDisks"] = WmiUtilities.GetVhdSettings(vm);
//replicationSettingData["IncludedDisks"] = WmiUtilities.GetVhdSettings(vm2);
Console.WriteLine(replicationSettingData["IncludedDisks"].ToString());
string settingDataEmbedded =
replicationSettingData.GetText(TextFormat.WmiDtd20);
using (ManagementObject replicationService =
ReplicaUtilities.GetVirtualMachineReplicationService(scope))
{
using (ManagementBaseObject inParams =
replicationService.GetMethodParameters("CreateReplicationRelationship"))
{
inParams["Collection"] = collection;
inParams["CollectionReplicationSettingData"] = settingDataEmbedded;
using (ManagementBaseObject outParams =
replicationService.InvokeMethod("CreateReplicationRelationship",
inParams,
null))
{
WmiUtilities.ValidateOutput(outParams, scope);
}
}
}
Console.WriteLine(string.Format(CultureInfo.CurrentCulture,
"Replication is successfully enabled for vmGroup: \"{0}\"", CollectionID));
}
}
}
}
}
/// <summary>
/// Gets the Msvm_VirtualSystemCollection instance that matches the requested VMGroup name.
/// </summary>
/// <param name="CollectionID">The CollectionID to retrieve the path for.</param>
/// <param name="scope">The ManagementScope to use to connect to WMI.</param>
/// <returns>The Msvm_VirtualSystemCollection instance.</returns>
public static ManagementObject
GetVMGroup(
string CollectionID,
ManagementScope scope)
{
return GetCollectionObject(CollectionID, "Msvm_VirtualSystemCollection", scope);
}
/// <summary>
/// Gets the Msvm_ComputerSystem instance that matches the requested virtual machine name.
/// </summary>
/// <param name="name">The name of the virtual machine to retrieve the path for.</param>
/// <param name="scope">The ManagementScope to use to connect to WMI.</param>
/// <returns>The Msvm_ComputerSystem instance.</returns>
public static ManagementObject
GetVirtualMachine(
string name,
ManagementScope scope)
{
return GetVmObject(name, "Msvm_ComputerSystem", scope);
}
/// <summary>
/// Gets the first virtual machine object of the given class with the given name.
/// </summary>
/// <param name="name">The name of the virtual machine to retrieve the path for.</param>
/// <param name="className">The class of virtual machine to search for.</param>
/// <param name="scope">The ManagementScope to use to connect to WMI.</param>
/// <returns>The instance representing the virtual machine.</returns>
private static ManagementObject
GetVmObject(
string name,
string className,
ManagementScope scope)
{
string vmQueryWql = string.Format(CultureInfo.InvariantCulture,
"SELECT * FROM {0} WHERE ElementName=\"{1}\"", className, name);
SelectQuery vmQuery = new SelectQuery(vmQueryWql);
using (ManagementObjectSearcher vmSearcher = new ManagementObjectSearcher(scope, vmQuery))
using (ManagementObjectCollection vmCollection = vmSearcher.Get())
{
if (vmCollection.Count == 0)
{
throw new ManagementException(string.Format(CultureInfo.CurrentCulture,
"No {0} could be found with name \"{1}\"",
className,
name));
}
//
// If multiple virtual machines exist with the requested name, return the first
// one.
//
ManagementObject vm = GetFirstObjectFromCollection(vmCollection);
return vm;
}
}
/// <summary>
/// Gets the replication settings object for a collection.
/// </summary>
/// <param name="systemCollection">The Msvm_VirtualSystemCollection mache object.</param>
/// <returns>The replication settings object.</returns>
internal static ManagementObject
GetReplicationSettings(
ManagementObject systemCollection)
{
using (ManagementObjectCollection settingsCollection =
systemCollection.GetRelated("Msvm_ReplicationSettingData"))
{
ManagementObject replicationSettings =
WmiUtilities.GetFirstObjectFromCollection(settingsCollection);
return replicationSettings;
}
}
/// <summary>
/// Gets the first virtual machine object of the given class with the given name.
/// </summary>
/// <param CollectionID="CollectionID">The name of the virtual machine to retrieve the path for.</param>
/// <param name="className">The class of virtual machine to search for.</param>
/// <param name="scope">The ManagementScope to use to connect to WMI.</param>
/// <returns>The instance representing the virtual machine.</returns>
private static ManagementObject
GetCollectionObject(
string CollectionID,
string className,
ManagementScope scope)
{
string vmQueryWql = string.Format(CultureInfo.InvariantCulture,
"SELECT * FROM {0} WHERE CollectionID=\"{1}\"", className, CollectionID);
SelectQuery vmQuery = new SelectQuery(vmQueryWql);
using (ManagementObjectSearcher vmSearcher = new ManagementObjectSearcher(scope, vmQuery))
using (ManagementObjectCollection vmCollection = vmSearcher.Get())
{
ManagementObject CollectionObject = null;
if (vmCollection.Count == 1)
{
foreach (ManagementObject managementObject in vmCollection)
{
CollectionObject = managementObject;
}
}
else
{
throw new ManagementException(string.Format(CultureInfo.CurrentCulture,
"No {0} could be found with ID \"{1}\"",
className,
CollectionID));
}
return CollectionObject;
}
}
/// <summary>
/// Gets the virtual system replication service.
/// </summary>
/// <param name="scope">The scope to use when connecting to WMI.</param>
/// <returns>The collection virtual machine replication service.</returns>
public static ManagementObject
GetVirtualMachineReplicationService(
ManagementScope scope)
{
ManagementScope scope2 = new ManagementScope(@"root\HyperVCluster\v2");
SelectQuery query = new SelectQuery("select * from Msvm_CollectionReplicationService");
using (ManagementObjectSearcher queryExecute = new ManagementObjectSearcher(scope2, query))
using (ManagementObjectCollection serviceCollection = queryExecute.Get())
{
if (serviceCollection.Count == 0)
{
throw new ManagementException("Cannot find the collection replication service object. " +
"Please check that the Hyper-V Virtual Machine Management service is running.");
}
return WmiUtilities.GetFirstObjectFromCollection(serviceCollection);
}
}
Also, here is ValidateOutput method.
/// <summary>
/// Validates the output parameters of a method call and prints errors, if any.
/// </summary>
/// <param name="outputParameters">The output parameters of a WMI method call.</param>
/// <param name="scope">The ManagementScope to use to connect to WMI.</param>
/// <returns><c>true</c> if successful and not firing an alert; otherwise, <c>false</c>.</returns>
public static bool
ValidateOutput(
ManagementBaseObject outputParameters,
ManagementScope scope)
{
return ValidateOutput(outputParameters, scope, true, false);
}
/// <summary>
/// Validates the output parameters of a method call and prints errors, if any.
/// </summary>
/// <param name="outputParameters">The output parameters of a WMI method call.</param>
/// <param name="scope">The ManagementScope to use to connect to WMI.</param>
/// <param name="throwIfFailed"> If true, the method throws on failure.</param>
/// <param name="printErrors">If true, Msvm_Error messages are displayed.</param>
/// <returns><c>true</c> if successful and not firing an alert; otherwise, <c>false</c>.</returns>
public static bool
ValidateOutput(
ManagementBaseObject outputParameters,
ManagementScope scope,
bool throwIfFailed,
bool printErrors)
{
bool succeeded = true;
string errorMessage = "The method call failed.";
if ((uint)outputParameters["ReturnValue"] == 4096)
{
//
// The method invoked an asynchronous operation. Get the Job object
// and wait for it to complete. Then we can check its result.
//
using (ManagementObject job = new ManagementObject((string)outputParameters["Job"]))
{
job.Scope = scope;
while (!IsJobComplete(job["JobState"]))
{
Thread.Sleep(TimeSpan.FromSeconds(1));
//
// ManagementObjects are offline objects. Call Get() on the object to have its
// current property state.
//
job.Get();
}
if (!IsJobSuccessful(job["JobState"]))
{
succeeded = false;
//
// In some cases the Job object can contain helpful information about
// why the method call failed. If it did contain such information,
// use it instead of a generic message.
//
if (!string.IsNullOrEmpty((string)job["ErrorDescription"]))
{
errorMessage = (string)job["ErrorDescription"];
}
if (printErrors)
{
PrintMsvmErrors(job);
}
if (throwIfFailed)
{
throw new ManagementException(errorMessage);
}
}
}
}
else if ((uint)outputParameters["ReturnValue"] != 0)
{
succeeded = false;
if (throwIfFailed)
{
throw new ManagementException(errorMessage);
}
}
return succeeded;
}
In the root of this repository it exhibit a MIT license, meaning all code here may be licensed under MIT license, but then going to the code, almost all code contains a header with following sentence:
// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.
Meaning all code is licensed under some form of EULA license.
Finally, going to Developer code samples at the very beginning, and then Microsoft Developer Services Agreement at the end of the document, in Exhibit B - Microsoft Limited Public License it states:
This license governs use of code marked as “sample” or “example” available on this web site
without a license agreement, as provided under the section above titled “NOTICE SPECIFIC
TO SOFTWARE AVAILABLE ON THIS WEB SITE.” If you use such code (the “software”), you
accept this license. If you do not accept the license, do not use the software.
As when the samples was distributed with Windows SDK (there were not any license file in there) which is now part of Windows-classic-samples.
Can Microsoft clarify which license apply to the files (MIT, Ms-LPL, other?), and update code headers according to that?.
DX11VideoRenderer sample is building a dll
Any plan to add a sample that either use that dll or make a new one that build an application instead?
hi, I have a crash when runing MFCaptureToFile on win10. I debug this program, if set MF_SOURCE_READER_ASYNC_CALLBACK attribute, the program will crash. how to deal with?
I was able to build the Samples/AmsiProvider in VS 2017 after adding runtimeobject.lib
as a linker dependency. It registered fine and added the AMSI reference registry key successfully. I followed the steps for logging and can get ETL file, and then dump the XML using tracerpt
. However, I'm only seeing the Close session
logs, and nothing from the Scan function, like Scan Start
or Attributes
. I've run a variety of PowerShell commands, including Mimikatz, and other things that Windows Defender alerts on, as well as some benign Write-Host
commands and calc.exe. Any idea why Scan wouldn't get invoked or trace log? Thanks!
DX11VideoRenderer produce only DX11VideoRenderer.dll. There is no executable file in Debug folder, however according to the README.md it has to be there.
I am exploring windows credential providers.
So, I have started with this samples https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/security/credentialproviders
Build environment
Windows 10 - 64 bit
Visual Studio 2017
Build the project
What I have done
What is expected
Linker's input list includes websocket.lib.
And running websocket sample fails because of missing websocket.dll.
Where can I get websocket.lib and websocket.dll?
If possible, for both x86 and x64.
thx
HaeRim
I am loking for a W10 class to capture video devices. ANy updated repository?
Hi,
I’m running into some issues with the dial when the application is running as administrator.
Using the sample classic Desktop Sample App: https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/RadialController/cpp
It seems that many of the callbacks registered stop working as a result of the application being run as administrator.
For example, a number of callbacks no longer get called when registered with:
IRadialControllerInterop::add_ControlLost
IRadialControllerInterop::add_ControlAcquired
IRadialControllerInterop::add_RotationChanged
...
Etc.
The registration of the above callbacks appear to succeed when looking at the HRESULT.
The only callback that seems to be working when running as administrator is the callback registered via IRadialControllerMenuItem::add_Invoked.
Lawrence
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System] "dontdisplaylastusername"=dword:00000001
If I enable the following setting dontdisplaylastusername, either through policy or by setting this registry setting and try to go to the login screen, the cursor just spins and the screen just flashes and I am never able to get the login screen to come up. Without any custom v2 credential providers installed, I am able to get to the Other User screen correctly.
How can I fix this? I tried adding a username field to my custom version since yours did not have one to see if that made any difference but that did not change anything.
Here is an example of the fault that is logged for the sample credential provider.
Fault bucket , type 0
Event Name: APPCRASH
Response: Not available
Cab Id: 0
Problem signature:
P1: LogonUI.exe
P2: 10.0.10586.0
P3: 5632d88c
P4: SampleV2CredentialProvider.dll
P5: 0.0.0.0
P6: 56cc64dd
P7: c0000005
P8: 0000000000003086
P9:
P10:
Attached files:
These files may be available here:
C:\ProgramData\Microsoft\Windows\WER\ReportQueue\AppCrash_LogonUI.exe_5e45fd9b49f0ea6611374ae56677dfa1cb3a1fe_9798b224_0a4ffaf8
Analysis symbol:
Rechecking for solution: 0
Report Id: 5efbdb96-de9f-4254-b259-1beea7137fc7
Report Status: 96
Faulting application name: LogonUI.exe, version: 10.0.10586.0, time stamp: 0x5632d88c
Faulting module name: SampleV2CredentialProvider.dll, version: 0.0.0.0, time stamp: 0x56cc64dd
Exception code: 0xc0000005
Fault offset: 0x0000000000003086
Faulting process id: 0x3a8
Faulting application start time: 0x01d1910e42a0efb5
Faulting application path: C:\Windows\system32\LogonUI.exe
Faulting module path: C:\Windows\system32\SampleV2CredentialProvider.dll
Report Id: 038f9265-0f6f-45fa-bc3e-6c7de490ca34
Faulting package full name:
Faulting package-relative application ID:
Are there any special considerations when trying to use this project as a DLL rather than a console application? I tried to move the code to a DLL, make wrapper functions to return a pointer to an instance of SimpleConsole, and then use wrapper functions to call ExecuteCommand on that instance. I have not yet been able to get it working from either Golang with the Syscall package, or from another C++ console application using LoadLibrary and GetProcAddress. If this is not doable in theory, can someone please tell me why? Thanks to anyone who can help.
Anyone else having build issues with newer versions of Visual Studio?
For example, with Visual Studio 2015 and Visual Studio 2017.
i.e. in https://github.com/Microsoft/Windows-classic-samples/blob/master/Samples/Win7Samples/Touch/MTScratchpadWMTouch/CS/WMTouchForm.cs is ulong used but MSDN https://msdn.microsoft.com/de-de/library/windows/desktop/dd317326(v=vs.85).aspx wants ULONG which is unsigned long --> 32 bit in size
This is not the only file where RegisterTouchWindow is used.
I tested this of course only with a 32 bit system or more with forces 32 bit C# application.
Hi,
it looks like some of the files encoded as UTF-16LE were corrupted by git's line ending conversion. The attached image shows the result of opening Windows-classic-samples\Samples\PowerShell\Host\Host06\cs\Host06.cs in Visual Studio.
I have also attached a list of files with inconsistent line endings.
libgit2 bug 1002 discusses git's lack of support for UTF16
Regards,
David
Compiling
Windows-classic-samples\Samples\ConnectionManagerCost\cpp\Wcmcostsample.cpp
using the far superior clang-cl
, gives this error:
Wcmcostsample.cpp(332,1): error: 'main' must return 'int'
void __cdecl main()
^
An easy fix.
I might have missed them in this repo but there are some interesting samples for Schannel in the Win2003 PSDK: \Samples\Security\SSPI\SSL
The SDK is available for public download at https://www.microsoft.com/en-us/download/details.aspx?id=12261
Readme says:
https://github.com/Microsoft/Windows-classic-samples/blob/9e116e87e7b6ab4a530aa63596fb13165b56812b/Samples/Win7Samples/winui/WindowsRibbon/Gallery/ReadMe.txt#L9
However gallery.xml is missing.
Hello *
I am writing TCP Server for handling good traffic from various clients for windows.
Each TCP Server is running on an individual port.
I have chosen IOCP as the TCP Socket , just need your valuable thoughts, there would be various instances of IOCP TCP Server running on its own port on a single windows server. Will there be any over head running multiple instances of IOCP servers on single windows machine , each instance / port would be handling traffic close to 10K clients ?
Abhi
Hello,
I downloaded the latest version of Visual Studio and copied the entire NetworkAccessProtectionExtensions solution. I was able to open and build the solution without any problems but the resulting SdkShv.dll will not load on my 2012 R2 server.
cannot convert argument 4 from 'LPITEMIDLIST *' to 'LPCITEMIDLIST *'
on this line of code:
hr = SHCreateShellItemArray(NULL, psfSampleSrc, c_cMaxFilesToCreate, &rgpidlChildren[0], &psia);
Hi ,
i am using the same sample to connect Bluetooth handset from window 7 machine. i am successfully able to locate and pair the Bluetooth handset, Window 7 bluetooth devices shows the handset under paired devices. but socket connect is failed always with error code 10060.
Sample is working fine on win10.
In the above page, i found 2 issues
The sample ssp contains a make file that builds in Windows NT systems only and fails in a windows 7 machine, making this not usable under a windows SDK 7 sample
The readme file contains a help documentation on how to invoke after building it using a SOCKAUTH security.c file, howevere i could not find a reference to that in this github.
Can anyone please help
Hello~!
For some purpose , I want to monitor powershell script when it's running.
According to the sourcecode from https://github.com/PowerShell/PowerShell/blob/master/src/System.Management.Automation/engine/runtime/CompiledScriptBlock.cs
I find the AMSI function will be called before compiling. So I make a test follow the instruction of AmsiProvider , But I can only see the function named CloseSession has been called , The scan function never have been called at all . The testing environment is Win10x86,16299,RS3
Hi there,
On most repos, there's a download zip of the branch on offer on the top right, but nothing for DPIAwarenessPerWindow so these files must be downloaded separately.
Don't use Git in VS- was this supposed to work with that, if that was ever a thing?
Edit: just realised the 50mb entire classic samples has to be downloaded- so it must be a Git thing then.
This can be closed.
Thanks.
Hi,
I built this sample, but it faults on run with this stack
> DynamicDPI.exe!ATL::CWindowImplRoot<ATL::CWindow>::~CWindowImplRoot<ATL::CWindow>() Line 3191 C++
DynamicDPI.exe!ATL::CWindowImplBaseT<ATL::CWindow,ATL::CWinTraits<269221888,0> >::~CWindowImplBaseT<ATL::CWindow,ATL::CWinTraits<269221888,0> >() C++
DynamicDPI.exe!ATL::CWindowImpl<CSampleDesktopWindow,ATL::CWindow,ATL::CWinTraits<269221888,0> >::~CWindowImpl<CSampleDesktopWindow,ATL::CWindow,ATL::CWinTraits<269221888,0> >() C++
DynamicDPI.exe!CSampleDesktopWindow::~CSampleDesktopWindow() Line 26 C++
DynamicDPI.exe!CSampleDynamicDpiWindow::~CSampleDynamicDpiWindow() Line 162 C++
fault is here
#ifdef _DEBUG
if(m_hWnd != NULL) // should be cleared in WindowProc
{
ATLTRACE(atlTraceWindowing, 0, _T("ERROR - Object deleted before window was destroyed\n"));
ATLASSERT(FALSE);
}
#endif //_DEBUG
My VS environment
Microsoft Visual Studio Professional 2013
Version 12.0.40629.00 Update 5
Microsoft .NET Framework
Version 4.6.01038
Installed Version: Professional
Team Explorer for Visual Studio 2013 06177-004-0446016-02925
Microsoft Team Explorer for Visual Studio 2013
Visual Basic 2013 06177-004-0446016-02925
Microsoft Visual Basic 2013
Visual C# 2013 06177-004-0446016-02925
Microsoft Visual C# 2013
Visual C++ 2013 06177-004-0446016-02925
Microsoft Visual C++ 2013
Visual F# 2013 06177-004-0446016-02925
Microsoft Visual F# 2013
Visual Studio 2013 Code Analysis Spell Checker 06177-004-0446016-02925
Microsoft® Visual Studio® 2013 Code Analysis Spell Checker
Portions of International CorrectSpell™ spelling correction system © 1993 by Lernout & Hauspie Speech Products N.V. All rights reserved.
The American Heritage® Dictionary of the English Language, Third Edition Copyright © 1992 Houghton Mifflin Company. Electronic version licensed from Lernout & Hauspie Speech Products N.V. All rights reserved.
Windows Phone SDK 8.0 - ENU 06177-004-0446016-02925
Windows Phone SDK 8.0 - ENU
Application Insights Tools for Visual Studio Package 1.0
Application Insights Tools for Visual Studio
Common Azure Tools 1.4
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Microsoft Azure Mobile Services Tools 1.4
Microsoft Azure Mobile Services Tools
NuGet Package Manager 2.8.60610.756
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
PreEmptive Analytics Visualizer 1.2
Microsoft Visual Studio extension to visualize aggregated summaries from the PreEmptive Analytics product.
Windows Phone 8.1 SDK Integration 1.0
This package integrates the tools for the Windows Phone 8.1 SDK into the menus and controls of Visual Studio.
Let me know anything else you need.
Hello,
I would like to use DNS Service Discovery in C++/CLR Windows App.
I inclueded Bonjour API of Apple but I got an error warning LNK4248: unresolved typeref token (0100002B) for '_DNSServiceRef_t'; image may not run
It's because of CLR... I don't know how to fix this..
I saw that Microsoft got headers already included of dns service discovery.
Please can you give me some advice ? How can I do ?
Thank you !
This "sample" just builds a DLL. There's no documentation, and no sample showing how to use the DLL.
Fail.
These samples reference Windows 7 and later and am trying to understand if these are the latest (maintained) samples for Win10? I am not looking for UWP samples (I need to run as native code as these samples demonstrate).
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.