Ejemplo n.º 1
0
/*=============================================================================
  Function Name : init_target_structure
  Description   : Read target structure (size etc.) from config file and reads
                  target concentration array etc.
                  First, we need to read the config file about how large the
                  target is, how many cells and so on... .
                  Then we can initialze the target arrays, and then finally read
                  in the composition matrix.

  Inputs  : char* file_name
  Outputs : no.

  Notes :
      TODO: free arrays
      Function call:
        fileio - int read_init_file (int (*read_data_block) (char* block_name),
                            int (*read_data) (char* par_name, char* par_value),
                            char* file_name);
                 int read_float_file_into_array (char* file_name, float* target_array,
                            int count, int file_type)
        util - void get_float_one_bit_smaller (float* flt_input, float* flt_output);
        csg  - int read_csg_shape ();
        fetm - int read_fetm_shape ().
=============================================================================*/
int init_target_structure (char *file_name) {
    int i, j, result;
#ifndef MPI_PRALLEL
    /* MPI=============================================== */
    unsigned long int lui_temp = 0;
    /* MPI=============================================== */
#endif

#ifdef MPI_PRALLEL
    /* MPI=============================================== */
    if (my_node==ROOT && print_level>=0) printf ("Initializing target.\n");
    /* MPI=============================================== */
#else
    if (print_level >= 0) printf ("Initializing target.\n");
#endif

    /* set some default values */
    use_density_mult = 0;

    /* read structure definition file */  /* (1) - (8) - (1) */
    result = read_init_file (read_target_structure_data_block, read_target_structure_data, file_name);
    if (result != 0) return result;
#ifdef MPI_PRALLEL
    /* MPI=============================================== */
    if (my_node==ROOT && print_level>=0) printf ("Target structure definition file: %s\n", file_name);
    /* MPI=============================================== */
#else
    if (print_level >= 0) printf ("Target structure definition file: %s\n", file_name);
#endif

    /* Right hand coordinate system: x-axis vertical to target surface (point into substrate),
       y,z-axises parallel to target surface. Uniform cell is only for the special target, for
       the substrate regions outside of the target region, nonuniform cells will be used or do
       not be counted. Or, this cell group is indepedent of the geomentry cell group, so the
       range of this cell group can be changed arbitrarily. */
    layer_count_yz = cell_count_y   * cell_count_z;
    cell_count     = layer_count_yz * cell_count_x;
    target_size_x  = cell_count_x   * cell_size_x;
    target_size_y  = cell_count_y   * cell_size_y;
    target_size_z  = cell_count_z   * cell_size_z;

    /* for nodes in msh module */
    node_x = cell_count_x + 1;
    node_y = cell_count_y + 1;
    node_z = cell_count_z + 1;
    node_yz = node_y * node_z;
    node_count = node_x * node_yz;

    /* we sometimes need a float that is one bit smaller than the targetsize itself */
    get_float_one_bit_smaller (&target_size_x, &target_max_x);
    get_float_one_bit_smaller (&target_size_y, &target_max_y);
    get_float_one_bit_smaller (&target_size_z, &target_max_z);

    cell_volume = cell_size_x * cell_size_y * cell_size_z;
#ifdef MPI_PRALLEL
    /* MPI=============================================== */
    if (my_node==ROOT && print_level>=0) {
        printf ("\nTarget size is: \n");
        printf ("x: %i cells, %g nm per cell, %g nm in total.\n",
                cell_count_x, cell_size_x, target_size_x);
        printf ("y: %i cells, %g nm per cell, %g nm in total.\n",
                cell_count_y, cell_size_y, target_size_y);
        printf ("z: %i cells, %g nm per cell, %g nm in total.\n",
                cell_count_z, cell_size_z, target_size_z);
        printf ("Total: %i cells in %g nm^3.\n", cell_count,
                target_size_x * target_size_y * target_size_z);
    }
    /* MPI=============================================== */
#else
    if (print_level >= 0) {
        printf ("\nTarget size is: \n");
        printf ("x: %i cells, %g nm per cell, %g nm in total.\n",
                cell_count_x, cell_size_x, target_size_x);
        printf ("y: %i cells, %g nm per cell, %g nm in total.\n",
                cell_count_y, cell_size_y, target_size_y);
        printf ("z: %i cells, %g nm per cell, %g nm in total.\n",
                cell_count_z, cell_size_z, target_size_z);
        printf ("Total: %i cells in %g nm^3.\n", cell_count,
                target_size_x * target_size_y * target_size_z);
    }
#endif

    /* Now that we know the size of the target we can initialze some arrays etc. */
    if (mem_usage_only == 0) {
        /* Use calloc instead of malloc for initializing to zeros */
        target_composition  = (int*) calloc (cell_count, sizeof (int));
        if (target_composition  == NULL) return -3001;  /* cannot allocate memory */
        target_implanted_ions = (int*) calloc (cell_count, sizeof (int));
        target_replacing_ions = (int*) calloc (cell_count, sizeof (int));
        target_total_displacements = (int*) calloc (cell_count, sizeof (int));
        target_total_interstitials = (int*) calloc (cell_count, sizeof (int));
        target_total_vacancies     = (int*) calloc (cell_count, sizeof (int));
        target_total_replacements  = (int*) calloc (cell_count, sizeof (int));

        target_depth_implanted_ions = (int*) calloc (cell_count_z, sizeof (int));;
        target_depth_replacing_ions = (int*) calloc (cell_count_z, sizeof (int));
        target_depth_total_displacements = (int*) calloc (cell_count_z, sizeof (int));
        target_depth_total_interstitials = (int*) calloc (cell_count_z, sizeof (int));
        target_depth_total_vacancies     = (int*) calloc (cell_count_z, sizeof (int));
        target_depth_total_replacements  = (int*) calloc (cell_count_z, sizeof (int));

        if (target_implanted_ions == NULL) return -3002;  /* cannot allocate memory */
        if (target_replacing_ions == NULL) return -3003;  /* cannot allocate memory */
        if (target_total_displacements == NULL) return -3004;  /* cannot allocate memory */
        if (target_total_interstitials == NULL) return -3005;  /* cannot allocate memory */
        if (target_total_vacancies     == NULL) return -3006;  /* cannot allocate memory */
        if (target_total_replacements  == NULL) return -3007;  /* cannot allocate memory */

        if (target_depth_implanted_ions == NULL) return -3008;  /* cannot allocate memory */
        if (target_depth_replacing_ions == NULL) return -3009;  /* cannot allocate memory */
        if (target_depth_total_displacements == NULL) return -3010;  /* cannot allocate memory */
        if (target_depth_total_interstitials == NULL) return -3011;  /* cannot allocate memory */
        if (target_depth_total_vacancies     == NULL) return -3012;  /* cannot allocate memory */
        if (target_depth_total_replacements  == NULL) return -3013;  /* cannot allocate memory */

        if (detailed_sputtering == 1) {  /* for detailed calucation of sputtering, we need these */
            target_total_sputtered  = (int*) calloc (cell_count, sizeof(int));
            if (target_total_sputtered  == NULL) return -3014;   /* cannot allocate */
        }
        if (store_energy_deposit == 1) {  /* for detailed storing of deposited energy, we need these */
            target_energy_phonons   = (double*) calloc (cell_count, sizeof (double));
            target_energy_electrons = (double*) calloc (cell_count, sizeof (double));

            target_depth_energy_phonons   = (double*) calloc (cell_count_z, sizeof (double));
            target_depth_energy_electrons = (double*) calloc (cell_count_z, sizeof (double));

            if (target_energy_phonons   == NULL) return -3015;  /* cannot allocate */
            if (target_energy_electrons == NULL) return -3016;  /* cannot allocate */

            if (target_depth_energy_phonons   == NULL) return -3017;  /* cannot allocate */
            if (target_depth_energy_electrons == NULL) return -3018;  /* cannot allocate */
        }

        /* go through materials, init arrays for interstitials and vacancies */
        for (i=0; i<number_of_materials; i++) {
            /* create arrays of pointers to arrays */
            list_of_materials[i].target_implanted_recoils_int  =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
            list_of_materials[i].target_implanted_recoils_repl =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
            list_of_materials[i].target_elemental_vacancies   =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
            list_of_materials[i].target_elemental_disp        =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);

            list_of_materials[i].target_depth_implanted_recoils_int  =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
            list_of_materials[i].target_depth_implanted_recoils_repl =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
            list_of_materials[i].target_depth_elemental_vacancies   =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
            list_of_materials[i].target_depth_elemental_disp        =
                (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);

            if (list_of_materials[i].target_implanted_recoils_int  == NULL) return -3019;
            if (list_of_materials[i].target_implanted_recoils_repl == NULL) return -3020;
            if (list_of_materials[i].target_elemental_vacancies    == NULL) return -3021;
            if (list_of_materials[i].target_elemental_disp         == NULL) return -3022;

            if (list_of_materials[i].target_depth_implanted_recoils_int  == NULL) return -3023;
            if (list_of_materials[i].target_depth_implanted_recoils_repl == NULL) return -3024;
            if (list_of_materials[i].target_depth_elemental_vacancies    == NULL) return -3025;
            if (list_of_materials[i].target_depth_elemental_disp         == NULL) return -3026;

            /* for detailed calucation of sputtering, we need these */
            if (detailed_sputtering == 1) {
                list_of_materials[i].target_sputtered_atoms =
                    (int**) malloc (sizeof (int*) * list_of_materials[i].element_count);
                if (list_of_materials[i].target_sputtered_atoms   == NULL) return -3027;
            }

            /* go through elements, make arrays for each one */
            for (j=0; j<list_of_materials[i].element_count; j++) {
                list_of_materials[i].target_implanted_recoils_int[j]  =
                    (int*) calloc (cell_count, sizeof (int));
                list_of_materials[i].target_implanted_recoils_repl[j] =
                    (int*) calloc (cell_count, sizeof (int));
                list_of_materials[i].target_elemental_vacancies[j]    =
                    (int*) calloc (cell_count, sizeof (int));
                list_of_materials[i].target_elemental_disp[j]         =
                    (int*) calloc (cell_count, sizeof (int));

                list_of_materials[i].target_depth_implanted_recoils_int[j]  =
                    (int*) calloc (cell_count_z, sizeof (int));
                list_of_materials[i].target_depth_implanted_recoils_repl[j] =
                    (int*) calloc (cell_count_z, sizeof (int));
                list_of_materials[i].target_depth_elemental_vacancies[j]    =
                    (int*) calloc (cell_count_z, sizeof (int));
                list_of_materials[i].target_depth_elemental_disp[j]         =
                    (int*) calloc (cell_count_z, sizeof (int));

                if (list_of_materials[i].target_implanted_recoils_int[j]  == NULL) return -3028;
                if (list_of_materials[i].target_implanted_recoils_repl[j] == NULL) return -3029;
                if (list_of_materials[i].target_elemental_vacancies[j]    == NULL) return -3030;
                if (list_of_materials[i].target_elemental_disp[j]         == NULL) return -3031;

                if (list_of_materials[i].target_depth_implanted_recoils_int[j]  == NULL) return -3032;
                if (list_of_materials[i].target_depth_implanted_recoils_repl[j] == NULL) return -3033;
                if (list_of_materials[i].target_depth_elemental_vacancies[j]    == NULL) return -3034;
                if (list_of_materials[i].target_depth_elemental_disp[j]         == NULL) return -3035;

                /* For detailed calucation of sputtering, we need these */
                if (detailed_sputtering == 1) {
                    list_of_materials[i].target_sputtered_atoms[j] =
                        (int*) calloc (cell_count, sizeof (int));
                    if (list_of_materials[i].target_sputtered_atoms[j]   == NULL) return -3036;
	              }
            }
        }

#ifdef MPI_PRALLEL
        /* MPI=============================================== */
        if (my_node==ROOT && print_level>=1) printf ("Memory for target arrays has been allocated.\n\n");
        /* MPI=============================================== */
#else
        if (print_level >= 1) printf ("Memory for target arrays has been allocated.\n\n");
#endif

        /* switch : 0 - CSG, 1 - FETM. */
        /* now read in the target composition file */
        /* target composition file for non-dyanmic version based on materials */
        switch (geometry_type) {
        case 0 :  /* multi_layer bulk geometry */
            result = read_bulk_shape (TargetCompositionFileName);  /* (1) - (8) - (2) */
            if (result != 0) {
                printf ("Error: cannot read multi-layer bulk geometry file.\n");
                return result;
            }
            else {
#ifdef MPI_PRALLEL
                /* MPI=============================================== */
                if (my_node == ROOT) printf ("This is the multi-layer bulk geometry version of iran3d.\n\n");
                /* MPI=============================================== */
#else
                printf ("This is the multi-layer bulk geometry version of iran3d.\n\n");  // %s, shape
#endif
            }
            break;
        case 1 :  /* csg geometry */
            result = read_csg_shape (TargetCompositionFileName);  /* (1) - (8) - (2) */
            if (result != 0) {
                printf ("Error: cannot read csg geometry file.\n");
                return result;
            }
            else {
#ifdef MPI_PRALLEL
                /* MPI=============================================== */
                if (my_node == ROOT) printf ("This is the CSG geometry version of iran3d.\n\n");
                /* MPI=============================================== */
#else
                printf ("This is the CSG geometry version of iran3d.\n\n");  // %s, shape
#endif
            }
            break;
        case 2 :  /* fetm geometry */
            result = read_fetm_shape (TargetCompositionFileName);  /* (1) - (8) - (3) */
            if (result != 0) {
                printf ("Error: cannot read fetm geometry file.\n");
                return result;
            }
            else {
#ifdef MPI_PRALLEL
                /* MPI=============================================== */
                if (my_node == ROOT) printf ("This is the FETM geometry version of iran3d.\n\n");
                /* MPI=============================================== */
#else
                printf ("This is the FETM geometry version of iran3d.\n\n");
#endif
            }
            break;
        default :
#ifdef MPI_PRALLEL
            /* MPI=============================================== */
            if (my_node == ROOT) printf ("Unknown geometry 'geometry_type':, %i", geometry_type);
            /* MPI=============================================== */
#else
            printf ("Unknown geometry 'geometry_type':, %i", geometry_type);
#endif
            break;
        }
#ifdef MPI_PRALLEL
        /* MPI=============================================== */
        if (my_node==ROOT && print_level>=0)
            printf ("Target composition read from %s.\n", TargetCompositionFileName);
        /* MPI=============================================== */
#else
        if (print_level >= 0)
            printf ("Target composition read from %s.\n", TargetCompositionFileName);
#endif
    }
    else {  /* only calc memory usage */
#ifndef MPI_PRALLEL
        /* MPI=============================================== */
        lui_temp += 7 * sizeof (int) * cell_count;
        lui_temp += sizeof (float) * cell_count;
        if (detailed_sputtering == 1) {  /* for detailed calucation of sputtering, we need these */
            lui_temp += sizeof (int) * cell_count;
            lui_temp += sizeof (char) * cell_count;
        }
        /* for detailed storing of deposited energy */
        if (store_energy_deposit == 1) lui_temp += 2 * sizeof (double) * cell_count;
        for (i=0; i<number_of_materials; i++) {
            for (j=0; j<list_of_materials[i].element_count; j++) {  /* go through elements,
                                                             make arrays for each one */
                lui_temp += 4 * cell_count * sizeof (int);
                /* for detailed calucation of sputtering, we need these */
                if (detailed_sputtering == 1) lui_temp += cell_count * sizeof (int);
            }
        }
        mem_usage += lui_temp;
        if (mem_usage_details == 1)
            printf ("MEMORY Target historgrams:          %li bytes\n", lui_temp);
        /* MPI=============================================== */
#endif
    }

    return 0;
}
Ejemplo n.º 2
0
static bool svcctl_add_service(TALLOC_CTX *mem_ctx,
			       struct dcerpc_binding_handle *h,
			       struct policy_handle *hive_hnd,
			       const char *key,
			       uint32_t access_mask,
			       const char *name)
{
	enum winreg_CreateAction action = REG_ACTION_NONE;
	struct security_descriptor *sd = NULL;
	struct policy_handle key_hnd;
	struct winreg_String wkey;
	struct winreg_String wkeyclass;
	char *description = NULL;
	char *dname = NULL;
	char *ipath = NULL;
	bool ok = false;
	uint32_t i;
	NTSTATUS status;
	WERROR result = WERR_OK;

	ZERO_STRUCT(key_hnd);

	ZERO_STRUCT(wkey);
	wkey.name = talloc_asprintf(mem_ctx, "%s\\%s", key, name);
	if (wkey.name == NULL) {
		goto done;
	}

	ZERO_STRUCT(wkeyclass);
	wkeyclass.name = "";

	status = dcerpc_winreg_CreateKey(h,
					 mem_ctx,
					 hive_hnd,
					 wkey,
					 wkeyclass,
					 0,
					 access_mask,
					 NULL,
					 &key_hnd,
					 &action,
					 &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create key %s: %s\n",
			wkey.name, nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create key %s: %s\n",
			wkey.name, win_errstr(result)));
		goto done;
	}

	/* These values are hardcoded in all QueryServiceConfig() replies.
	   I'm just storing them here for cosmetic purposes */
	status = dcerpc_winreg_set_dword(mem_ctx,
					 h,
					 &key_hnd,
					 "Start",
					 SVCCTL_AUTO_START,
					 &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	status = dcerpc_winreg_set_dword(mem_ctx,
					 h,
					 &key_hnd,
					 "Type",
					 SERVICE_TYPE_WIN32_OWN_PROCESS,
					 &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	status = dcerpc_winreg_set_dword(mem_ctx,
					 h,
					 &key_hnd,
					 "ErrorControl",
					 SVCCTL_SVC_ERROR_NORMAL,
					 &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	status = dcerpc_winreg_set_sz(mem_ctx,
				      h,
				      &key_hnd,
				      "ObjectName",
				      "LocalSystem",
				      &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	/*
	 * Special considerations for internal services and the DisplayName
	 * value.
	 */
	for (i = 0; builtin_svcs[i].servicename; i++) {
		if (strequal(name, builtin_svcs[i].servicename)) {
			ipath = talloc_asprintf(mem_ctx,
						"%s/%s/%s",
						get_dyn_MODULESDIR(),
						SVCCTL_SCRIPT_DIR,
						builtin_svcs[i].daemon);
			description = talloc_strdup(mem_ctx, builtin_svcs[i].description);
			dname = talloc_strdup(mem_ctx, builtin_svcs[i].dispname);
			break;
		}
	}

	/* Default to an external service if we haven't found a match */
	if (builtin_svcs[i].servicename == NULL) {
		struct rcinit_file_information *init_info = NULL;
		char *dispname = NULL;

		ipath = talloc_asprintf(mem_ctx,
					"%s/%s/%s",
					get_dyn_MODULESDIR(),
					SVCCTL_SCRIPT_DIR,
					name);

		/* lookup common unix display names */
		dispname = svcctl_get_common_service_dispname(mem_ctx, name);
		dname = talloc_strdup(mem_ctx, dispname ? dispname : "");

		/* get info from init file itself */
		if (read_init_file(mem_ctx, name, &init_info)) {
			description = talloc_strdup(mem_ctx,
						    init_info->description);
		} else {
			description = talloc_strdup(mem_ctx,
						    "External Unix Service");
		}
	}

	if (ipath == NULL || dname == NULL || description == NULL) {
		goto done;
	}

	status = dcerpc_winreg_set_sz(mem_ctx,
				      h,
				      &key_hnd,
				      "DisplayName",
				      dname,
				      &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	status = dcerpc_winreg_set_sz(mem_ctx,
				      h,
				      &key_hnd,
				      "ImagePath",
				      ipath,
				      &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	status = dcerpc_winreg_set_sz(mem_ctx,
				      h,
				      &key_hnd,
				      "Description",
				      description,
				      &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	sd = svcctl_gen_service_sd(mem_ctx);
	if (sd == NULL) {
		DEBUG(0, ("add_new_svc_name: Failed to create default "
			  "sec_desc!\n"));
		goto done;
	}

	if (is_valid_policy_hnd(&key_hnd)) {
		dcerpc_winreg_CloseKey(h, mem_ctx, &key_hnd, &result);
	}
	ZERO_STRUCT(key_hnd);

	ZERO_STRUCT(wkey);
	wkey.name = talloc_asprintf(mem_ctx, "%s\\%s\\Security", key, name);
	if (wkey.name == NULL) {
		result = WERR_NOMEM;
		goto done;
	}

	ZERO_STRUCT(wkeyclass);
	wkeyclass.name = "";

	status = dcerpc_winreg_CreateKey(h,
					 mem_ctx,
					 hive_hnd,
					 wkey,
					 wkeyclass,
					 0,
					 access_mask,
					 NULL,
					 &key_hnd,
					 &action,
					 &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create key %s: %s\n",
			wkey.name, nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create key %s: %s\n",
			wkey.name, win_errstr(result)));
		goto done;
	}

	status = dcerpc_winreg_set_sd(mem_ctx,
				      h,
				      &key_hnd,
				      "Security",
				      sd,
				      &result);
	if (!NT_STATUS_IS_OK(status)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  nt_errstr(status)));
		goto done;
	}
	if (!W_ERROR_IS_OK(result)) {
		DEBUG(0, ("svcctl_init_winreg_keys: Could not create value: %s\n",
			  win_errstr(result)));
		goto done;
	}

	ok = true;
done:
	if (is_valid_policy_hnd(&key_hnd)) {
		dcerpc_winreg_CloseKey(h, mem_ctx, &key_hnd, &result);
	}

	return ok;
}