Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • wine/wine
  • rbernon/wine
  • stefan/wine
  • FireBurn/wine
  • alesliehughes/wine
  • zhiyi/wine
  • huw/wine
  • jsikorski/wine
  • hmc/wine
  • dadangnh/wine
  • epo/wine
  • dlesho/wine
  • DarkShadow44/wine
  • iamahuman/wine
  • jacek/wine
  • mstorsjo/wine
  • gofman/wine
  • alexhenrie/wine
  • giomasce/wine
  • tclem/wine
  • besentv/wine
  • dlehman25/wine
  • aeikum/wine
  • cdavis5e/wine
  • sbaars/wine
  • baskanov/wine
  • pperdigao/wine
  • DavidHusicka/wine
  • DadSchoorse/wine
  • gverm/wine
  • bshanks/wine
  • gonzoMD/wine
  • Mystral/wine
  • tmatthies/wine
  • zlice/wine
  • AndreRH/wine
  • madewokherd/wine
  • zfigura/wine
  • fgouget/wine
  • nsivov/wine
  • ElementalWarrior/wine
  • piotr/wine
  • timozuccarello/wine
  • DavidCurtiss/wine
  • cmcadams/wine
  • davidebeatrici/wine
  • hans/wine
  • insn/wine
  • danrm/wine
  • jklemann/wine
  • saedo/wine
  • sgwaki/wine
  • puetzk/wine
  • bernhardu/wine
  • ReDress/wine
  • jlucfarias/wine
  • sloper42/wine
  • ivyl/wine
  • zhui/wine
  • julliard/wine
  • ClearlyClaire/wine
  • Alexander-Wilms/wine
  • rndtrash/wine
  • redmcg/wine
  • jkfloris/wine
  • maljaf/wine
  • Tuupertunut/wine
  • bsjeon/wine
  • tati/wine
  • whydoubt/wine
  • doitsujin/wine
  • shaunren/wine
  • szanni/wine
  • tobi.goergens/wine-cabinet-patch
  • winspool/wine
  • olivierfrdierick/wine
  • linkmauve/wine
  • jin-king1/wine
  • yeyeshun/wine
  • sulix/wine
  • bgc/wine
  • fanwenjie/wine
  • IncubusRK/wine
  • js6pak/wine
  • AurimasF/wine
  • etaash.mathamsetty/wine
  • hverbeet/wine
  • Fox2Code/wine
  • jhol/wine
  • jrueger/wine
  • afrantzis/wine
  • lauri.kentta/wine
  • ehoover/wine
  • cdenton/wine
  • jkloetzke/wine
  • baryluk/wine
  • restet/wine-personal
  • orudge/wine
  • Gcenx/wine
  • mstefani/wine
  • hibbsncc1701/wine
  • jchw/wine
  • moceap/wine
  • Skryptonyte/wine
  • marzent/wine
  • msmeissn/wine
  • learn-more/wine
  • logos128/wine
  • xe/wine
  • florian-kuebler/wine
  • eason329/wine
  • gang65/wine
  • binarymaster/wine
  • nbosio1001/wine
  • sh.owais95/wine
  • yaoyuan.0553/wine
  • AnthonyLaurienti/wine
  • mivanchev/wine
  • Hi-Angel/wine
  • vt/wine
  • wyrquill/wine
  • waynus/wine
  • wuliande/wine
  • yao.yuan.wn/wine
  • K1K1/wine
  • lukehutch1027/wine
  • etang-cw/wine
  • Josueblanco/wine
  • jplotz/wine
  • j20001970/wine
  • jsm174/wine
  • aricstewart/wine
  • uncoveryoureyestheresnosun/wine
  • VitorRamos/wine
  • 0e4ef622/wine
  • tj4048750/wine
  • xantares/wine
  • maxfigura/wine
  • sanane/wine
  • juniorjr9345/wine
  • lucaspereira1234/wine
  • gerald/wine
  • lepemiguel32/wine
  • caibb2018/wine
  • CNB_Kevin/wine
  • thc13/wine
  • jaihysc/wine
  • youngsecurity/wine
  • chendeqiang1024/wine
  • rhendric/wine
  • databoose/wine
  • memory-thrasher/wine
  • salman.tajik22/wine
  • CowFroggers/wine
  • kbdharun/wine
  • dreamer/wine
  • babyjoey711/wine
  • ripxorip/wine
  • PSzczepanski1996/wine
  • steveshe006/wine
  • joshua/wine
  • cmccarthy/wine
  • tomjansen/wine
  • sonyps5201314/wine
  • katelynnking4281/wine
  • dhary686/wine
  • mathematician/wine
  • rhabacker/wine
  • steveschnepp/wine
  • nekotekina/wine
  • Aaron1011/wine
  • catsout/wine
  • kasper93/wine
  • beef331/wine
  • ESD/wine
  • sarosib/wine
  • ghurmcardash/wine
  • AMZN-hgoffin/wine
  • gtmikw/wine
  • Keming/wine
  • dpjh747-gl/wine
  • tzluo/wine
  • rfz/wine
  • illia.a.polishchuk/wine
  • new_kleth/wine
  • serkan-maker/wine
  • w-flo/wine
  • mikayahlevi/wine
  • nulleve/wine
  • pgruebele/wine
  • athiele/wine
  • paparaha4/wine
  • novenary/wine
  • Plavil/wine
  • longjunyu/wine
  • chrisli/wine
  • samkottler/wine
  • danielzgtg/wine
  • twcassel/wine
  • guo/wine
  • didier31/wine
  • Zhaoyi/wine
  • twhitehead/wine
  • svyatpro/wine
  • infyquest/wine-iq-devel
  • sebres/wine
  • endrift/wine
  • zhengbl/wine
  • joelikeyan/wine
  • IsaacMarovitz/wine
  • LouiseTheGoldenGoddess/wine
  • SergeGautherie/wine
  • Klittiklatsch/wine
  • ldhacker/wine
  • dk1006498/wine
  • ishitatsuyuki/wine
  • h3c/wine
  • wincenty.bandyta41/wine
  • ayhankus482/wine
  • q4a/wine
  • mjgarton/wine
  • agusev/wine
  • vovams/wine
  • shardulsb08/wine
  • lylythechosenone/wine
  • artemist/wine
  • dropbear/wine
  • Cherser-s/wine
  • smayr/wine
  • loveptong/wine
  • chendeqiang/wine
  • gaber139/wine
  • shytzedaka/wine
  • ghkmufc/wine
  • TornadoCookie/wine
  • klownwolfman/wine
  • bylaws/wine
  • vitorhnn/wine
  • mide1337/wine
  • mewinkler/wine
  • firelzrd/wine
  • Samsuper/wine
  • kkartaltepe/wine
  • petravion/wine
  • Maaka00524/jacob-wine
  • petrathekat/wine
  • dj/wine
  • liam-middlebrook/wine
  • padolkarlucky/wine
  • maarten/wine
  • yhd986/wine
  • linkmecry/wine
  • tehrantoday/wine
  • xuxin12345/wine
  • dmjc/wine
  • sedwards/wine
  • hanslehnert/wine
  • 3ts75/wine
  • EkaterinePapava/wine
  • lav/wine
  • lygstate/wine
  • mxkrsv/wine
  • xutaxkamay/wine
  • cbialorucki/wine
  • yshui/wine
  • baikaishiuc/wine
  • HuwCampbell/wine
  • llde/wine
  • rockdrilla/wine
  • aidanhs/wine
  • SwimmingTiger/wine
  • fvalasiad/wine
  • zsoltiv/wine
  • mailnew4ster/wine
  • ake.rehnman/wine
  • IDocin/wine
  • dmitry/wine
  • Cthuflu/wine
  • corngood/wine
  • whindsaks/wine
  • telans/wine
  • DmitrySokolov/wine
  • Pospelove/wine
  • ellingtonsantos/wine
  • roro/wine
  • wurenny/wine
  • KokoseiJ/wine
  • amurzeau/wine
  • spazzymoto/wine
  • searchingin/wine
  • marler8997/wine
  • Alcaro/wine
  • aunali1/wine
  • snaccslocc420/wine
  • ajkhoury/wine
  • qsniyg/wine
  • Matheus-TestUser1/wine
  • adamrehn/wine
  • brobston/wine
  • aalyaev/wine
  • thongthai/wine
  • j.bayer1988/wine
  • skitt/wine
  • benben/wine
  • ahmouse15/wine
  • achurch/wine
  • mfaqiri2/wine
  • yseo/wine
  • kingjinni/wine
  • userid0x0/wine
  • titan/wine
  • Komoszek/wine
  • GamzeeRakoon/wine
  • joanluc/wine
  • Alan/wine
  • meshine/wine
  • EBADF/wine
  • vibhavp/wine
  • quininer/wine
  • pawelulita/wine
  • muek2211/wine
  • chenhaoyang/wine
  • nishiyama/wine
  • silviuxgaming/wine
  • nell/wine
  • 29jm/wine
  • arilou/wine
  • Mini-Gaunt/wine
  • DodoGTA/wine
  • davispuh/wine
  • mzent/wine
  • arakmar/wine
  • number201724/wine
  • yhd986/wine-up
  • rpisl/wine
  • zp1/wine-zp-cs-464
  • h0tc0d3/wine
  • Snowiiii/wine
  • gabrielb/wine
  • PureBulb/wine
  • OO/wine
  • Clara/wine
  • Saancreed/wine
  • enolp/wine
  • arthunix/wine
  • halfline/wine
  • carlo-bramini/wine
  • jfmu/wine
  • russelltg/wine
  • ntay/wine
  • YellowOnion/wine
  • niversesu/wine
  • gilvbp/wine
  • tingling0072/wine
  • DandD1517/wine
  • rastos/add-GetAnycastIpAddressTable
  • gnif/wine
  • gibsonpil/wine
  • antenabr2/wine
  • kvashis/wine
  • CKolle/wine
  • kubni/wine
  • ten0s/wine
  • Yvonne8873/wine
  • kurikaesu/wine
  • minggr/wine
  • JohnSebastienNadeau/wine
  • karshnicholas/wine
  • SamB/wine
  • apgrc/wine
  • Samiklom/wine
  • llyyr/wine
  • nberner/wine
  • katharinechui/wine
  • kirill.zhumarin/wine
  • vaxerski/wine
  • infiniteloop/wine
  • K0bin/wine
  • arethusa/wine
  • mrdeathjr28/wine
  • dank_meme/wine
  • dh/wine
  • tuomasjjrasanen/wine
  • mmcdonnell/wine
  • mxnny00/wine-manjaro-arch-compatibility
  • Joan/wine
  • g.mo.alcauter/wine
  • zhenbo_li/wine
  • tsmx/wine
  • xaqumin/wine
  • peterjc123/wine
  • ruslangaripov/wine
  • blyss/wine
  • xanathar/wine
  • michael.bond/wine
  • Quix0r/wine
  • sinisa.susnjar/wine
  • Rapid/wine
  • theli.ua/wine
  • shaun.din/wine
  • zhaohongxin/wine
  • dylan.eskew/wine
  • humbertoperezs991/wine
  • vaevi/wine
  • Riesi/wine
  • francisdb/wine
  • 1480c1/wine
  • trcrsired/wine
  • npatt/wine
  • muhammmadalli/wine9.0
  • Czahrien/wine
  • nilsen.jonas/wine
  • underdogest/wine
  • djordjem/wine
  • frubin/wine
  • LucasChollet/wine
  • lipengfei-loongson/wine
  • JacobCzekalla/wine-fork-jacob
  • omar_elantil/wine
  • lumarel/wine
  • principeagustin/wine
  • gotzl/wine
  • OneTester250376/wine
  • austin987/wine
  • unknown62627/wine
  • navi/wine
  • somedevfox/wine
  • notaz/wine
  • fcasas/wine
  • Asteroz/wine
  • MariusSchiffer/wine
  • kevinrmartinez/wine-devel
  • St1gven/wine
  • maarten256/wine
  • rcstarr87/wine
  • tinozzo123/wine
  • GermanAizek/wine
  • spencerwallace/wine
  • schloegl/wine
  • giuppococco/wine
  • shayan7878/wine
  • N080DY12/wine
  • ralf.habacker/wine
  • oh-ok/wine
  • johnporter/wine
  • Low-power/wine
  • thelande/wine
  • riyu12383/wine
  • kubapet/wine
  • Ivan_83/wine
  • SmithGoll/wine
  • gmesmer/wine
  • akarisu.de/wine
  • jwffrey9046/wine
  • anders/wine
  • markbhasawut/wine
  • dy-tea/wine
  • Benjamin_Loison/wine
  • frmdstryr/wine
  • zzam/wine
  • haydenhestad/wine
  • Deppy04/wine
  • osbre/wine
  • CharlottePabst/wine
  • SunlitTango/wine
  • ritalat/wine
  • AlexeyLushnikov/wine
  • mickdermack/wine
  • s1UMBa/wine
  • huangqinjin/wine
  • caseyr297/wine
  • d1saster/wine
  • ayufdh222/wine
  • janstrakowski/wine
  • petur/wine
  • matheus.venturini/wine-fix-ohm-sign
  • rayrapetyan/wine
  • xiaotong/wine
  • ovarley1/wine
  • dos1/wine
  • BZZZZ/wine
  • joesoroka/wine
  • toadking/wine
  • JoshuaBrest/wine
  • elias/wine
  • michele.dionisio/wine
  • garlett/wine-send-arp
  • eugenemcardle/wine
  • hugwijst/wine
  • whrvt/wine
  • loisgomez/wine
  • ramleejo/wine
  • self/wine
  • fr33z00/wine
  • JoeS209/wine
  • JacKeTUs/wine
  • nak.ak2015/wine
  • morgwai/wine
  • funfunctor/wine
  • donnyjoe/wine
  • sitter/wine
  • atticf/wine
  • xipster/wine
  • sebastian/wine
  • AlexanderWillner/wine
  • yaoyongjie/wine
  • wayne/wine
  • AMark/wine
  • zamaudio/wine
  • TomaszPakula/wine
  • Freakness109/wine
  • amorozov/wine
  • HP/wine
  • danlm/wine
  • rariema/wine
  • Biswa96/wine
  • rlippmann/wine
  • yangkun/wine
  • greyghoster/wine
  • toxieainc/wine
