Skip to content

Commit 1ed3025

Browse files
author
Windows classic samples
committed
MFCaptureD3D and DeskBand fixes
MFCaptureD3D: Avoid infinite loop if no matching format is found. #135 fixed by @jameshfisher DeskBand: Avoid crash due to premature unload. #136 Also update a lot of README files so they show up in the https://docs.microsoft.com/samples browser.
1 parent b89b2cd commit 1ed3025

File tree

98 files changed

+2304
-1887
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2304
-1887
lines changed

Samples/AmsiProvider/README.md

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,17 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: IAntimalwareProvider interface sample
8+
urlFragment: iantimalwareprovider-sample
9+
description: Demonstrates how to use the Antimalware Provider Interface to register as a provider and scan an incoming stream.
10+
extendedZipContent:
11+
- path: LICENSE
12+
target: LICENSE
13+
---
14+
115
# IAntimalwareProvider interface sample
216

317
Demonstrates how to use the Antimalware Provider Interface to register as a provider and scan an incoming stream.
@@ -16,51 +30,25 @@ Note that the provider is loaded as an in-process server, which means that you n
1630

1731
1. Load the Project solution.
1832
2. Build the Project.
19-
3. From an elevated command prompt, go to the output directory and type
20-
````
21-
regsvr32 AmsiProvider.dll
22-
````
33+
3. From an elevated command prompt, go to the output directory and type `regsvr32 AmsiProvider.dll`.
2334

24-
If your system has other providers installed, they may take priority over the sample provider.
25-
To prevent this from happening (for testing purposes), go to the
26-
`HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AMSI\Providers`
27-
and
28-
`HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\AMSI\Providers`
29-
registry keys and temporarily rename the other providers
30-
so that the system will use the sample provider.
35+
If your system has other providers installed, they may take priority over the sample provider. To prevent this from happening (for testing purposes), go to the `HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\AMSI\Providers` and `HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\AMSI\Providers` registry keys and temporarily rename the other providers so that the system will use the sample provider.
3136

3237
### Exercising the sample provider
3338

34-
Events logged by the sample provider
35-
can be captured using ETW tools such as xperf. The log files are generated in
36-
ETL format so they can be viewed and processed by the Windows Performance
37-
Toolkit (WPT), as well as utilities such as tracerpt.exe or xperf.exe.
38-
39-
1. From an elevated command prompt, type
40-
````
41-
xperf.exe -start mySession -f myFile.etl -on 00604c86-2d25-46d6-b814-cd149bfdf0b3
42-
````
43-
to begin capturing events from the provider used by the sample.
39+
Events logged by the sample provider can be captured using ETW tools such as xperf. The log files are generated in ETL format so they can be viewed and processed by the Windows Performance Toolkit (WPT), as well as utilities such as *tracerpt.exe* or *xperf.exe*.
4440

41+
1. From an elevated command prompt, type `xperf.exe -start mySession -f myFile.etl -on 00604c86-2d25-46d6-b814-cd149bfdf0b3` to begin capturing events from the provider used by the sample.
4542
2. From an unelevated command prompt, launch PowerShell with the Bypass execution policy.
4643
The PowerShell program should be the same bitness as the project you built and installed.
47-
* To run 32-bit PowerShell on a 32-bit system, or 64-bit PowerShell on a 64-bit system: `powershell -ep bypass`
48-
* To run 32-bit PowerShell on a 64-bit system: `C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -ep bypass`
44+
* To run 32-bit PowerShell on a 32-bit system, or 64-bit PowerShell on a 64-bit system: `powershell -ep bypass`
45+
* To run 32-bit PowerShell on a 64-bit system: `C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell -ep bypass`
4946
3. Run some PowerShell commands. For example, type `calc` to launch calc.
5047
4. Exit PowerShell.
51-
5. From an elevated command prompt, type
52-
````
53-
xperf.exe -stop mySession
54-
````
55-
to stop capturing events.
56-
48+
5. From an elevated command prompt, type `xperf.exe -stop mySession` to stop capturing events.
5749
6. View the `myFile.etl` trace graphically in WPA, or generate a text version by typing `tracerpt myFile.etl`.
5850

5951
### Uninstalling the sample provider
6052

61-
1. From an elevated command prompt, go to the output directory and type
62-
````
63-
regsvr32 /u AmsiProvider.dll
64-
````
65-
66-
If you temporarily renamed conflicting providers when you installed the sample provider, rename the keys back.
53+
1. From an elevated command prompt, go to the output directory and type `regsvr32 /u AmsiProvider.dll`.
54+
2. If you temporarily renamed conflicting providers when you installed the sample provider, rename the keys back.

