GithubHelp home page GithubHelp logo

microsoft / windows-classic-samples Goto Github PK

View Code? Open in Web Editor NEW
4.8K 243.0 3.2K 37.53 MB

This repo contains samples that demonstrate the API used in Windows classic desktop applications.

License: Other

windows-classic-samples's Introduction

Windows classic samples

This repo contains samples that demonstrate the API used in Windows classic desktop applications.

Note. You can use Microsoft Visual Studio to search the entire set of source code here to see whether the usage of a particular Windows API is being demonstrated. Clone this repo (or download the ZIP) to your local file system. Then Find in Files in Visual Studio, set Look in to the folder you cloned or downloaded into, and search for an API name. You can install Visual Studio without expense. A Community edition is available—it's free for students, open-source contributors, and individuals.

These samples demonstrate the functionality and programming model for Windows and Windows Server. This repo contains Visual Studio solution (SLN) files for each sample, along with the source files, assets, resources, and metadata needed to compile and run the sample. For more info about the programming models, platforms, languages, and APIs demonstrated in these samples, check out the documentation on the Windows Dev Center.

Most of these samples were created for Windows 7, Windows 8.1 and/or Windows Server 2012 R2 using Visual Studio 2013, but some were created with earlier versions, or with specific SKU and other requirements. In many cases, the samples will also work on later versions than the ones indicated. If you cannot get a sample to work as expected, it might have platform, version, or SKU-specific requirements. If you have any issues with the samples, please provide feedback using the Issues list.

To get a copy of Visual Studio, go to Visual Studio Downloads.

Other samples:

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.

windows-classic-samples's People

Contributors

cgallred avatar cvubrugier avatar drewbatgit avatar edwardbetts avatar hsebs avatar iamalsaher avatar karl-bridge-microsoft avatar msftgits avatar stevewhims avatar zhaobenx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

windows-classic-samples's Issues

reference to a wrong project name in readme file

https://github.com/Microsoft/Windows-classic-samples/tree/master/Samples/Win7Samples/security/authentication/sampssp

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

Need License clarification please

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?.

Some general queries regarding IOCP

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

issue about AmsiProvider

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

AmsiProvider example doesn't log any scan events

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!

Hyper-V Cluster - Shared Disk Replication

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;
}

incorrect documentation: enabling ProjFS

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).

Latest Windows Samples for MediaFoundation?

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

How to port this to DLL?

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.

If dontdisplaylastusername is turned on, loginui.exe keeps crashing with custom cred provider

[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:

i'm very glad

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.

VolumeShadowCopyServiceWriter sample fails to be listed by vssadmin list writers

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.

Dynamic DPI sample assert violation (UAF)

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.

samplewrapexistingcredentialprovider is not displayed in Windows7

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

  1. Open the project file .sln in IDE
  2. It prompted to migrate the files, so I click Ok
  3. I have built it for both 32 and 64
  4. It built successfully

What I have done

  1. I have installed respective vcredist.exe
  2. I have followed the instructions mentioned in respective samples
  3. sampleallcontrolscredentialprovider works in both Win 10(64) and Win 7(32)
  4. samplewrapexistingcredentialprovider works in Win 10(64) only, but not in Win 7(32)
  5. No error displayed

What is expected

  1. The tile "Local or domain account password..." should be displayed in Windows7 login screen along with other tiles

corrupt source files

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.
image

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

Use of attribute MF_SA_REQUIRED_SAMPLE_COUNT_PROGRESSIVE

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:

  • use the differentiated attribute keys I mentioned above to differentiate these cases, -or-
  • set the value determined at this juncture into both of those attribute keys.

I'm not sure which of these options is best, since documentation on those attributes is quite thin.

Add new demonstration based on MFCaptureD3D Sample

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?

IAntimalwareProvider for VBS/JS?

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!

Location of the center of the zoom in GID_ZOOM Gesture

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.

Unable to connect to bluetooth handset from Window 7

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.

[Wcmcostsample.cpp] error with clang-cl

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.

crash when runing MFCaptureToFile on win10

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?

AmsiStream sample fails with E_INVALIDARG for large files

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.

WpdApiSample error

error c2065; 'CLSID_PortableDeviceFTM' : undeclared identifier DeviceEnumeration.cpp 399

How to fix it?

How to port this to DLL?

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.

No "Download Zip" for DPIAwarenessPerWindow

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.

RadialController cpp - Run As Administrator

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

No Msvm_PlannedComputerSystem could be found with name "xxxxxx"

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.

NetworkAccessProtectionExtensions SHV will not load?

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.

Can not detect touchpad by IdentifyInputSource sample

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:

  1. Change windows version https://github.com/chaopeng/IdentifyInputSource/blob/master/cpp/stdafx.h#L10
  2. Change event handler https://github.com/chaopeng/IdentifyInputSource/blob/master/cpp/InputSource.cpp#L159

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

Can't run sln

can't run sln cpp or console
only can run wpf sln

Develop Environment
Visual studio 2017
Windows 10

DNS Service Discovery

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 !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.