Недавно добавленные исходники

•  DeLiKaTeS Tetris (Тетрис)  150

•  TDictionary Custom Sort  3 329

•  Fast Watermark Sources  3 077

•  3D Designer  4 838

•  Sik Screen Capture  3 331

•  Patch Maker  3 545

•  Айболит (remote control)  3 651

•  ListBox Drag & Drop  3 004

•  Доска для игры Реверси  81 650

•  Графические эффекты  3 933

•  Рисование по маске  3 240

•  Перетаскивание изображений  2 621

•  Canvas Drawing  2 744

•  Рисование Луны  2 571

•  Поворот изображения  2 179

•  Рисование стержней  2 167

•  Paint on Shape  1 567

•  Генератор кроссвордов  2 231

•  Головоломка Paletto  1 766

•  Теорема Монжа об окружностях  2 220

•  Пазл Numbrix  1 684

•  Заборы и коммивояжеры  2 055

•  Игра HIP  1 280

•  Игра Go (Го)  1 227

•  Симулятор лифта  1 472

•  Программа укладки плитки  1 215

•  Генератор лабиринта  1 545

•  Проверка числового ввода  1 361

•  HEX View  1 494

•  Физический маятник  1 357

 
скрыть


Delphi FAQ - Часто задаваемые вопросы

| Базы данных | Графика и Игры | Интернет и Сети | Компоненты и Классы | Мультимедиа |
| ОС и Железо | Программа и Интерфейс | Рабочий стол | Синтаксис | Технологии | Файловая система |



Delphi Sources

Запустить на выполнение файл от имени любого пользователя



Автор: Диюк Анрей

unit HSAdvApi;

interface

uses
  Windows;
procedure MyCreateProcess(ConstCommandLine: string);
function CreateProcessWithLogonW(const lpUsername: PWideChar;
  const lpDomain: PWideChar; const lpPassword: PWideChar;
  dwLogonFlags: DWORD; const lpApplicationName: PWideChar;
  lpCommandLine: PWideChar; dwCreationFlags: DWORD;
  lpEnvironment: Pointer; const lpCurrentDirectory: PWideChar;
  lpStartupInfo: PStartupInfo;
  lpProcessInfo: PProcessInformation): Boolean; stdcall;

const
  LOGON_WITH_PROFILE = $00000001;
  LOGON_NETCREDENTIALS_ONLY = $00000002;
  LOGON_ZERO_PASSWORD_BUFFER = $80000000;

implementation
uses
  SysUtils;
{$WARN SYMBOL_DEPRECATED OFF}
{ ADVAPI32.DLL functions }
type
  TCreateProcessWithLogonW =
    function(const lpUsername: PWideChar;
    const lpDomain: PWideChar; const lpPassword: PWideChar;
    dwLogonFlags: DWORD; const lpApplicationName: PWideChar;
    lpCommandLine: PWideChar; dwCreationFlags: DWORD;
    lpEnvironment: Pointer; const lpCurrentDirectory: PWideChar;
    lpStartupInfo: PStartupInfo;
    lpProcessInfo: PProcessInformation): Boolean; stdcall;

const
  DllName = 'advapi32.dll';

var
  DllHandle: THandle;
  _CreateProcessWithLogonW: TCreateProcessWithLogonW;

function InitLib: Boolean;
begin
  if DllHandle = 0 then
    if Win32Platform = VER_PLATFORM_WIN32_NT then
    begin
      DllHandle := LoadLibrary(DllName);
      if DllHandle <> 0 then
      begin
        @_CreateProcessWithLogonW := GetProcAddress(DllHandle,
          'CreateProcessWithLogonW');
      end;
    end;
  Result := (DllHandle <> 0);
end;

function NotImplementedBool: Boolean;
begin
  SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
  Result := false;
end;

function CreateProcessWithLogonW(const lpUsername: PWideChar;
  const lpDomain: PWideChar; const lpPassword: PWideChar;
  dwLogonFlags: DWORD; const lpApplicationName: PWideChar;
  lpCommandLine: PWideChar; dwCreationFlags: DWORD;
  lpEnvironment: Pointer; const lpCurrentDirectory: PWideChar;
  lpStartupInfo: PStartupInfo;
  lpProcessInfo: PProcessInformation): Boolean; stdcall;
begin
  if InitLib and Assigned(_CreateProcessWithLogonW) then
    Result := _CreateProcessWithLogonW(lpUsername, lpDomain, lpPassword,
      dwLogonFlags, lpApplicationName, lpCommandLine, dwCreationFlags,
      lpEnvironment, lpCurrentDirectory, lpStartupInfo, lpProcessInfo)
  else
    Result := NotImplementedBool;
end;

procedure MyCreateProcess(ConstCommandLine: string);
const
  UserName: WideString = 'ADMIN';
  Password: WideString = 'creyc';
  //ConstCommandLine : String = 'MONIC_S.EXE ';
  Title: WideString = 'SERVISE';
  Domain: WideString = 'SOKAL';
var
  MyStartupInfo: STARTUPINFO;
  ProcessInfo: PROCESS_INFORMATION;
  CommandLine: array[0..512] of WideChar;
begin
  FillChar(MyStartupInfo, SizeOf(MyStartupInfo), 0);
  MyStartupInfo.cb := SizeOf(MyStartupInfo);
  StringToWideChar(ConstCommandLine, CommandLine,
    Sizeof(CommandLine) div SizeOf(WideChar));
  MyStartupInfo.lpTitle := PWideChar(Title);
  if not CreateProcessWithLogonW(PWideChar(UserName), PWideChar(Domain),
    PWideChar(Password), LOGON_WITH_PROFILE, nil,
    CommandLine, 0, nil, nil, @MyStartupInfo, @ProcessInfo) then
    RaiseLastWin32Error()
  else
  begin
    CloseHandle(ProcessInfo.hProcess);
    CloseHandle(ProcessInfo.hThread);
  end;
end;

initialization
finalization
  if DllHandle <> 0 then
    FreeLibrary(DllHandle);
end.




Похожие по теме исходники

Чтение PSD файлов

Шифратор файлов

Разбиение файла на части

Поиск файлов

 

FileMan (менеджер файлов)

Поиск открытых файлов

Текст внутри файла

Гадание по имени

 



Copyright © 2004-2024 "Delphi Sources" by BrokenByte Software. Delphi World FAQ

Группа ВКонтакте