mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-05 15:18:49 +00:00
Add support to core:windows to add/delete users.
main :: proc() {
using fmt;
using windows;
username := "testuser";
password := "testpass";
ok := add_user("", username, password);
fmt.printf("add_user: %v\n", ok);
pi := windows.PROCESS_INFORMATION{};
ok2, path := windows.add_user_profile(username);
fmt.printf("add_user_profile: %v, %v\n", ok2, path);
ok3 := windows.delete_user_profile(username);
fmt.printf("delete_user_profile: %v\n", ok3);
ok4 := windows.delete_user("", username);
fmt.printf("delete_user: %v\n", ok4);
// Has optional bool to not wait on the process before returning.
b := run_as_user(username, password, "C:\\Repro\\repro.exe", "Hellope!", &pi);
fmt.printf("run_as_user: %v %v\n", b, pi);
}
This commit is contained in:
@@ -7,4 +7,32 @@ foreign userenv {
|
||||
GetUserProfileDirectoryW :: proc(hToken: HANDLE,
|
||||
lpProfileDir: LPWSTR,
|
||||
lpcchSize: ^DWORD) -> BOOL ---
|
||||
LoadUserProfileW :: proc(
|
||||
hToken: HANDLE,
|
||||
lpProfileInfo: ^PROFILEINFOW,
|
||||
) -> BOOL ---
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-createprofile
|
||||
// The caller must have administrator privileges to call this function.
|
||||
CreateProfile :: proc(
|
||||
pszUserSid: LPCWSTR,
|
||||
pszUserName: LPCWSTR,
|
||||
pszProfilePath: wstring,
|
||||
cchProfilePath: DWORD,
|
||||
) -> u32 ---
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/userenv/nf-userenv-deleteprofilew
|
||||
// The caller must have administrative privileges to delete a user's profile.
|
||||
DeleteProfileW :: proc(
|
||||
lpSidString: LPCWSTR,
|
||||
lpProfilePath: LPCWSTR,
|
||||
lpComputerName: LPCWSTR,
|
||||
) -> BOOL ---
|
||||
|
||||
// https://docs.microsoft.com/en-us/windows/win32/api/sddl/nf-sddl-convertsidtostringsida
|
||||
// To turn a SID into a string SID to use with CreateProfile & DeleteProfileW.
|
||||
ConvertSidToStringSidW :: proc(
|
||||
Sid: ^SID,
|
||||
StringSid: ^LPCWSTR,
|
||||
) -> BOOL ---
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user