advapi32

Calling advapi.dll using Pinvoke: CryptDecrypt and CryptEncrypt unexpected behaviour

会有一股神秘感。 提交于 2019-12-23 03:33:56
问题 This is a follow up from this question. I am calling the WinAPI Cryptography functions from VB.net to ensure compatibility with a legacy product that shares the resulting data. The code functioned fine for many years however I have recently run into a problem when running on Windows Server 2012. After taking a look at various examples and the answer to my previous question I gave the code an overhaul, including changing what was previously a string variable to a Byte array, which I believe is

What's making this security descriptor go bad?

南笙酒味 提交于 2019-12-22 06:37:42
问题 I'm trying to read the access for files and directories in Windows using this code (patterned after Tim Golden's proposed patch to os.access to make it read from ACLs on Windows): from ctypes import( windll, wintypes, c_char_p, c_void_p, byref ) from win32api import GetCurrentThread from win32security import ( GetFileSecurity, DACL_SECURITY_INFORMATION, ImpersonateSelf, SecurityImpersonation, OpenThreadToken, TOKEN_ALL_ACCESS, MapGenericMask ) from ntsecuritycon import ( FILE_READ_DATA, FILE

Using RegSetKeySecurity to avoid registry redirection

偶尔善良 提交于 2019-12-11 10:33:22
问题 In order to avoid registry redirection to Wow64 keys, how to translate the following code that uses Microsoft.Win32 APIs public void SetKeyAccessControl( RegistryKey rootKey, string subKeyName, string identity, RegistryRights rights, InheritanceFlags inheritanceFlags, PropagationFlags propagationFlags, AccessControlType accessType) { using (RegistryKey regKey = rootKey.OpenSubKey(subKeyName, true)) { RegistrySecurity acl = new RegistrySecurity(); RegistryAccessRule rule = new

How to impersonate another user?

蓝咒 提交于 2019-12-10 14:18:59
问题 I'm working on an ASP.net app and i'm trying to impersonate a user I'm creating a windowsIdentity with a token WindowsIdentity winId = new WindowsIdenty( token ); this token was got by calling the un managed code [DllImport("advapi32.dll")] public static extern int LogonUserA(String lpszUserName, String lpszDomain, String lpszPassword, int dwLogonType, int dwLogonProvider, ref IntPtr phToken); is there any other way to get a token without using this advapi32.dll unmanaged code? tks 回答1:

Wincred not working properly with Git Bash(Git for Windows) when executing certain commands like “prune”

不想你离开。 提交于 2019-12-09 23:45:41
问题 I have setup GitforWindows in my Windows 7 64Bit pretty well with Credential manager as "Wincred". Yet when I run some commands like git remote prune origin in GitBash, it gives following error in console, though runs the command: Failed to load advapi32.dll Why is that ? If there is something need to be done with Credential manager settings, then I need full explanation of how to do those settings and what each setting means. Note: This problem I have only with some commands, other commands

How do I configure failure actions of a Windows service written in Go?

喜你入骨 提交于 2019-12-07 10:52:33
问题 I'm writing a Windows Service in Go using the golang.org/x/sys/windows/svc package. So far, it's all working great and so easy to get started with, I love it. I've written in some auto update functionality and I'm wanting the service to restart itself when it has completed an update. I've tried spawning a process that will restart the service using the SCM , but it logs an error message which seems to be to do with trying to control the service while running as Local System. The service

Calling AuditQuerySystemPolicy() (advapi32.dll) from C# returns “The parameter is incorrect”

我的梦境 提交于 2019-12-06 08:05:07
问题 The sequence is like follows: Open a policy handle with LsaOpenPolicy() (not shown) Call LsaQueryInformationPolicy() to get the number of categories; For each category: Call AuditLookupCategoryGuidFromCategoryId() to turn the enum value into a GUID; Call AuditEnumerateSubCategories() to get a list of the GUIDs of all subcategories; Call AuditQuerySystemPolicy() to get the audit policies for the subcategories. All of these work and return expected, sensible values except the last. Calling

Where can I find a good example of ReportEvent function usage?

北城以北 提交于 2019-12-06 01:57:46
问题 As with most "legacy" MSDN pages, the page for ReportEvent has too little information for me to make much sense of it. I've tried searching, but can't find a good, clean, simple example of the function's usage. Could anyone suggest one? 回答1: I ended up using this: HANDLE eventLog; WORD type; const char* msg; // ... snip ... ReportEvent(eventLog, type, 0, 1, NULL, 1, 0, &LPCTSTR(msg), NULL); Seems to work well enough. 回答2: Well this seems to be a very old thread, landed here looking for a good

How do I configure failure actions of a Windows service written in Go?

↘锁芯ラ 提交于 2019-12-05 16:36:18
I'm writing a Windows Service in Go using the golang.org/x/sys/windows/svc package. So far, it's all working great and so easy to get started with, I love it. I've written in some auto update functionality and I'm wanting the service to restart itself when it has completed an update. I've tried spawning a process that will restart the service using the SCM , but it logs an error message which seems to be to do with trying to control the service while running as Local System. The service process could not connect to the service controller. A better/easier way seems to be to os.Exit(1) and have

What's making this security descriptor go bad?

房东的猫 提交于 2019-12-05 10:52:03
I'm trying to read the access for files and directories in Windows using this code (patterned after Tim Golden's proposed patch to os.access to make it read from ACLs on Windows ): from ctypes import( windll, wintypes, c_char_p, c_void_p, byref ) from win32api import GetCurrentThread from win32security import ( GetFileSecurity, DACL_SECURITY_INFORMATION, ImpersonateSelf, SecurityImpersonation, OpenThreadToken, TOKEN_ALL_ACCESS, MapGenericMask ) from ntsecuritycon import ( FILE_READ_DATA, FILE_WRITE_DATA, FILE_EXECUTE, FILE_ALL_ACCESS ) import pywintypes import winnt TRUE = 1 def CheckAccess