520 results
Show changes
Showing
with 1512 additions and 77 deletions
/*
* Copyright (c) 2017 Michael Müller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "resource.h"
#include "winresrc.h"
#pragma makedep po
LANGUAGE LANG_ENGLISH, SUBLANG_DEFAULT
IDD_SECURITY_PROPERTIES DIALOGEX 0, 0, 240, 215
STYLE DS_SHELLFONT | WS_CHILD | WS_CAPTION
CAPTION "Security"
FONT 8, "MS Shell Dlg"
BEGIN
LTEXT "&Group or user names:", -1, 5, 5, 230, 10
CONTROL "", IDC_USERS, "SysListView32", LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | LVS_SORTASCENDING
| LVS_SINGLESEL | LVS_SHOWSELALWAYS | WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
5, 17, 230, 63, WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE
LTEXT "", IDC_ACE_USER, 5, 105, 110, 10
LTEXT "Allow", -1, 120, 105, 55, 10, SS_CENTER
LTEXT "Deny", -1, 180, 105, 55, 10, SS_CENTER
CONTROL "", IDC_ACE, "SysListView32", LVS_REPORT | LVS_NOCOLUMNHEADER | LVS_NOSORTHEADER | LVS_SINGLESEL
| WS_CHILD | WS_VISIBLE | WS_VSCROLL | WS_TABSTOP,
5, 115, 230, 95, WS_EX_NOPARENTNOTIFY | WS_EX_CLIENTEDGE
END
STRINGTABLE
BEGIN
IDS_PERMISSION_FOR "Permissions for %1"
END
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
/* @makedep: user_icons.bmp */
IDB_USER_ICONS BITMAP user_icons.bmp
......@@ -18,44 +18,505 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <stdarg.h>
#define COBJMACROS
#include "initguid.h"
#include "windef.h"
#include "winbase.h"
#include "winuser.h"
#include "winnt.h"
#include "aclui.h"
#include "resource.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(aclui);
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
/* the aclui.h files does not contain the necessary COBJMACROS */
#define ISecurityInformation_AddRef(This) (This)->lpVtbl->AddRef(This)
#define ISecurityInformation_Release(This) (This)->lpVtbl->Release(This)
#define ISecurityInformation_GetObjectInformation(This, obj) (This)->lpVtbl->GetObjectInformation(This, obj)
#define ISecurityInformation_GetSecurity(This, info, sd, def) (This)->lpVtbl->GetSecurity(This, info, sd, def)
#define ISecurityInformation_GetAccessRights(This, type, flags, access, count, def) (This)->lpVtbl->GetAccessRights(This, type, flags, access, count, def)
struct user
{
WCHAR *name;
PSID sid;
};
struct security_page
{
TRACE("(0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
ISecurityInformation *security;
SI_OBJECT_INFO info;
PSECURITY_DESCRIPTOR sd;
switch (fdwReason)
SI_ACCESS *access;
ULONG access_count;
struct user *users;
unsigned int user_count;
HWND dialog;
HIMAGELIST image_list;
};
static HINSTANCE aclui_instance;
static WCHAR *WINAPIV load_formatstr(UINT resource, ...)
{
va_list valist;
WCHAR *str;
DWORD ret;
va_start(valist, resource);
ret = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_HMODULE,
aclui_instance, resource, 0, (WCHAR*)&str, 0, &valist);
va_end(valist);
return ret ? str : NULL;
}
static WCHAR *get_sid_name(PSID sid, SID_NAME_USE *sid_type)
{
WCHAR *name, *domain;
DWORD domain_len = 0;
DWORD name_len = 0;
BOOL ret;
LookupAccountSidW(NULL, sid, NULL, &name_len, NULL, &domain_len, sid_type);
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return NULL;
if (!(name = malloc(name_len * sizeof(WCHAR))))
return NULL;
if (!(domain = malloc(domain_len * sizeof(WCHAR))))
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls(hinstDLL);
break;
free(name);
return NULL;
}
return TRUE;
ret = LookupAccountSidW(NULL, sid, name, &name_len, domain, &domain_len, sid_type);
free(domain);
if (ret) return name;
free(name);
return NULL;
}
HPROPSHEETPAGE WINAPI CreateSecurityPage(LPSECURITYINFO psi)
static void add_user(struct security_page *page, PSID sid)
{
FIXME("(%p): stub\n", psi);
return NULL;
struct user *new_array, *user;
SID_NAME_USE sid_type;
unsigned int i;
LVITEMW item;
WCHAR *name;
/* check if we already processed this user or group */
for (i = 0; i < page->user_count; ++i)
{
if (EqualSid(sid, page->users[i].sid))
return;
}
if (!(name = get_sid_name(sid, &sid_type)))
return;
if (!(new_array = realloc(page->users, (page->user_count + 1) * sizeof(*page->users))))
{
free(name);
return;
}
page->users = new_array;
user = &page->users[page->user_count++];
user->name = name;
user->sid = sid;
item.mask = LVIF_PARAM | LVIF_TEXT | LVIF_IMAGE;
item.iItem = -1;
item.iSubItem = 0;
item.pszText = name;
item.lParam = (LPARAM)user;
item.iImage = (sid_type == SidTypeGroup || sid_type == SidTypeWellKnownGroup) ? 0 : 1;
SendMessageW(GetDlgItem(page->dialog, IDC_USERS), LVM_INSERTITEMW, 0, (LPARAM)&item);
}
static PSID get_sid_from_ace(ACE_HEADER *ace)
{
switch (ace->AceType)
{
case ACCESS_ALLOWED_ACE_TYPE:
return &((ACCESS_ALLOWED_ACE *)ace)->SidStart;
case ACCESS_DENIED_ACE_TYPE:
return &((ACCESS_DENIED_ACE *)ace)->SidStart;
default:
FIXME("Unhandled ACE type %#x.\n", ace->AceType);
return NULL;
}
}
static void compute_access_masks(PSECURITY_DESCRIPTOR sd, PSID sid, ACCESS_MASK *allowed, ACCESS_MASK *denied)
{
BOOL defaulted, present;
ACE_HEADER *ace;
PSID ace_sid;
DWORD index;
ACL *dacl;
*allowed = 0;
*denied = 0;
if (!GetSecurityDescriptorDacl(sd, &present, &dacl, &defaulted) || !present)
return;
for (index = 0; index < dacl->AceCount; index++)
{
if (!GetAce(dacl, index, (void**)&ace))
break;
ace_sid = get_sid_from_ace(ace);
if (!ace_sid || !EqualSid(ace_sid, sid))
continue;
if (ace->AceType == ACCESS_ALLOWED_ACE_TYPE)
*allowed |= ((ACCESS_ALLOWED_ACE*)ace)->Mask;
else if (ace->AceType == ACCESS_DENIED_ACE_TYPE)
*denied |= ((ACCESS_DENIED_ACE*)ace)->Mask;
}
}
static void update_access_list(struct security_page *page, struct user *user)
{
ACCESS_MASK allowed, denied;
WCHAR *infotext;
ULONG i, index;
LVITEMW item;
HWND control;
compute_access_masks(page->sd, user->sid, &allowed, &denied);
if ((infotext = load_formatstr(IDS_PERMISSION_FOR, user->name)))
{
SetDlgItemTextW(page->dialog, IDC_ACE_USER, infotext);
LocalFree(infotext);
}
control = GetDlgItem(page->dialog, IDC_ACE);
index = 0;
for (i = 0; i < page->access_count; i++)
{
if (!(page->access[i].dwFlags & SI_ACCESS_GENERAL))
continue;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iSubItem = 1;
if ((page->access[i].mask & allowed) == page->access[i].mask)
item.pszText = (WCHAR *)L"X";
else
item.pszText = (WCHAR *)L"-";
SendMessageW(control, LVM_SETITEMW, 0, (LPARAM)&item);
item.iSubItem = 2;
if ((page->access[i].mask & denied) == page->access[i].mask)
item.pszText = (WCHAR *)L"X";
else
item.pszText = (WCHAR *)L"-";
SendMessageW(control, LVM_SETITEMW, 0, (LPARAM)&item);
index++;
}
}
static void init_users(struct security_page *page)
{
BOOL defaulted, present;
ACE_HEADER *ace;
DWORD index;
ACL *dacl;
PSID sid;
if (!GetSecurityDescriptorDacl(page->sd, &present, &dacl, &defaulted))
{
ERR("Failed to query descriptor information, error %lu.\n", GetLastError());
return;
}
if (!present)
return;
for (index = 0; index < dacl->AceCount; index++)
{
if (!GetAce(dacl, index, (void **)&ace))
break;
if (!(sid = get_sid_from_ace(ace)))
continue;
add_user(page, sid);
}
}
static void init_access_list(struct security_page *page)
{
ULONG i, index;
WCHAR str[256];
LVITEMW item;
HWND control;
control = GetDlgItem(page->dialog, IDC_ACE);
index = 0;
for (i = 0; i < page->access_count; i++)
{
if (!(page->access[i].dwFlags & SI_ACCESS_GENERAL))
continue;
item.mask = LVIF_TEXT;
item.iItem = index;
item.iSubItem = 0;
if (IS_INTRESOURCE(page->access[i].pszName))
{
str[0] = 0;
LoadStringW(page->info.hInstance, (DWORD_PTR)page->access[i].pszName, str, ARRAY_SIZE(str));
item.pszText = str;
}
else
item.pszText = (WCHAR *)page->access[i].pszName;
SendMessageW(control, LVM_INSERTITEMW, 0, (LPARAM)&item);
index++;
}
}
BOOL WINAPI EditSecurity(HWND owner, LPSECURITYINFO psi)
static HIMAGELIST create_image_list(UINT resource, UINT width, UINT height, UINT count, COLORREF mask_color)
{
FIXME("(%p, %p): stub\n", owner, psi);
HIMAGELIST image_list;
HBITMAP image;
INT ret;
if (!(image_list = ImageList_Create(width, height, ILC_COLOR32 | ILC_MASK, 0, count)))
return NULL;
if (!(image = LoadBitmapW(aclui_instance, MAKEINTRESOURCEW(resource))))
{
ImageList_Destroy(image_list);
return NULL;
}
ret = ImageList_AddMasked(image_list, image, mask_color);
DeleteObject(image);
if (ret == -1)
{
ImageList_Destroy(image_list);
return NULL;
}
return image_list;
}
static void security_page_free(struct security_page *page)
{
unsigned int i;
for (i = 0; i < page->user_count; ++i)
free(page->users[i].name);
free(page->users);
LocalFree(page->sd);
if (page->image_list)
ImageList_Destroy(page->image_list);
if (page->security)
ISecurityInformation_Release(page->security);
free(page);
}
static void security_page_init_dlg(HWND hwnd, struct security_page *page)
{
LVCOLUMNW column;
HWND control;
HRESULT hr;
ULONG def;
RECT rect;
page->dialog = hwnd;
if (FAILED(hr = ISecurityInformation_GetSecurity(page->security,
DACL_SECURITY_INFORMATION, &page->sd, FALSE)))
{
ERR("Failed to get security descriptor, hr %#lx.\n", hr);
return;
}
if (FAILED(hr = ISecurityInformation_GetAccessRights(page->security,
NULL, 0, &page->access, &page->access_count, &def)))
{
ERR("Failed to get access mapping, hr %#lx.\n", hr);
return;
}
/* user list */
control = GetDlgItem(hwnd, IDC_USERS);
SendMessageW(control, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
GetClientRect(control, &rect);
column.mask = LVCF_FMT | LVCF_WIDTH;
column.fmt = LVCFMT_LEFT;
column.cx = rect.right - rect.left;
SendMessageW(control, LVM_INSERTCOLUMNW, 0, (LPARAM)&column);
if (!(page->image_list = create_image_list(IDB_USER_ICONS, 18, 18, 2, RGB(255, 0, 255))))
return;
SendMessageW(control, LVM_SETIMAGELIST, LVSIL_SMALL, (LPARAM)page->image_list);
init_users(page);
/* ACE list */
control = GetDlgItem(hwnd, IDC_ACE);
SendMessageW(control, LVM_SETEXTENDEDLISTVIEWSTYLE, LVS_EX_FULLROWSELECT, LVS_EX_FULLROWSELECT);
column.mask = LVCF_FMT | LVCF_WIDTH;
column.fmt = LVCFMT_LEFT;
column.cx = 170;
SendMessageW(control, LVM_INSERTCOLUMNW, 0, (LPARAM)&column);
column.fmt = LVCFMT_CENTER;
column.cx = 85;
SendMessageW(control, LVM_INSERTCOLUMNW, 1, (LPARAM)&column);
SendMessageW(control, LVM_INSERTCOLUMNW, 2, (LPARAM)&column);
init_access_list(page);
if (page->user_count)
{
LVITEMW item;
item.mask = LVIF_STATE;
item.iItem = 0;
item.iSubItem = 0;
item.state = LVIS_FOCUSED | LVIS_SELECTED;
item.stateMask = item.state;
SendMessageW(control, LVM_SETITEMW, 0, (LPARAM)&item);
}
}
static INT_PTR CALLBACK security_page_proc(HWND dialog, UINT msg, WPARAM wparam, LPARAM lparam)
{
switch (msg)
{
case WM_INITDIALOG:
{
PROPSHEETPAGEW *propsheet = (PROPSHEETPAGEW *)lparam;
SetWindowLongPtrW(dialog, DWLP_USER, propsheet->lParam);
security_page_init_dlg(dialog, (struct security_page *)propsheet->lParam);
break;
}
case WM_NOTIFY:
{
struct security_page *page = (struct security_page *)GetWindowLongPtrW(dialog, DWLP_USER);
NMHDR *hdr = (NMHDR *)lparam;
if (hdr->hwndFrom == GetDlgItem(dialog, IDC_USERS) && hdr->code == LVN_ITEMCHANGED)
{
NMLISTVIEW *listview = (NMLISTVIEW *)lparam;
if (!(listview->uOldState & LVIS_SELECTED) && (listview->uNewState & LVIS_SELECTED))
update_access_list(page, (struct user *)listview->lParam);
return TRUE;
}
break;
}
}
return FALSE;
}
static UINT CALLBACK security_page_callback(HWND hwnd, UINT msg, PROPSHEETPAGEW *ppsp)
{
struct security_page *page = (struct security_page *)ppsp->lParam;
if (msg == PSPCB_RELEASE)
security_page_free(page);
return 1;
}
HPROPSHEETPAGE WINAPI CreateSecurityPage(ISecurityInformation *security)
{
struct security_page *page;
PROPSHEETPAGEW propsheet;
HPROPSHEETPAGE ret;
TRACE("%p\n", security);
InitCommonControls();
if (!(page = calloc(1, sizeof(*page))))
return NULL;
if (FAILED(ISecurityInformation_GetObjectInformation(security, &page->info)))
{
free(page);
return NULL;
}
page->security = security;
ISecurityInformation_AddRef(security);
memset(&propsheet, 0, sizeof(propsheet));
propsheet.dwSize = sizeof(propsheet);
propsheet.dwFlags = PSP_DEFAULT | PSP_USECALLBACK;
propsheet.hInstance = aclui_instance;
propsheet.pszTemplate = (WCHAR *)MAKEINTRESOURCE(IDD_SECURITY_PROPERTIES);
propsheet.pfnDlgProc = security_page_proc;
propsheet.pfnCallback = security_page_callback;
propsheet.lParam = (LPARAM)page;
if (page->info.dwFlags & SI_PAGE_TITLE)
{
propsheet.pszTitle = page->info.pszPageTitle;
propsheet.dwFlags |= PSP_USETITLE;
}
if (!(ret = CreatePropertySheetPageW(&propsheet)))
{
ERR("Failed to create property sheet page.\n");
ISecurityInformation_Release(security);
free(page);
return NULL;
}
return ret;
}
BOOL WINAPI EditSecurity(HWND owner, ISecurityInformation *security)
{
PROPSHEETHEADERW sheet = {0};
HPROPSHEETPAGE pages[1];
SI_OBJECT_INFO info;
BOOL ret;
TRACE("(%p, %p)\n", owner, security);
if (FAILED(ISecurityInformation_GetObjectInformation(security, &info)))
return FALSE;
if (!(pages[0] = CreateSecurityPage(security)))
return FALSE;
sheet.dwSize = sizeof(sheet);
sheet.dwFlags = PSH_DEFAULT;
sheet.hwndParent = owner;
sheet.hInstance = aclui_instance;
sheet.pszCaption = load_formatstr(IDS_PERMISSION_FOR, info.pszObjectName);
sheet.nPages = 1;
sheet.nStartPage = 0;
sheet.phpage = pages;
ret = PropertySheetW(&sheet) != -1;
LocalFree((void *)sheet.pszCaption);
return ret;
}
BOOL WINAPI DllMain(HINSTANCE instance, DWORD reason, void *reserved)
{
if (reason == DLL_PROCESS_ATTACH)
{
aclui_instance = instance;
DisableThreadLibraryCalls(instance);
}
return TRUE;
}
/*
* Definitions for aclui dialog controls
*
* Copyright (c) 2017 Michael Müller
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#ifndef __WINE_ACLUI__
#define __WINE_ACLUI__
#define IDD_SECURITY_PROPERTIES 100
#define IDC_USERS 101
#define IDC_ACE_USER 110
#define IDC_ACE 111
#define IDS_PERMISSION_FOR 1000
#define IDB_USER_ICONS 2000
#define IDB_CHECKBOX 2001
#endif /* __WINE_ACLUI__ */
dlls/aclui/user_icons.bmp

2.67 KiB

MODULE = activeds.tlb
EXTRADLLFLAGS = -Wb,--data-only
SOURCES = \
activeds_tlb.idl
/*
* Copyright 2020 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep regtypelib
#include "iads.idl"
MODULE = activeds.dll
IMPORTLIB = activeds
IMPORTS = advapi32 ole32 oleaut32 uuid
C_SRCS = activeds_main.c
EXTRADLLFLAGS = -Wb,--prefer-native
SOURCES = \
activeds.idl \
activeds_main.c \
pathname.c
/*
* Copyright 2020 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#pragma makedep register
[
helpstring("ADs LDAP Pathname Descriptor Object"),
progid("Pathname"),
uuid(080d0d78-f421-11d0-a36e-00c04fb950dc),
threading(both)
]
coclass Pathname { interface IADsPathname; }
......@@ -22,7 +22,7 @@
26 stub PropVariantToAdsType2
27 stub ConvertSecDescriptorToVariant
28 stub ConvertSecurityDescriptorToSecDes
#@ stub DllCanUnloadNow
#@ stub DllGetClassObject
#@ stub DllRegisterServer
#@ stub DllUnregisterServer
@ stdcall -private DllCanUnloadNow()
@ stdcall -private DllGetClassObject(ptr ptr ptr)
@ stdcall -private DllRegisterServer()
@ stdcall -private DllUnregisterServer()
......@@ -2,6 +2,7 @@
* Implementation of the Active Directory Service Interface
*
* Copyright 2005 Detlef Riekenberg
* Copyright 2019 Dmitry Timoshkov
*
* This file contains only stubs to get the printui.dll up and running
* activeds.dll is much much more than this
......@@ -30,39 +31,26 @@
#include "winuser.h"
#include "objbase.h"
#include "initguid.h"
#include "iads.h"
#include "adshlp.h"
#include "adserr.h"
#include "wine/unicode.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(activeds);
/*****************************************************
* DllMain
*/
BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
{
TRACE("(%p, %d, %p)\n",hinstDLL, fdwReason, lpvReserved);
switch(fdwReason)
{
case DLL_WINE_PREATTACH:
return FALSE; /* prefer native version */
case DLL_PROCESS_ATTACH:
DisableThreadLibraryCalls( hinstDLL );
break;
}
return TRUE;
}
/*****************************************************
* ADsGetObject [ACTIVEDS.3]
*/
HRESULT WINAPI ADsGetObject(LPCWSTR lpszPathName, REFIID riid, VOID** ppObject)
HRESULT WINAPI ADsGetObject(LPCWSTR path, REFIID riid, void **obj)
{
FIXME("(%s)->(%s,%p)!stub\n",debugstr_w(lpszPathName), debugstr_guid(riid), ppObject);
return E_NOTIMPL;
HRESULT hr;
hr = ADsOpenObject(path, NULL, NULL, ADS_SECURE_AUTHENTICATION, riid, obj);
if (hr != S_OK)
hr = ADsOpenObject(path, NULL, NULL, 0, riid, obj);
return hr;
}
/*****************************************************
......@@ -88,17 +76,51 @@ HRESULT WINAPI ADsFreeEnumerator(IEnumVARIANT* pEnumVariant)
*/
HRESULT WINAPI ADsEnumerateNext(IEnumVARIANT* pEnumVariant, ULONG cElements, VARIANT* pvar, ULONG * pcElementsFetched)
{
FIXME("(%p)->(%u, %p, %p)!stub\n",pEnumVariant, cElements, pvar, pcElementsFetched);
FIXME("(%p)->(%lu, %p, %p)!stub\n",pEnumVariant, cElements, pvar, pcElementsFetched);
return E_NOTIMPL;
}
/*****************************************************
* ADsBuildVarArrayStr [ACTIVEDS.7]
*/
HRESULT WINAPI ADsBuildVarArrayStr(LPWSTR *lppPathNames, DWORD dwPathNames, VARIANT* pvar)
HRESULT WINAPI ADsBuildVarArrayStr(LPWSTR *str, DWORD count, VARIANT *var)
{
FIXME("(%p, %d, %p)!stub\n",*lppPathNames, dwPathNames, pvar);
return E_NOTIMPL;
HRESULT hr;
SAFEARRAY *sa;
LONG idx, end = count;
TRACE("(%p, %lu, %p)\n", str, count, var);
if (!var) return E_ADS_BAD_PARAMETER;
sa = SafeArrayCreateVector(VT_VARIANT, 0, count);
if (!sa) return E_OUTOFMEMORY;
VariantInit(var);
for (idx = 0; idx < end; idx++)
{
VARIANT item;
V_VT(&item) = VT_BSTR;
V_BSTR(&item) = SysAllocString(str[idx]);
if (!V_BSTR(&item))
{
hr = E_OUTOFMEMORY;
goto fail;
}
hr = SafeArrayPutElement(sa, &idx, &item);
SysFreeString(V_BSTR(&item));
if (hr != S_OK) goto fail;
}
V_VT(var) = VT_ARRAY | VT_VARIANT;
V_ARRAY(var) = sa;
return S_OK;
fail:
SafeArrayDestroy(sa);
return hr;
}
/*****************************************************
......@@ -106,18 +128,87 @@ HRESULT WINAPI ADsBuildVarArrayStr(LPWSTR *lppPathNames, DWORD dwPathNames, VARI
*/
HRESULT WINAPI ADsBuildVarArrayInt(LPDWORD lpdwObjectTypes, DWORD dwObjectTypes, VARIANT* pvar)
{
FIXME("(%p, %d, %p)!stub\n",lpdwObjectTypes, dwObjectTypes, pvar);
FIXME("(%p, %ld, %p)!stub\n",lpdwObjectTypes, dwObjectTypes, pvar);
return E_NOTIMPL;
}
/*****************************************************
* ADsOpenObject [ACTIVEDS.9]
*/
HRESULT WINAPI ADsOpenObject(LPCWSTR lpszPathName, LPCWSTR lpszUserName, LPCWSTR lpszPassword, DWORD dwReserved, REFIID riid, VOID** ppObject)
HRESULT WINAPI ADsOpenObject(LPCWSTR path, LPCWSTR user, LPCWSTR password, DWORD reserved, REFIID riid, void **obj)
{
FIXME("(%s,%s,%u,%s,%p)!stub\n", debugstr_w(lpszPathName),
debugstr_w(lpszUserName), dwReserved, debugstr_guid(riid), ppObject);
return E_NOTIMPL;
HRESULT hr;
HKEY hkey, hprov;
WCHAR provider[MAX_PATH], progid[MAX_PATH];
DWORD idx = 0;
TRACE("(%s,%s,%lu,%s,%p)\n", debugstr_w(path), debugstr_w(user), reserved, debugstr_guid(riid), obj);
if (!path || !riid || !obj)
return E_INVALIDARG;
hr = E_FAIL;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\ADs\\Providers", 0, KEY_READ, &hkey))
return hr;
for (;;)
{
if (RegEnumKeyW(hkey, idx++, provider, ARRAY_SIZE(provider)))
break;
TRACE("provider %s\n", debugstr_w(provider));
if (!wcsnicmp(path, provider, wcslen(provider)) && path[wcslen(provider)] == ':')
{
LONG size;
if (RegOpenKeyExW(hkey, provider, 0, KEY_READ, &hprov))
break;
size = ARRAY_SIZE(progid);
if (!RegQueryValueW(hprov, NULL, progid, &size))
{
CLSID clsid;
if (CLSIDFromProgID(progid, &clsid) == S_OK)
{
IADsOpenDSObject *adsopen;
IDispatch *disp;
TRACE("ns %s => clsid %s\n", debugstr_w(progid), wine_dbgstr_guid(&clsid));
if (CoCreateInstance(&clsid, 0, CLSCTX_INPROC_SERVER, &IID_IADsOpenDSObject, (void **)&adsopen) == S_OK)
{
BSTR bpath, buser, bpassword;
bpath = SysAllocString(path);
buser = SysAllocString(user);
bpassword = SysAllocString(password);
hr = IADsOpenDSObject_OpenDSObject(adsopen, bpath, buser, bpassword, reserved, &disp);
if (hr == S_OK)
{
hr = IDispatch_QueryInterface(disp, riid, obj);
IDispatch_Release(disp);
}
SysFreeString(bpath);
SysFreeString(buser);
SysFreeString(bpassword);
IADsOpenDSObject_Release(adsopen);
}
}
}
RegCloseKey(hprov);
break;
}
}
RegCloseKey(hkey);
return hr;
}
/*****************************************************
......@@ -125,7 +216,7 @@ HRESULT WINAPI ADsOpenObject(LPCWSTR lpszPathName, LPCWSTR lpszUserName, LPCWSTR
*/
VOID WINAPI ADsSetLastError(DWORD dwErr, LPWSTR pszError, LPWSTR pszProvider)
{
FIXME("(%d,%p,%p)!stub\n", dwErr, pszError, pszProvider);
FIXME("(%ld,%p,%p)!stub\n", dwErr, pszError, pszProvider);
}
/*****************************************************
......@@ -133,7 +224,7 @@ VOID WINAPI ADsSetLastError(DWORD dwErr, LPWSTR pszError, LPWSTR pszProvider)
*/
HRESULT WINAPI ADsGetLastError(LPDWORD perror, LPWSTR errorbuf, DWORD errorbuflen, LPWSTR namebuf, DWORD namebuflen)
{
FIXME("(%p,%p,%d,%p,%d)!stub\n", perror, errorbuf, errorbuflen, namebuf, namebuflen);
FIXME("(%p,%p,%ld,%p,%ld)!stub\n", perror, errorbuf, errorbuflen, namebuf, namebuflen);
return E_NOTIMPL;
}
......@@ -142,8 +233,7 @@ HRESULT WINAPI ADsGetLastError(LPDWORD perror, LPWSTR errorbuf, DWORD errorbufle
*/
LPVOID WINAPI AllocADsMem(DWORD cb)
{
FIXME("(%d)!stub\n",cb);
return NULL;
return malloc(cb);
}
/*****************************************************
......@@ -151,8 +241,8 @@ LPVOID WINAPI AllocADsMem(DWORD cb)
*/
BOOL WINAPI FreeADsMem(LPVOID pMem)
{
FIXME("(%p)!stub\n",pMem);
return FALSE;
free(pMem);
return TRUE;
}
/*****************************************************
......@@ -160,8 +250,7 @@ BOOL WINAPI FreeADsMem(LPVOID pMem)
*/
LPVOID WINAPI ReallocADsMem(LPVOID pOldMem, DWORD cbOld, DWORD cbNew)
{
FIXME("(%p,%d,%d)!stub\n", pOldMem, cbOld, cbNew);
return NULL;
return realloc(pOldMem, cbNew);
}
/*****************************************************
......@@ -169,8 +258,8 @@ LPVOID WINAPI ReallocADsMem(LPVOID pOldMem, DWORD cbOld, DWORD cbNew)
*/
LPWSTR WINAPI AllocADsStr(LPWSTR pStr)
{
FIXME("(%p)!stub\n",pStr);
return NULL;
TRACE("(%p)\n", pStr);
return wcsdup(pStr);
}
/*****************************************************
......@@ -178,8 +267,9 @@ LPWSTR WINAPI AllocADsStr(LPWSTR pStr)
*/
BOOL WINAPI FreeADsStr(LPWSTR pStr)
{
FIXME("(%p)!stub\n",pStr);
return FALSE;
TRACE("(%p)\n", pStr);
return FreeADsMem(pStr);
}
/*****************************************************
......@@ -196,6 +286,6 @@ BOOL WINAPI ReallocADsStr(LPWSTR *ppStr, LPWSTR pStr)
*/
HRESULT WINAPI ADsEncodeBinaryData(PBYTE pbSrcData, DWORD dwSrcLen, LPWSTR *ppszDestData)
{
FIXME("(%p,%d,%p)!stub\n", pbSrcData, dwSrcLen, *ppszDestData);
FIXME("(%p,%ld,%p)!stub\n", pbSrcData, dwSrcLen, *ppszDestData);
return E_NOTIMPL;
}
/*
* Copyright 2020 Dmitry Timoshkov
*
* This file contains only stubs to get the printui.dll up and running
* activeds.dll is much much more than this
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "iads.h"
#include "adserr.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(activeds);
#include "initguid.h"
DEFINE_GUID(CLSID_Pathname,0x080d0d78,0xf421,0x11d0,0xa3,0x6e,0x00,0xc0,0x4f,0xb9,0x50,0xdc);
typedef struct
{
IADsPathname IADsPathname_iface;
LONG ref;
BSTR provider, server, dn;
} Pathname;
static inline Pathname *impl_from_IADsPathname(IADsPathname *iface)
{
return CONTAINING_RECORD(iface, Pathname, IADsPathname_iface);
}
static HRESULT WINAPI path_QueryInterface(IADsPathname *iface, REFIID riid, void **obj)
{
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
if (!riid || !obj) return E_INVALIDARG;
if (IsEqualGUID(riid, &IID_IUnknown) ||
IsEqualGUID(riid, &IID_IDispatch) ||
IsEqualGUID(riid, &IID_IADsPathname))
{
IADsPathname_AddRef(iface);
*obj = iface;
return S_OK;
}
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI path_AddRef(IADsPathname *iface)
{
Pathname *path = impl_from_IADsPathname(iface);
return InterlockedIncrement(&path->ref);
}
static ULONG WINAPI path_Release(IADsPathname *iface)
{
Pathname *path = impl_from_IADsPathname(iface);
LONG ref = InterlockedDecrement(&path->ref);
if (!ref)
{
TRACE("destroying %p\n", iface);
SysFreeString(path->provider);
SysFreeString(path->server);
SysFreeString(path->dn);
free(path);
}
return ref;
}
static HRESULT WINAPI path_GetTypeInfoCount(IADsPathname *iface, UINT *count)
{
FIXME("%p,%p: stub\n", iface, count);
return E_NOTIMPL;
}
static HRESULT WINAPI path_GetTypeInfo(IADsPathname *iface, UINT index, LCID lcid, ITypeInfo **info)
{
FIXME("%p,%u,%#lx,%p: stub\n", iface, index, lcid, info);
return E_NOTIMPL;
}
static HRESULT WINAPI path_GetIDsOfNames(IADsPathname *iface, REFIID riid, LPOLESTR *names,
UINT count, LCID lcid, DISPID *dispid)
{
FIXME("%p,%s,%p,%u,%lu,%p: stub\n", iface, debugstr_guid(riid), names, count, lcid, dispid);
return E_NOTIMPL;
}
static HRESULT WINAPI path_Invoke(IADsPathname *iface, DISPID dispid, REFIID riid, LCID lcid, WORD flags,
DISPPARAMS *params, VARIANT *result, EXCEPINFO *excepinfo, UINT *argerr)
{
FIXME("%p,%ld,%s,%04lx,%04x,%p,%p,%p,%p: stub\n", iface, dispid, debugstr_guid(riid), lcid, flags,
params, result, excepinfo, argerr);
return E_NOTIMPL;
}
static HRESULT parse_path(BSTR path, BSTR *provider, BSTR *server, BSTR *dn)
{
WCHAR *p, *p_server;
int server_len;
*provider = NULL;
*server = NULL;
*dn = NULL;
if (wcsnicmp(path, L"LDAP:", 5) != 0)
return E_ADS_BAD_PATHNAME;
*provider = SysAllocStringLen(path, 4);
if (!*provider) return E_OUTOFMEMORY;
p = path + 5;
if (!*p) return S_OK;
if (*p++ != '/' || *p++ != '/' || !*p)
{
SysFreeString(*provider);
return E_ADS_BAD_PATHNAME;
}
p_server = p;
server_len = 0;
while (*p && *p != '/')
{
p++;
server_len++;
}
if (server_len == 0)
{
SysFreeString(*provider);
return E_ADS_BAD_PATHNAME;
}
*server = SysAllocStringLen(p_server, server_len);
if (!*server)
{
SysFreeString(*provider);
return E_OUTOFMEMORY;
}
if (!*p) return S_OK;
if (*p++ != '/' || !*p)
{
SysFreeString(*provider);
SysFreeString(*server);
return E_ADS_BAD_PATHNAME;
}
*dn = SysAllocString(p);
if (!*dn)
{
SysFreeString(*provider);
SysFreeString(*server);
return E_OUTOFMEMORY;
}
return S_OK;
}
static HRESULT WINAPI path_Set(IADsPathname *iface, BSTR adspath, LONG type)
{
Pathname *path = impl_from_IADsPathname(iface);
HRESULT hr;
BSTR provider, server, dn;
TRACE("%p,%s,%ld\n", iface, debugstr_w(adspath), type);
if (!adspath) return E_INVALIDARG;
if (type == ADS_SETTYPE_PROVIDER)
{
SysFreeString(path->provider);
path->provider = SysAllocString(adspath);
return path->provider ? S_OK : E_OUTOFMEMORY;
}
if (type == ADS_SETTYPE_SERVER)
{
SysFreeString(path->server);
path->server = SysAllocString(adspath);
return path->server ? S_OK : E_OUTOFMEMORY;
}
if (type == ADS_SETTYPE_DN)
{
SysFreeString(path->dn);
path->dn = SysAllocString(adspath);
return path->dn ? S_OK : E_OUTOFMEMORY;
}
if (type != ADS_SETTYPE_FULL)
{
FIXME("type %ld not implemented\n", type);
return E_INVALIDARG;
}
hr = parse_path(adspath, &provider, &server, &dn);
if (hr == S_OK)
{
SysFreeString(path->provider);
SysFreeString(path->server);
SysFreeString(path->dn);
path->provider = provider;
path->server = server;
path->dn = dn;
}
return hr;
}
static HRESULT WINAPI path_SetDisplayType(IADsPathname *iface, LONG type)
{
FIXME("%p,%ld: stub\n", iface, type);
return E_NOTIMPL;
}
static HRESULT WINAPI path_Retrieve(IADsPathname *iface, LONG type, BSTR *adspath)
{
Pathname *path = impl_from_IADsPathname(iface);
int len;
TRACE("%p,%ld,%p\n", iface, type, adspath);
if (!adspath) return E_INVALIDARG;
switch (type)
{
default:
FIXME("type %ld not implemented\n", type);
/* fall through */
case ADS_FORMAT_X500:
len = wcslen(path->provider) + 3;
if (path->server) len += wcslen(path->server) + 1;
if (path->dn) len += wcslen(path->dn);
*adspath = SysAllocStringLen(NULL, len);
if (!*adspath) break;
wcscpy(*adspath, path->provider);
wcscat(*adspath, L"://");
if (path->server)
{
wcscat(*adspath, path->server);
wcscat(*adspath, L"/");
}
if (path->dn) wcscat(*adspath, path->dn);
break;
case ADS_FORMAT_PROVIDER:
*adspath = SysAllocString(path->provider);
break;
case ADS_FORMAT_SERVER:
*adspath = path->provider ? SysAllocString(path->server) : SysAllocStringLen(NULL, 0);
break;
case ADS_FORMAT_X500_DN:
*adspath = path->dn ? SysAllocString(path->dn) : SysAllocStringLen(NULL, 0);
break;
case ADS_FORMAT_LEAF:
if (!path->dn)
*adspath = SysAllocStringLen(NULL, 0);
else
{
WCHAR *p = wcschr(path->dn, ',');
*adspath = p ? SysAllocStringLen(path->dn, p - path->dn) : SysAllocString(path->dn);
}
break;
}
TRACE("=> %s\n", debugstr_w(*adspath));
return *adspath ? S_OK : E_OUTOFMEMORY;
}
static HRESULT WINAPI path_GetNumElements(IADsPathname *iface, LONG *count)
{
Pathname *path = impl_from_IADsPathname(iface);
WCHAR *p;
TRACE("%p,%p\n", iface, count);
if (!count) return E_INVALIDARG;
*count = 0;
p = path->dn;
while (p)
{
*count += 1;
p = wcschr(p, ',');
if (p) p++;
}
return S_OK;
}
static HRESULT WINAPI path_GetElement(IADsPathname *iface, LONG index, BSTR *element)
{
Pathname *path = impl_from_IADsPathname(iface);
HRESULT hr;
WCHAR *p, *end;
LONG count;
TRACE("%p,%ld,%p\n", iface, index, element);
if (!element) return E_INVALIDARG;
count = 0;
hr = HRESULT_FROM_WIN32(ERROR_INVALID_INDEX);
p = path->dn;
while (p)
{
end = wcschr(p, ',');
if (index == count)
{
*element = end ? SysAllocStringLen(p, end - p) : SysAllocString(p);
hr = *element ? S_OK : E_OUTOFMEMORY;
break;
}
p = end ? end + 1 : NULL;
count++;
}
return hr;
}
static HRESULT WINAPI path_AddLeafElement(IADsPathname *iface, BSTR element)
{
FIXME("%p,%s: stub\n", iface, debugstr_w(element));
return E_NOTIMPL;
}
static HRESULT WINAPI path_RemoveLeafElement(IADsPathname *iface)
{
FIXME("%p: stub\n", iface);
return E_NOTIMPL;
}
static HRESULT WINAPI path_CopyPath(IADsPathname *iface, IDispatch **path)
{
FIXME("%p,%p: stub\n", iface, path);
return E_NOTIMPL;
}
static HRESULT WINAPI path_GetEscapedElement(IADsPathname *iface, LONG reserved, BSTR element, BSTR *str)
{
FIXME("%p,%ld,%s,%p: stub\n", iface, reserved, debugstr_w(element), str);
return E_NOTIMPL;
}
static HRESULT WINAPI path_get_EscapedMode(IADsPathname *iface, LONG *mode)
{
FIXME("%p,%p: stub\n", iface, mode);
return E_NOTIMPL;
}
static HRESULT WINAPI path_put_EscapedMode(IADsPathname *iface, LONG mode)
{
FIXME("%p,%ld: stub\n", iface, mode);
return E_NOTIMPL;
}
static const IADsPathnameVtbl IADsPathname_vtbl =
{
path_QueryInterface,
path_AddRef,
path_Release,
path_GetTypeInfoCount,
path_GetTypeInfo,
path_GetIDsOfNames,
path_Invoke,
path_Set,
path_SetDisplayType,
path_Retrieve,
path_GetNumElements,
path_GetElement,
path_AddLeafElement,
path_RemoveLeafElement,
path_CopyPath,
path_GetEscapedElement,
path_get_EscapedMode,
path_put_EscapedMode
};
static HRESULT Pathname_create(REFIID riid, void **obj)
{
Pathname *path;
HRESULT hr;
path = malloc(sizeof(*path));
if (!path) return E_OUTOFMEMORY;
path->IADsPathname_iface.lpVtbl = &IADsPathname_vtbl;
path->ref = 1;
path->provider = SysAllocString(L"LDAP");
path->server = NULL;
path->dn = NULL;
hr = IADsPathname_QueryInterface(&path->IADsPathname_iface, riid, obj);
IADsPathname_Release(&path->IADsPathname_iface);
return hr;
}
static const struct class_info
{
const CLSID *clsid;
HRESULT (*constructor)(REFIID, void **);
} class_info[] =
{
{ &CLSID_Pathname, Pathname_create }
};
typedef struct
{
IClassFactory IClassFactory_iface;
LONG ref;
const struct class_info *info;
} class_factory;
static inline class_factory *impl_from_IClassFactory(IClassFactory *iface)
{
return CONTAINING_RECORD(iface, class_factory, IClassFactory_iface);
}
static HRESULT WINAPI factory_QueryInterface(IClassFactory *iface, REFIID riid, LPVOID *obj)
{
TRACE("%p,%s,%p\n", iface, debugstr_guid(riid), obj);
if (!riid || !obj) return E_INVALIDARG;
if (IsEqualIID(riid, &IID_IUnknown) ||
IsEqualIID(riid, &IID_IClassFactory))
{
IClassFactory_AddRef(iface);
*obj = iface;
return S_OK;
}
*obj = NULL;
FIXME("interface %s is not implemented\n", debugstr_guid(riid));
return E_NOINTERFACE;
}
static ULONG WINAPI factory_AddRef(IClassFactory *iface)
{
class_factory *factory = impl_from_IClassFactory(iface);
ULONG ref = InterlockedIncrement(&factory->ref);
TRACE("(%p) ref %lu\n", iface, ref);
return ref;
}
static ULONG WINAPI factory_Release(IClassFactory *iface)
{
class_factory *factory = impl_from_IClassFactory(iface);
ULONG ref = InterlockedDecrement(&factory->ref);
TRACE("(%p) ref %lu\n", iface, ref);
if (!ref)
free(factory);
return ref;
}
static HRESULT WINAPI factory_CreateInstance(IClassFactory *iface, IUnknown *outer, REFIID riid, void **obj)
{
class_factory *factory = impl_from_IClassFactory(iface);
TRACE("%p,%s,%p\n", outer, debugstr_guid(riid), obj);
if (!riid || !obj) return E_INVALIDARG;
*obj = NULL;
if (outer) return CLASS_E_NOAGGREGATION;
return factory->info->constructor(riid, obj);
}
static HRESULT WINAPI factory_LockServer(IClassFactory *iface, BOOL lock)
{
FIXME("%p,%d: stub\n", iface, lock);
return S_OK;
}
static const struct IClassFactoryVtbl factory_vtbl =
{
factory_QueryInterface,
factory_AddRef,
factory_Release,
factory_CreateInstance,
factory_LockServer
};
static HRESULT factory_constructor(const struct class_info *info, REFIID riid, void **obj)
{
class_factory *factory;
HRESULT hr;
factory = malloc(sizeof(*factory));
if (!factory) return E_OUTOFMEMORY;
factory->IClassFactory_iface.lpVtbl = &factory_vtbl;
factory->ref = 1;
factory->info = info;
hr = IClassFactory_QueryInterface(&factory->IClassFactory_iface, riid, obj);
IClassFactory_Release(&factory->IClassFactory_iface);
return hr;
}
HRESULT WINAPI DllGetClassObject(REFCLSID clsid, REFIID iid, LPVOID *obj)
{
int i;
TRACE("%s,%s,%p\n", debugstr_guid(clsid), debugstr_guid(iid), obj);
if (!clsid || !iid || !obj) return E_INVALIDARG;
*obj = NULL;
for (i = 0; i < ARRAY_SIZE(class_info); i++)
{
if (IsEqualCLSID(class_info[i].clsid, clsid))
return factory_constructor(&class_info[i], iid, obj);
}
FIXME("class %s/%s is not implemented\n", debugstr_guid(clsid), debugstr_guid(iid));
return CLASS_E_CLASSNOTAVAILABLE;
}
TESTDLL = activeds.dll
IMPORTS = ole32 oleaut32 activeds
SOURCES = \
activeds.c
/*
* Copyright 2020 Dmitry Timoshkov
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include <stdarg.h>
#include <stdio.h>
#define COBJMACROS
#include "windef.h"
#include "winbase.h"
#include "objbase.h"
#include "initguid.h"
#include "iads.h"
#include "adshlp.h"
#include "adserr.h"
#include "wine/test.h"
DEFINE_GUID(CLSID_Pathname,0x080d0d78,0xf421,0x11d0,0xa3,0x6e,0x00,0xc0,0x4f,0xb9,0x50,0xdc);
static void test_ADsBuildVarArrayStr(void)
{
const WCHAR *props[] = { L"prop1", L"prop2" };
HRESULT hr;
VARIANT var, item, *data;
LONG start, end, idx;
hr = ADsBuildVarArrayStr(NULL, 0, NULL);
ok(hr == E_ADS_BAD_PARAMETER || hr == E_FAIL /* XP */, "got %#lx\n", hr);
hr = ADsBuildVarArrayStr(NULL, 0, &var);
ok(hr == S_OK, "got %#lx\n", hr);
ok(V_VT(&var) == (VT_ARRAY | VT_VARIANT), "got %d\n", V_VT(&var));
start = 0xdeadbeef;
hr = SafeArrayGetLBound(V_ARRAY(&var), 1, &start);
ok(hr == S_OK, "got %#lx\n", hr);
ok(start == 0, "got %ld\n", start);
end = 0xdeadbeef;
hr = SafeArrayGetUBound(V_ARRAY(&var), 1, &end);
ok(hr == S_OK, "got %#lx\n", hr);
ok(end == -1, "got %ld\n", end);
VariantClear(&var);
hr = ADsBuildVarArrayStr((LPWSTR *)props, ARRAY_SIZE(props), &var);
ok(hr == S_OK, "got %#lx\n", hr);
ok(V_VT(&var) == (VT_ARRAY | VT_VARIANT), "got %d\n", V_VT(&var));
start = 0xdeadbeef;
hr = SafeArrayGetLBound(V_ARRAY(&var), 1, &start);
ok(hr == S_OK, "got %#lx\n", hr);
ok(start == 0, "got %ld\n", start);
end = 0xdeadbeef;
hr = SafeArrayGetUBound(V_ARRAY(&var), 1, &end);
ok(hr == S_OK, "got %#lx\n", hr);
ok(end == 1, "got %ld\n", end);
idx = 0;
hr = SafeArrayGetElement(V_ARRAY(&var), &idx, &item);
ok(hr == S_OK, "got %#lx\n", hr);
ok(V_VT(&item) == VT_BSTR, "got %d\n", V_VT(&item));
ok(!lstrcmpW(V_BSTR(&item), L"prop1"), "got %s\n", wine_dbgstr_w(V_BSTR(&item)));
VariantClear(&item);
hr = SafeArrayAccessData(V_ARRAY(&var), (void *)&data);
ok(hr == S_OK, "got %#lx\n", hr);
ok(V_VT(&data[0]) == VT_BSTR, "got %d\n", V_VT(&data[0]));
ok(!lstrcmpW(V_BSTR(&data[0]), L"prop1"), "got %s\n", wine_dbgstr_w(V_BSTR(&data[0])));
ok(V_VT(&data[0]) == VT_BSTR, "got %d\n", V_VT(&data[0]));
ok(!lstrcmpW(V_BSTR(&data[1]), L"prop2"), "got %s\n", wine_dbgstr_w(V_BSTR(&data[1])));
hr = SafeArrayUnaccessData(V_ARRAY(&var));
ok(hr == S_OK, "got %#lx\n", hr);
VariantClear(&var);
}
static void test_Pathname(void)
{
static const WCHAR * const elem[3] = { L"a=b",L"c=d",L"e=f" };
HRESULT hr;
IADsPathname *path;
BSTR bstr;
LONG count, i;
hr = CoCreateInstance(&CLSID_Pathname, 0, CLSCTX_INPROC_SERVER, &IID_IADsPathname, (void **)&path);
ok(hr == S_OK, "got %#lx\n", hr);
count = 0xdeadbeef;
hr = IADsPathname_GetNumElements(path, &count);
ok(hr == S_OK, "got %#lx\n", hr);
ok(count == 0, "got %ld\n", count);
bstr = NULL;
hr = IADsPathname_Retrieve(path, ADS_FORMAT_X500, &bstr);
ok(hr == S_OK, "got %#lx\n", hr);
ok(bstr && !wcscmp(bstr, L"LDAP://"), "got %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
bstr = SysAllocString(L"LDAP://sample");
hr = IADsPathname_Set(path, bstr, ADS_SETTYPE_FULL);
ok(hr == S_OK, "got %#lx\n", hr);
SysFreeString(bstr);
count = 0xdeadbeef;
hr = IADsPathname_GetNumElements(path, &count);
ok(hr == S_OK, "got %#lx\n", hr);
ok(count == 0, "got %ld\n", count);
hr = IADsPathname_GetElement(path, 0, &bstr);
ok(hr == HRESULT_FROM_WIN32(ERROR_INVALID_INDEX), "got %#lx\n", hr);
SysFreeString(bstr);
bstr = SysAllocString(L"LDAP://sample:123/a=b,c=d,e=f");
hr = IADsPathname_Set(path, bstr, ADS_SETTYPE_FULL);
ok(hr == S_OK, "got %#lx\n", hr);
SysFreeString(bstr);
count = 0xdeadbeef;
hr = IADsPathname_GetNumElements(path, &count);
ok(hr == S_OK, "got %#lx\n", hr);
ok(count == 3, "got %ld\n", count);
for (i = 0; i < count; i++)
{
hr = IADsPathname_GetElement(path, i, &bstr);
ok(hr == S_OK, "got %#lx\n", hr);
ok(!wcscmp(bstr, elem[i]), "%lu: %s\n", i, wine_dbgstr_w(bstr));
SysFreeString(bstr);
}
hr = IADsPathname_Retrieve(path, ADS_FORMAT_X500, &bstr);
ok(hr == S_OK, "got %#lx\n", hr);
ok(!wcscmp(bstr, L"LDAP://sample:123/a=b,c=d,e=f"), "got %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
hr = IADsPathname_Retrieve(path, ADS_FORMAT_PROVIDER, &bstr);
ok(hr == S_OK, "got %#lx\n", hr);
ok(!wcscmp(bstr, L"LDAP"), "got %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
hr = IADsPathname_Retrieve(path, ADS_FORMAT_SERVER, &bstr);
ok(hr == S_OK, "got %#lx\n", hr);
ok(!wcscmp(bstr, L"sample:123"), "got %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
hr = IADsPathname_Retrieve(path, ADS_FORMAT_LEAF, &bstr);
ok(hr == S_OK, "got %#lx\n", hr);
ok(!wcscmp(bstr, L"a=b"), "got %s\n", wine_dbgstr_w(bstr));
SysFreeString(bstr);
IADsPathname_Release(path);
}
START_TEST(activeds)
{
CoInitialize(NULL);
test_Pathname();
test_ADsBuildVarArrayStr();
CoUninitialize();
}
MODULE = actxprxy.dll
IMPORTS = uuid oleaut32 ole32 rpcrt4
C_SRCS = \
usrmarshal.c
IDL_SRCS = \
SOURCES = \
actxprxy_activscp.idl \
actxprxy_comcat.idl \
actxprxy_docobj.idl \
......@@ -16,6 +13,7 @@ IDL_SRCS = \
actxprxy_servprov.idl \
actxprxy_shldisp.idl \
actxprxy_shobjidl.idl \
actxprxy_urlhist.idl
actxprxy_urlhist.idl \
usrmarshal.c
dlldata_EXTRADEFS = -DWINE_REGISTER_DLL -DPROXY_DELEGATION
......@@ -27,4 +27,4 @@
threading(both),
uuid(b8da6310-e19b-11d0-933c-00a0c90dcaa9) /* IActiveScriptStats */
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }
......@@ -27,4 +27,4 @@
threading(both),
uuid(b8da6310-e19b-11d0-933c-00a0c90dcaa9) /* IActiveScriptStats */
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }
......@@ -27,4 +27,4 @@
threading(both),
uuid(b8da6310-e19b-11d0-933c-00a0c90dcaa9) /* IActiveScriptStats */
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }
......@@ -27,4 +27,4 @@
threading(both),
uuid(b8da6310-e19b-11d0-933c-00a0c90dcaa9) /* IActiveScriptStats */
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }
......@@ -27,4 +27,4 @@
threading(both),
uuid(b8da6310-e19b-11d0-933c-00a0c90dcaa9) /* IActiveScriptStats */
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }
......@@ -27,4 +27,4 @@
threading(both),
uuid(b8da6310-e19b-11d0-933c-00a0c90dcaa9) /* IActiveScriptStats */
]
coclass PSFactoryBuffer { interface IFactoryBuffer; }
coclass PSFactoryBuffer { interface IPSFactoryBuffer; }