advapi32.odin 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // +build windows
  2. package sys_windows
  3. foreign import advapi32 "system:Advapi32.lib"
  4. @(default_calling_convention="stdcall")
  5. foreign advapi32 {
  6. @(link_name = "SystemFunction036")
  7. RtlGenRandom :: proc(RandomBuffer: ^u8, RandomBufferLength: ULONG) -> BOOLEAN ---
  8. OpenProcessToken :: proc(ProcessHandle: HANDLE,
  9. DesiredAccess: DWORD,
  10. TokenHandle: ^HANDLE) -> BOOL ---
  11. }
  12. // Necessary to create a token to impersonate a user with for CreateProcessAsUser
  13. @(default_calling_convention="stdcall")
  14. foreign advapi32 {
  15. LogonUserW :: proc(
  16. lpszUsername: LPCWSTR,
  17. lpszDomain: LPCWSTR,
  18. lpszPassword: LPCWSTR,
  19. dwLogonType: Logon32_Type,
  20. dwLogonProvider: Logon32_Provider,
  21. phToken: ^HANDLE,
  22. ) -> BOOL ---
  23. // https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-lookupaccountnamew
  24. // To look up the SID to use with DeleteProfileW.
  25. LookupAccountNameW :: proc(
  26. lpSystemName: wstring,
  27. lpAccountName: wstring,
  28. Sid: ^SID,
  29. cbSid: ^DWORD,
  30. ReferencedDomainName: wstring,
  31. cchReferencedDomainName: ^DWORD,
  32. peUse: ^SID_TYPE,
  33. ) -> BOOL ---
  34. CreateProcessWithLogonW :: proc(
  35. lpUsername: wstring,
  36. lpDomain: wstring,
  37. lpPassword: wstring,
  38. dwLogonFlags: DWORD,
  39. lpApplicationName: wstring,
  40. lpCommandLine: wstring,
  41. dwCreationFlags: DWORD,
  42. lpEnvironment: LPVOID,
  43. lpCurrentDirectory: wstring,
  44. lpStartupInfo: LPSTARTUPINFO,
  45. lpProcessInformation: LPPROCESS_INFORMATION,
  46. ) -> BOOL ---
  47. // https://docs.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-createprocessasuserw
  48. CreateProcessAsUserW :: proc(
  49. hToken: HANDLE,
  50. lpApplicationName: wstring,
  51. lpCommandLine: wstring,
  52. lpProcessAttributes: LPSECURITY_ATTRIBUTES,
  53. lpThreadAttributes: LPSECURITY_ATTRIBUTES,
  54. bInheritHandles: BOOL,
  55. dwCreationFlags: DWORD,
  56. lpEnvironment: LPVOID,
  57. lpCurrentDirectory: wstring,
  58. lpStartupInfo: LPSTARTUPINFO,
  59. lpProcessInformation: LPPROCESS_INFORMATION,
  60. ) -> BOOL ---
  61. }