Samples/AmsiStream/README.md

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,32 @@
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: IAmsiStream interface sample
8+
urlFragment: iamsistream-sample
9+
description: Demonstrates how to use the Antimalware Scan Interface to scan a stream.
10+
extendedZipContent:
11+
- path: LICENSE
12+
target: LICENSE
13+
---
14+
115
# IAmsiStream interface sample
216

317
Demonstrates how to use the Antimalware Scan Interface to scan a stream.
418

5-
The sample implements the
6-
[IAmsiStream](https://msdn.microsoft.com/en-us/library/windows/desktop/dn889589(v=vs.85).aspx) interface
7-
so that an antimalware provider can use it to scan the contents of a stream.
19+
The sample implements the [IAmsiStream](https://msdn.microsoft.com/en-us/library/windows/desktop/dn889589(v=vs.85).aspx) interface so that an antimalware provider can use it to scan the contents of a stream.
820

9-
The sample demonstrates a stream where the data comes from a file
10-
and a stream where the data comes from an in-memory buffer.
21+
The sample demonstrates a stream where the data comes from a file and a stream where the data comes from an in-memory buffer.
1122

1223
## Instructions
1324
1. Load the Project solution.
14-
2. Go to Project Properties, Debugging.
25+
2. Go to **Project Properties, Debugging**.
1526
3. To scan an in-memory buffer, leave the *Command Arguments* blank. To scan a file, enter the file's complete path in the *Command Arguments*.
16-
4. Hit F5 to build and run.
27+
4. Press **F5** to build and run.
1728

18-
## Sample Output
29+
## Sample output
1930

2031
Creating stream object with file name: C:\sample.txt
2132
Calling antimalware->Scan() ...
Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
Create app package sample
2-
=========================
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: Create app package sample
8+
urlFragment: create-app-package
9+
description: Demonstrates how to create an app package by using the app Packaging API.
10+
---
11+
12+
# Create app package sample
313

414
This sample shows you how to create an app package by using the app [Packaging API](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446766).
515

616
Users acquire your app as an app package. Windows uses the information in an app package to install the app on a per-user basis, and ensure that all traces of the app are gone from the device after all users who installed the app uninstall it. Each package consists of the files that constitute the app, along with a package manifest file that describes the app to Windows.
717

818
The sample covers the following tasks:
919

10-
- Use [**IAppxFactory::CreatePackageWriter**](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446679) to create a package writer
11-
- Use [**IAppxPackageWriter::AddPayloadFile**](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446763) to add the payload files to the package
12-
- Create an input stream and use [**IAppxPackageWriter::Close**](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446764) to write the manifest at the end of the package
20+
- Use [IAppxFactory::CreatePackageWriter](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446679) to create a package writer.
21+
- Use [IAppxPackageWriter::AddPayloadFile](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446763) to add the payload files to the package.
22+
- Create an input stream and use [IAppxPackageWriter::Close](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446764) to write the manifest at the end of the package.
1323

1424
**Warning** This sample requires Microsoft Visual Studio 2013 or a later version (any SKU); it doesn't compile with Microsoft Visual Studio Express 2013 for Windows.
1525

@@ -19,45 +29,17 @@ To get a copy of Windows, go to [Downloads and tools](http://go.microsoft.com/fw
1929

2030
To get a copy of Visual Studio, go to [Visual Studio Downloads](http://go.microsoft.com/fwlink/p/?linkid=301697).
2131

22-
Related topics
23-
--------------
24-
25-
**Sample**
26-
27-
[Extract app package contents sample](http://go.microsoft.com/fwlink/p/?linkid=106455)
28-
29-
**Tasks**
30-
31-
[How to create a package](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446616)
32-
33-
**Concepts**
34-
35-
[App packages and deployment](http://msdn.microsoft.com/en-us/library/windows/desktop/hh464929)
36-
37-
**Reference**
38-
39-
[**IAppxFactory::CreatePackageWriter**](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446679)
40-
41-
[**IAppxPackageWriter**](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446762)
42-
43-
Related technologies
44-
--------------------
45-
46-
[App packaging and deployment](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446593)
32+
## Operating system requirements
4733

48-
Operating system requirements
49-
-----------------------------
50-
51-
Client
34+
### Client
5235

5336
Windows 8.1
5437

55-
Server
38+
### Server
5639

5740
Windows Server 2012 R2
5841

59-
Build the sample
60-
----------------
42+
## Build the sample
6143

6244
### From the Command window
6345

@@ -67,27 +49,49 @@ Build the sample
6749

6850
3. Run the following command:
6951

70-
**msbuild CreateAppx.sln**
52+
```msbuild CreateAppx.sln```
7153

7254
### From Visual Studio
7355

7456
1. Start Visual Studio and select **File** \> **Open** \> **Project/Solution**.
7557

76-
2. Go to the directory where you downloaded the CreateAppx sample and double-click its Microsoft Visual Studio Solution (.sln) file.
58+
2. Go to the directory where you downloaded the CreateAppx sample and select its Microsoft Visual Studio Solution (*.sln*) file.
7759

78-
3. Press F7 (or F6 for Visual Studio 2013) or use **Build** \> **Build Solution**.
60+
3. Press **F7** (or **F6** for Visual Studio 2013) or use **Build** \> **Build Solution**.
7961

8062
Run the sample
8163
--------------
8264

8365
1. Open a Command window.
8466

85-
2. Go to the CreateAppx\\Data directory.
67+
2. Go to the *CreateAppx\\Data* directory.
8668

8769
3. Run the following command (where \<path\> is "..\\debug\\CreateAppx" or "..\\release\\CreateAppx"):
8870

89-
**\<path\>\\CreateAppx**
71+
```\<path\>\\CreateAppx```
72+
73+
This command creates an app package named *HelloWorld.appx* from the contents of the *CreateAppx\\Data* directory.
74+
75+
## Related topics
76+
77+
### Sample
9078

91-
This command creates an app package named HelloWorld.appx from the contents of the CreateAppx\\Data directory.
79+
[Extract app package contents sample](http://go.microsoft.com/fwlink/p/?linkid=106455)
80+
81+
### Tasks
82+
83+
[How to create a package](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446616)
9284

85+
### Concepts
9386

87+
[App packages and deployment](http://msdn.microsoft.com/en-us/library/windows/desktop/hh464929)
88+
89+
### Reference
90+
91+
[IAppxFactory::CreatePackageWriter](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446679)
92+
93+
[IAppxPackageWriter](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446762)
94+
95+
## Related technologies
96+
97+
[App packaging and deployment](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446593)
Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,48 @@
1-
Create app bundle sample
2-
========================
1+
---
2+
page_type: sample
3+
languages:
4+
- cpp
5+
products:
6+
- windows-api-win32
7+
name: Create app bundle sample
8+
urlFragment: create-app-bundle
9+
description: Demonstrates how to create an app bundle using the Packaging API.
10+
---
11+
12+
# Create app bundle sample
313

414
This sample shows you how to create an app bundle using the [Packaging API](http://msdn.microsoft.com/en-us/library/windows/desktop/hh446766).
515

616
The sample covers these tasks:
717

8-
- Use [**IAppxBundleFactory::CreateBundleWriter**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280280) to create a bundle writer
9-
- Use [**IAppxBundleWriter::AddPayloadPackage**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280303) to add the payload packages to the bundle
10-
- Create an input stream and use [**IAppxBundleWriter::Close**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280304) to flush the stream
18+
- Use [IAppxBundleFactory::CreateBundleWriter](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280280) to create a bundle writer.
19+
- Use [IAppxBundleWriter::AddPayloadPackage](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280303) to add the payload packages to the bundle.
20+
- Create an input stream and use [IAppxBundleWriter::Close](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280304) to flush the stream.
1121

12-
Related topics
13-
--------------
22+
## Operating system requirements
1423

15-
**Reference**
16-
17-
[**IAppxBundleFactory::CreateBundleWriter**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280280)
18-
19-
[**IAppxBundleWriter**](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280302)
20-
21-
Operating system requirements
22-
-----------------------------
23-
24-
Client
24+
### Client
2525

2626
Windows 8.1
2727

28-
Server
28+
### Server
2929

3030
Windows Server 2012 R2
3131

32-
Build the sample
33-
----------------
32+
## Build the sample
3433

3534
1. Start Microsoft Visual Studio and select **File** \> **Open** \> **Project/Solution**.
36-
2. Go to the directory named for the sample, and double-click the Visual Studio Solution (.sln) file.
37-
3. Press F7 or use **Build** \> **Build Solution** to build the sample.
35+
2. Go to the directory named for the sample, and double-click the Visual Studio Solution (*.sln*) file.
36+
3. Press **F7** or use **Build** \> **Build Solution** to build the sample.
37+
38+
## Run the sample
39+
40+
To debug the app and then run it, press **F5** or use **Debug** \> **Start Debugging**. To run the app without debugging, press **Ctrl**+**F5** or use **Debug** \> **Start Without Debugging**.
41+
42+
## Related topics
3843

39-
Run the sample
40-
--------------
44+
### Reference
4145

42-
To debug the app and then run it, press F5 or use **Debug** \> **Start Debugging**. To run the app without debugging, press Ctrl+F5 or use **Debug** \> **Start Without Debugging**.
46+
[IAppxBundleFactory::CreateBundleWriter](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280280)
4347

48+
[IAppxBundleWriter](http://msdn.microsoft.com/en-us/library/windows/desktop/dn280302)

0 commit comments

Comments
 (0)