added HKEY_CLASSES_ROOT MSRPC open call. reg_open_hkcr etc. supported
authorLuke Leighton <lkcl@samba.org>
Fri, 29 Oct 1999 16:24:11 +0000 (16:24 +0000)
committerLuke Leighton <lkcl@samba.org>
Fri, 29 Oct 1999 16:24:11 +0000 (16:24 +0000)
in rpcclient, regenum HKEY_CLASSES_ROOT or regenum HKCR to test.

source/include/proto.h
source/include/rpc_reg.h
source/lib/util.c
source/rpc_client/cli_reg.c
source/rpc_parse/parse_reg.c

index e83e0320deac5a1a9eae63c4a4fa158aec4224c0..74d81ad7f18b8aa022985a080741c6d0c629bcbe 100644 (file)
@@ -1816,6 +1816,8 @@ void cli_nt_session_close(struct cli_state *cli, uint16 nt_pipe_fnum);
 
 BOOL do_reg_connect(struct cli_state *cli, uint16 fnum, char *full_keyname, char *key_name,
                                POLICY_HND *reg_hnd);
+BOOL do_reg_open_hkcr(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+                               POLICY_HND *hnd);
 BOOL do_reg_open_hklm(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
                                POLICY_HND *hnd);
 BOOL do_reg_open_hku(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
@@ -2334,6 +2336,10 @@ BOOL _prs_uint32_post(char *name, prs_struct *ps, int depth, uint32 *data32,
 
 /*The following definitions come from  rpc_parse/parse_reg.c  */
 
+BOOL make_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
+                               uint16 unknown_0, uint32 level);
+BOOL reg_io_q_open_hkcr(char *desc,  REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth);
+BOOL reg_io_r_open_hkcr(char *desc,  REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth);
 BOOL make_reg_q_open_hklm(REG_Q_OPEN_HKLM *q_o,
                                uint16 unknown_0, uint32 level);
 BOOL reg_io_q_open_hklm(char *desc,  REG_Q_OPEN_HKLM *r_q, prs_struct *ps, int depth);
@@ -3245,7 +3251,7 @@ BOOL sam_query_groupmem(struct cli_state *cli, uint16 fnum,
 uint32 msrpc_sam_enum_groups(struct client_info *info,
                                struct acct_info **sam,
                                uint32 *num_sam_entries,
-                               BOOL request_member_info,
+                               void(*grp_mem_fn)(uint32, char*, uint32, uint32*, char**, uint32*),
                                BOOL request_group_info);
 void cmd_sam_enum_groups(struct client_info *info);
 
index cc163540d73f78584bbf17e35974e42620da4d12..f74856193dbc86e57d50b468cc063bdf7ef5372f 100644 (file)
@@ -26,6 +26,7 @@
 
 
 /* winreg pipe defines */
+#define REG_OPEN_HKCR       0x00
 #define REG_OPEN_HKLM       0x02
 #define REG_OPEN_HKU        0x04
 #define REG_FLUSH_KEY       0x0B
 #define REG_CLOSE           0x05
 #define REG_SHUTDOWN        0x18
 
-#define HKEY_LOCAL_MACHINE 0x80000000
+#define HKEY_CLASSES_ROOT  0x80000000
+#define HKEY_CURRENT_USER  0x80000001
+#define HKEY_LOCAL_MACHINE 0x80000002
 #define HKEY_USERS         0x80000003
 
+/* REG_Q_OPEN_HKCR   */
+typedef struct q_reg_open_hkcr_info
+{
+       uint32 ptr;
+       uint16 unknown_0; /* 0x5428      - 16 bit unknown */
+       uint16 unknown_1; /* random.  changes */
+       uint32 level;     /* 0x0200 0000 */
+
+} REG_Q_OPEN_HKCR;
+
+/* REG_R_OPEN_HKCR   */
+typedef struct r_reg_open_hkcr_info
+{
+       POLICY_HND pol;       /* policy handle */
+       uint32 status;         /* return status */
+
+} REG_R_OPEN_HKCR;
+
+
 /* REG_Q_OPEN_HKLM   */
-typedef struct q_reg_open_policy_info
+typedef struct q_reg_open_hklm_info
 {
        uint32 ptr;
        uint16 unknown_0; /* 0xE084      - 16 bit unknown */
@@ -58,7 +80,7 @@ typedef struct q_reg_open_policy_info
 } REG_Q_OPEN_HKLM  ;
 
 /* REG_R_OPEN_HKLM   */
-typedef struct r_reg_open_policy_info
+typedef struct r_reg_open_hklm_info
 {
        POLICY_HND pol;       /* policy handle */
        uint32 status;         /* return status */
@@ -67,7 +89,7 @@ typedef struct r_reg_open_policy_info
 
 
 /* REG_Q_OPEN_HKU */
-typedef struct q_reg_open_unk4_info
+typedef struct q_reg_open_hku_info
 {
        uint32 ptr;
        uint16 unknown_0; /* 0xE084      - 16 bit unknown */
@@ -77,7 +99,7 @@ typedef struct q_reg_open_unk4_info
 } REG_Q_OPEN_HKU;
 
 /* REG_R_OPEN_HKU */
-typedef struct r_reg_open_unk4_info
+typedef struct r_reg_open_hku_info
 {
        POLICY_HND pol;       /* policy handle */
        uint32 status;         /* return status */
index 8afa2f8c017bcf4ca4fb101d4af05260534f611d..bd93b01341894cb0101f6682239e53f11c9fdec1 100644 (file)
@@ -3139,7 +3139,15 @@ BOOL reg_split_key(char *full_keyname, uint32 *reg_type, char *key_name)
 
        DEBUG(10, ("reg_split_key: hive %s\n", tmp));
 
-       if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
+       if (strequal(tmp, "HKCR") || strequal(tmp, "HKEY_CLASSES_ROOT"))
+       {
+               (*reg_type) = HKEY_CLASSES_ROOT;
+       }
+       else if (strequal(tmp, "HKCU") || strequal(tmp, "HKEY_CURRENT_USER"))
+       {
+               (*reg_type) = HKEY_CURRENT_USER;
+       }
+       else if (strequal(tmp, "HKLM") || strequal(tmp, "HKEY_LOCAL_MACHINE"))
        {
                (*reg_type) = HKEY_LOCAL_MACHINE;
        }
index cbbd6e57bffa845d0cb8711f2c1da1b6e003f1e1..49423beaa56ed17fb27a19bffbcaeab7fd104c79 100644 (file)
@@ -59,6 +59,14 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum, char *full_keyname, char
 
        switch (reg_type)
        {
+               case HKEY_CLASSES_ROOT:
+               {
+                       res = res ? do_reg_open_hkcr(cli, fnum,
+                                       0x5428, 0x02000000,
+                                       reg_hnd) : False;
+                       break;
+               }
+       
                case HKEY_LOCAL_MACHINE:
                {
                        res = res ? do_reg_open_hklm(cli, fnum,
@@ -84,6 +92,63 @@ BOOL do_reg_connect(struct cli_state *cli, uint16 fnum, char *full_keyname, char
        return res;
 }
 
+/****************************************************************************
+do a REG Open Policy
+****************************************************************************/
+BOOL do_reg_open_hkcr(struct cli_state *cli, uint16 fnum, uint16 unknown_0, uint32 level,
+                               POLICY_HND *hnd)
+{
+       prs_struct rbuf;
+       prs_struct buf; 
+       REG_Q_OPEN_HKCR q_o;
+       BOOL valid_pol = False;
+
+       if (hnd == NULL) return False;
+
+       prs_init(&buf , 1024, 4, SAFETY_MARGIN, False);
+       prs_init(&rbuf, 0   , 4, SAFETY_MARGIN, True );
+
+       /* create and send a MSRPC command with api REG_OPEN_HKCR */
+
+       DEBUG(4,("REG Open HKCR\n"));
+
+       make_reg_q_open_hkcr(&q_o, unknown_0, level);
+
+       /* turn parameters into data stream */
+       reg_io_q_open_hkcr("", &q_o, &buf, 0);
+
+       /* send the data on \PIPE\ */
+       if (rpc_api_pipe_req(cli, fnum, REG_OPEN_HKCR, &buf, &rbuf))
+       {
+               REG_R_OPEN_HKCR r_o;
+               BOOL p;
+
+               ZERO_STRUCT(r_o);
+
+               reg_io_r_open_hkcr("", &r_o, &rbuf, 0);
+               p = rbuf.offset != 0;
+
+               if (p && r_o.status != 0)
+               {
+                       /* report error code */
+                       DEBUG(0,("REG_OPEN_HKCR: %s\n", get_nt_error_msg(r_o.status)));
+                       p = False;
+               }
+
+               if (p)
+               {
+                       /* ok, at last: we're happy. return the policy handle */
+                       memcpy(hnd, r_o.pol.data, sizeof(hnd->data));
+                       valid_pol = True;
+               }
+       }
+
+       prs_mem_free(&rbuf);
+       prs_mem_free(&buf );
+
+       return valid_pol;
+}
+
 /****************************************************************************
 do a REG Open Policy
 ****************************************************************************/
index 9c6ec61716790f4ed0ad1310139ec44caa3c08d0..01776974fdaa6fbe74b9f296fe1294f77925277c 100644 (file)
 extern int DEBUGLEVEL;
 
 
+/*******************************************************************
+creates a structure.
+********************************************************************/
+BOOL make_reg_q_open_hkcr(REG_Q_OPEN_HKCR *q_o,
+                               uint16 unknown_0, uint32 level)
+{
+       q_o->ptr = 1;
+       q_o->unknown_0 = unknown_0;
+       q_o->unknown_1 = 0x0; /* random - changes */
+       q_o->level = level;
+
+       return True;
+}
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_q_open_hkcr(char *desc,  REG_Q_OPEN_HKCR *r_q, prs_struct *ps, int depth)
+{
+       if (r_q == NULL) return False;
+
+       prs_debug(ps, depth, desc, "reg_io_q_open_hkcr");
+       depth++;
+
+       prs_align(ps);
+       
+       prs_uint32("ptr      ", ps, depth, &(r_q->ptr      ));
+       if (r_q->ptr != 0)
+       {
+               prs_uint16("unknown_0", ps, depth, &(r_q->unknown_0));
+               prs_uint16("unknown_1", ps, depth, &(r_q->unknown_1));
+               prs_uint32("level    ", ps, depth, &(r_q->level    ));
+       }
+
+       return True;
+}
+
+
+/*******************************************************************
+reads or writes a structure.
+********************************************************************/
+BOOL reg_io_r_open_hkcr(char *desc,  REG_R_OPEN_HKCR *r_r, prs_struct *ps, int depth)
+{
+       if (r_r == NULL) return False;
+
+       prs_debug(ps, depth, desc, "reg_io_r_open_hkcr");
+       depth++;
+
+       prs_align(ps);
+       
+       smb_io_pol_hnd("", &(r_r->pol), ps, depth);
+
+       prs_uint32("status", ps, depth, &(r_r->status));
+
+       return True;
+}
+
+
 /*******************************************************************
 creates a structure.
 ********************************************************************/