This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NTSTATUS CreateECDHKey(_In_ BCRYPT_KEY_HANDLE *phKey, PCWSTR pszAlgId) | |
| { | |
| NTSTATUS status; | |
| BCRYPT_ALG_HANDLE hAlgorithm; | |
| if (0 <= (status = BCryptOpenAlgorithmProvider(&hAlgorithm, pszAlgId, 0, 0))) | |
| { | |
| BCRYPT_KEY_HANDLE hKey; | |
| status = BCryptGenerateKeyPair(hAlgorithm, &hKey, 0, 0); | |
| BCryptCloseAlgorithmProvider(hAlgorithm, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NTSTATUS GenRsaKey(_Out_ BCRYPT_KEY_HANDLE *phKey, _In_ ULONG dwLength = 2048) | |
| { | |
| NTSTATUS status; | |
| BCRYPT_ALG_HANDLE hAlgorithm; | |
| if (0 <= (status = BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_RSA_ALGORITHM, 0, 0))) | |
| { | |
| BCRYPT_KEY_HANDLE hKey; | |
| status = BCryptGenerateKeyPair(hAlgorithm, &hKey, dwLength, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NTSTATUS GenRsaKey(_Out_ BCRYPT_KEY_HANDLE *phKey, _In_ ULONG dwLength = 2048) | |
| { | |
| NTSTATUS status; | |
| BCRYPT_ALG_HANDLE hAlgorithm; | |
| if (0 <= (status = BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_RSA_ALGORITHM, 0, 0))) | |
| { | |
| BCRYPT_KEY_HANDLE hKey; | |
| status = BCryptGenerateKeyPair(hAlgorithm, &hKey, dwLength, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace std | |
| { | |
| class latch | |
| { | |
| HANDLE _hEvent; | |
| volatile LONG _Counter; | |
| public: | |
| latch(LONG Expected) : _Counter(Expected), _hEvent(CreateEventW(0,0,0,0)) | |
| { | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NTSTATUS GenDHKey(_Out_ BCRYPT_KEY_HANDLE* phKey) | |
| { | |
| NTSTATUS status; | |
| BCRYPT_ALG_HANDLE hAlgorithm; | |
| if (0 <= (status = BCryptOpenAlgorithmProvider(&hAlgorithm, BCRYPT_DH_ALGORITHM, 0, 0))) | |
| { | |
| BCRYPT_KEY_HANDLE hKey; | |
| status = BCryptGenerateKeyPair(hAlgorithm, &hKey, 0, 0); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void TestDllReloc() | |
| { | |
| if (HMODULE hmod = GetModuleHandleW(L"kernel32.dll")) | |
| { | |
| STARTUPINFOW si = { sizeof(si) }; | |
| PROCESS_INFORMATION pi; | |
| WCHAR cmd[] = L"notepad.exe"; | |
| if (CreateProcessW(0, cmd, 0, 0, FALSE, CREATE_SUSPENDED, 0, 0, &si, &pi)) | |
| { | |
| VirtualAllocEx(pi.hProcess, hmod, 1, MEM_RESERVE, PAGE_NOACCESS); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| struct TPARAMS | |
| { | |
| HANDLE hEvent; | |
| PNT_TIB Tib; | |
| ULONG_PTR LowLimit, HighLimit; | |
| }; | |
| ULONG WINAPI TestThread(TPARAMS* param) | |
| { | |
| param->Tib = reinterpret_cast<PNT_TIB>(NtCurrentTeb()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| void ght(PCWSTR lpMachineName) | |
| { | |
| HKEY hKey, hk; | |
| if (NOERROR == RegConnectRegistry(lpMachineName, HKEY_USERS, &hKey)) | |
| { | |
| ULONG i = 0; | |
| WCHAR name[SECURITY_MAX_SID_STRING_CHARACTERS + 32]; | |
| ULONG cch; | |
| LONG status; | |
| while (ERROR_NO_MORE_ITEMS != (status = RegEnumKeyExW(hKey, i++, name, &(cch = SECURITY_MAX_SID_STRING_CHARACTERS), 0, 0, 0, 0))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NTSTATUS CreateMountPoint(POBJECT_ATTRIBUTES poa, PCWSTR SubstituteName, PCWSTR PrintName) | |
| { | |
| NTSTATUS status = STATUS_INTERNAL_ERROR; | |
| PREPARSE_DATA_BUFFER prdb = 0; | |
| int len = 0; | |
| PWSTR PathBuffer = 0; | |
| ULONG cb = 0; | |
| while (0 < (len = _snwprintf(PathBuffer, len, L"%ws%c%ws", SubstituteName, 0, PrintName))) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| NTSTATUS CreateMountPoint(POBJECT_ATTRIBUTES poa, PCWSTR SubstituteName, PCWSTR PrintName) | |
| { | |
| NTSTATUS status = STATUS_INTERNAL_ERROR; | |
| PREPARSE_DATA_BUFFER prdb = 0; | |
| int len = 0; | |
| PWSTR PathBuffer = 0; | |
| ULONG cb = 0; | |
| while (0 < (len = _snwprintf(PathBuffer, len, L"%ws%c%ws", SubstituteName, 0, PrintName))) | |
| { |
NewerOlder