LCOV - code coverage report
Current view: top level - bin/default/librpc/gen_ndr - py_winreg.c (source / functions) Hit Total Coverage
Test: coverage report for abartlet/fix-coverage dd10fb34 Lines: 386 12529 3.1 %
Date: 2021-09-23 10:06:22 Functions: 12 920 1.3 %

          Line data    Source code
       1             : 
       2             : /* Python wrapper functions auto-generated by pidl */
       3             : #define PY_SSIZE_T_CLEAN 1 /* We use Py_ssize_t for PyArg_ParseTupleAndKeywords */
       4             : #include <Python.h>
       5             : #include "python/py3compat.h"
       6             : #include "includes.h"
       7             : #include "python/modules.h"
       8             : #include <pytalloc.h>
       9             : #include "librpc/rpc/pyrpc.h"
      10             : #include "librpc/rpc/pyrpc_util.h"
      11             : #include "bin/default/librpc/gen_ndr/ndr_winreg.h"
      12             : #include "bin/default/librpc/gen_ndr/ndr_winreg_c.h"
      13             : 
      14             : /*
      15             :  * Suppress compiler warnings if the generated code does not call these
      16             :  * functions
      17             :  */
      18             : #ifndef _MAYBE_UNUSED_
      19             : #ifdef __has_attribute
      20             : #if __has_attribute(unused)
      21             : #define _MAYBE_UNUSED_ __attribute__ ((unused))
      22             : #else
      23             : #define _MAYBE_UNUSED_
      24             : #endif
      25             : #endif
      26             : #endif
      27             : /*
      28             :  * These functions are here to ensure they can be optimized out by
      29             :  * the compiler based on the constant input values
      30             :  */
      31             : 
      32           3 : static inline unsigned long long ndr_sizeof2uintmax(size_t var_size)
      33             : {
      34           3 :         switch (var_size) {
      35           0 :         case 8:
      36           0 :                 return UINT64_MAX;
      37           3 :         case 4:
      38           3 :                 return UINT32_MAX;
      39           0 :         case 2:
      40           0 :                 return UINT16_MAX;
      41           0 :         case 1:
      42           0 :                 return UINT8_MAX;
      43             :         }
      44             : 
      45           0 :         return 0;
      46             : }
      47             : 
      48             : static inline _MAYBE_UNUSED_ long long ndr_sizeof2intmax(size_t var_size)
      49             : {
      50             :         switch (var_size) {
      51             :         case 8:
      52             :                 return INT64_MAX;
      53             :         case 4:
      54             :                 return INT32_MAX;
      55             :         case 2:
      56             :                 return INT16_MAX;
      57             :         case 1:
      58             :                 return INT8_MAX;
      59             :         }
      60             : 
      61             :         return 0;
      62             : }
      63             : 
      64             : #include "librpc/gen_ndr/lsa.h"
      65             : #include "librpc/gen_ndr/security.h"
      66             : #include "librpc/gen_ndr/misc.h"
      67             : static PyTypeObject winreg_String_Type;
      68             : static PyTypeObject KeySecurityData_Type;
      69             : static PyTypeObject winreg_SecBuf_Type;
      70             : static PyTypeObject winreg_StringBuf_Type;
      71             : static PyTypeObject winreg_ValNameBuf_Type;
      72             : static PyTypeObject KeySecurityAttribute_Type;
      73             : static PyTypeObject QueryMultipleValue_Type;
      74             : static PyTypeObject winreg_InterfaceType;
      75             : static PyTypeObject winreg_OpenHKCR_Type;
      76             : static PyTypeObject winreg_OpenHKCU_Type;
      77             : static PyTypeObject winreg_OpenHKLM_Type;
      78             : static PyTypeObject winreg_OpenHKPD_Type;
      79             : static PyTypeObject winreg_OpenHKU_Type;
      80             : static PyTypeObject winreg_CloseKey_Type;
      81             : static PyTypeObject winreg_CreateKey_Type;
      82             : static PyTypeObject winreg_DeleteKey_Type;
      83             : static PyTypeObject winreg_DeleteValue_Type;
      84             : static PyTypeObject winreg_EnumKey_Type;
      85             : static PyTypeObject winreg_EnumValue_Type;
      86             : static PyTypeObject winreg_FlushKey_Type;
      87             : static PyTypeObject winreg_GetKeySecurity_Type;
      88             : static PyTypeObject winreg_LoadKey_Type;
      89             : static PyTypeObject winreg_NotifyChangeKeyValue_Type;
      90             : static PyTypeObject winreg_OpenKey_Type;
      91             : static PyTypeObject winreg_QueryInfoKey_Type;
      92             : static PyTypeObject winreg_QueryValue_Type;
      93             : static PyTypeObject winreg_ReplaceKey_Type;
      94             : static PyTypeObject winreg_RestoreKey_Type;
      95             : static PyTypeObject winreg_SaveKey_Type;
      96             : static PyTypeObject winreg_SetKeySecurity_Type;
      97             : static PyTypeObject winreg_SetValue_Type;
      98             : static PyTypeObject winreg_UnLoadKey_Type;
      99             : static PyTypeObject winreg_InitiateSystemShutdown_Type;
     100             : static PyTypeObject winreg_AbortSystemShutdown_Type;
     101             : static PyTypeObject winreg_GetVersion_Type;
     102             : static PyTypeObject winreg_OpenHKCC_Type;
     103             : static PyTypeObject winreg_OpenHKDD_Type;
     104             : static PyTypeObject winreg_QueryMultipleValues_Type;
     105             : static PyTypeObject winreg_InitiateSystemShutdownEx_Type;
     106             : static PyTypeObject winreg_SaveKeyEx_Type;
     107             : static PyTypeObject winreg_OpenHKPT_Type;
     108             : static PyTypeObject winreg_OpenHKPN_Type;
     109             : static PyTypeObject winreg_QueryMultipleValues2_Type;
     110             : static PyTypeObject winreg_DeleteKeyEx_Type;
     111             : 
     112             : static PyTypeObject *BaseObject_Type;
     113             : static PyTypeObject *policy_handle_Type;
     114             : static PyTypeObject *lsa_StringLarge_Type;
     115             : static PyTypeObject *ClientConnection_Type;
     116             : static PyTypeObject *ndr_syntax_id_Type;
     117             : 
     118           0 : static PyObject *py_winreg_String_get_name_len(PyObject *obj, void *closure)
     119             : {
     120           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(obj);
     121             :         PyObject *py_name_len;
     122           0 :         py_name_len = PyLong_FromLong((uint16_t)object->name_len);
     123           0 :         return py_name_len;
     124             : }
     125             : 
     126           0 : static int py_winreg_String_set_name_len(PyObject *py_obj, PyObject *value, void *closure)
     127             : {
     128           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(py_obj);
     129           0 :         if (value == NULL) {
     130           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name_len");
     131           0 :                 return -1;
     132             :         }
     133             :         {
     134           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->name_len));
     135           0 :                 if (PyLong_Check(value)) {
     136             :                         unsigned long long test_var;
     137           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     138           0 :                         if (PyErr_Occurred() != NULL) {
     139           0 :                                 return -1;
     140             :                         }
     141           0 :                         if (test_var > uint_max) {
     142           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     143             :                                   PyLong_Type.tp_name, uint_max, test_var);
     144           0 :                                 return -1;
     145             :                         }
     146           0 :                         object->name_len = test_var;
     147             :                 } else {
     148           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     149             :                           PyLong_Type.tp_name);
     150           0 :                         return -1;
     151             :                 }
     152             :         }
     153           0 :         return 0;
     154             : }
     155             : 
     156           0 : static PyObject *py_winreg_String_get_name_size(PyObject *obj, void *closure)
     157             : {
     158           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(obj);
     159             :         PyObject *py_name_size;
     160           0 :         py_name_size = PyLong_FromLong((uint16_t)object->name_size);
     161           0 :         return py_name_size;
     162             : }
     163             : 
     164           0 : static int py_winreg_String_set_name_size(PyObject *py_obj, PyObject *value, void *closure)
     165             : {
     166           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(py_obj);
     167           0 :         if (value == NULL) {
     168           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name_size");
     169           0 :                 return -1;
     170             :         }
     171             :         {
     172           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->name_size));
     173           0 :                 if (PyLong_Check(value)) {
     174             :                         unsigned long long test_var;
     175           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     176           0 :                         if (PyErr_Occurred() != NULL) {
     177           0 :                                 return -1;
     178             :                         }
     179           0 :                         if (test_var > uint_max) {
     180           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     181             :                                   PyLong_Type.tp_name, uint_max, test_var);
     182           0 :                                 return -1;
     183             :                         }
     184           0 :                         object->name_size = test_var;
     185             :                 } else {
     186           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     187             :                           PyLong_Type.tp_name);
     188           0 :                         return -1;
     189             :                 }
     190             :         }
     191           0 :         return 0;
     192             : }
     193             : 
     194           0 : static PyObject *py_winreg_String_get_name(PyObject *obj, void *closure)
     195             : {
     196           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(obj);
     197             :         PyObject *py_name;
     198           0 :         if (object->name == NULL) {
     199           0 :                 Py_RETURN_NONE;
     200             :         }
     201           0 :         if (object->name == NULL) {
     202           0 :                 py_name = Py_None;
     203           0 :                 Py_INCREF(py_name);
     204             :         } else {
     205           0 :                 if (object->name == NULL) {
     206           0 :                         py_name = Py_None;
     207           0 :                         Py_INCREF(py_name);
     208             :                 } else {
     209           0 :                         py_name = PyUnicode_Decode(object->name, strlen(object->name), "utf-8", "ignore");
     210             :                 }
     211             :         }
     212           0 :         return py_name;
     213             : }
     214             : 
     215           0 : static int py_winreg_String_set_name(PyObject *py_obj, PyObject *value, void *closure)
     216             : {
     217           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(py_obj);
     218           0 :         if (value == NULL) {
     219           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name");
     220           0 :                 return -1;
     221             :         }
     222           0 :         if (value == Py_None) {
     223           0 :                 object->name = NULL;
     224             :         } else {
     225           0 :                 object->name = NULL;
     226             :                 {
     227             :                         const char *test_str;
     228             :                         const char *talloc_str;
     229           0 :                         PyObject *unicode = NULL;
     230           0 :                         if (PyUnicode_Check(value)) {
     231           0 :                                 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     232           0 :                                 if (unicode == NULL) {
     233           0 :                                         PyErr_NoMemory();
     234           0 :                                         return -1;
     235             :                                 }
     236           0 :                                 test_str = PyBytes_AS_STRING(unicode);
     237           0 :                         } else if (PyBytes_Check(value)) {
     238           0 :                                 test_str = PyBytes_AS_STRING(value);
     239             :                         } else {
     240           0 :                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     241           0 :                                 return -1;
     242             :                         }
     243           0 :                         talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     244           0 :                         if (unicode != NULL) {
     245           0 :                                 Py_DECREF(unicode);
     246             :                         }
     247           0 :                         if (talloc_str == NULL) {
     248           0 :                                 PyErr_NoMemory();
     249           0 :                                 return -1;
     250             :                         }
     251           0 :                         object->name = talloc_str;
     252             :                 }
     253             :         }
     254           0 :         return 0;
     255             : }
     256             : 
     257             : static PyGetSetDef py_winreg_String_getsetters[] = {
     258             :         {
     259             :                 .name = discard_const_p(char, "name_len"),
     260             :                 .get = py_winreg_String_get_name_len,
     261             :                 .set = py_winreg_String_set_name_len,
     262             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     263             :         },
     264             :         {
     265             :                 .name = discard_const_p(char, "name_size"),
     266             :                 .get = py_winreg_String_get_name_size,
     267             :                 .set = py_winreg_String_set_name_size,
     268             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     269             :         },
     270             :         {
     271             :                 .name = discard_const_p(char, "name"),
     272             :                 .get = py_winreg_String_get_name,
     273             :                 .set = py_winreg_String_set_name,
     274             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     275             :         },
     276             :         { .name = NULL }
     277             : };
     278             : 
     279           1 : static PyObject *py_winreg_String_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     280             : {
     281           1 :         return pytalloc_new(struct winreg_String, type);
     282             : }
     283             : 
     284           0 : static PyObject *py_winreg_String_ndr_pack(PyObject *py_obj,  PyObject *Py_UNUSED(ignored))
     285             : {
     286           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(py_obj);
     287           0 :         PyObject *ret = NULL;
     288             :         DATA_BLOB blob;
     289             :         enum ndr_err_code err;
     290           0 :         TALLOC_CTX *tmp_ctx = talloc_new(pytalloc_get_mem_ctx(py_obj));
     291           0 :         if (tmp_ctx == NULL) {
     292           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
     293           0 :                 return NULL;
     294             :         }
     295           0 :         err = ndr_push_struct_blob(&blob, tmp_ctx, object, (ndr_push_flags_fn_t)ndr_push_winreg_String);
     296           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     297           0 :                 TALLOC_FREE(tmp_ctx);
     298           0 :                 PyErr_SetNdrError(err);
     299           0 :                 return NULL;
     300             :         }
     301             : 
     302           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
     303           0 :         TALLOC_FREE(tmp_ctx);
     304           0 :         return ret;
     305             : }
     306             : 
     307           0 : static PyObject *py_winreg_String_ndr_unpack(PyObject *py_obj, PyObject *args, PyObject *kwargs)
     308             : {
     309           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(py_obj);
     310           0 :         DATA_BLOB blob = {.data = NULL, .length = 0};
     311           0 :         Py_ssize_t blob_length = 0;
     312             :         enum ndr_err_code err;
     313           0 :         const char * const kwnames[] = { "data_blob", "allow_remaining", NULL };
     314           0 :         PyObject *allow_remaining_obj = NULL;
     315           0 :         bool allow_remaining = false;
     316             : 
     317           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|O:__ndr_unpack__",
     318             :                 discard_const_p(char *, kwnames),
     319             :                 &blob.data, &blob_length,
     320             :                 &allow_remaining_obj)) {
     321           0 :                 return NULL;
     322             :         }
     323           0 :         blob.length = blob_length;
     324             : 
     325           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
     326           0 :                 allow_remaining = true;
     327             :         }
     328             : 
     329           0 :         if (allow_remaining) {
     330           0 :                 err = ndr_pull_struct_blob(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_winreg_String);
     331             :         } else {
     332           0 :                 err = ndr_pull_struct_blob_all(&blob, pytalloc_get_mem_ctx(py_obj), object, (ndr_pull_flags_fn_t)ndr_pull_winreg_String);
     333             :         }
     334           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
     335           0 :                 PyErr_SetNdrError(err);
     336           0 :                 return NULL;
     337             :         }
     338             : 
     339           0 :         Py_RETURN_NONE;
     340             : }
     341             : 
     342           0 : static PyObject *py_winreg_String_ndr_print(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
     343             : {
     344           0 :         struct winreg_String *object = (struct winreg_String *)pytalloc_get_ptr(py_obj);
     345             :         PyObject *ret;
     346             :         char *retstr;
     347             : 
     348           0 :         retstr = ndr_print_struct_string(pytalloc_get_mem_ctx(py_obj), (ndr_print_fn_t)ndr_print_winreg_String, "winreg_String", object);
     349           0 :         ret = PyUnicode_FromString(retstr);
     350           0 :         talloc_free(retstr);
     351             : 
     352           0 :         return ret;
     353             : }
     354             : 
     355             : static PyMethodDef py_winreg_String_methods[] = {
     356             :         { "__ndr_pack__", (PyCFunction)py_winreg_String_ndr_pack, METH_NOARGS, "S.ndr_pack(object) -> blob\nNDR pack" },
     357             :         { "__ndr_unpack__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_String_ndr_unpack), METH_VARARGS|METH_KEYWORDS, "S.ndr_unpack(class, blob, allow_remaining=False) -> None\nNDR unpack" },
     358             :         { "__ndr_print__", (PyCFunction)py_winreg_String_ndr_print, METH_NOARGS, "S.ndr_print(object) -> None\nNDR print" },
     359             :         { NULL, NULL, 0, NULL }
     360             : };
     361             : 
     362             : 
     363             : static PyTypeObject winreg_String_Type = {
     364             :         PyVarObject_HEAD_INIT(NULL, 0)
     365             :         .tp_name = "winreg.String",
     366             :         .tp_getset = py_winreg_String_getsetters,
     367             :         .tp_methods = py_winreg_String_methods,
     368             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     369             :         .tp_new = py_winreg_String_new,
     370             : };
     371             : 
     372             : 
     373           0 : static PyObject *py_KeySecurityData_get_data(PyObject *obj, void *closure)
     374             : {
     375           0 :         struct KeySecurityData *object = (struct KeySecurityData *)pytalloc_get_ptr(obj);
     376             :         PyObject *py_data;
     377           0 :         if (object->data == NULL) {
     378           0 :                 Py_RETURN_NONE;
     379             :         }
     380           0 :         if (object->data == NULL) {
     381           0 :                 py_data = Py_None;
     382           0 :                 Py_INCREF(py_data);
     383             :         } else {
     384           0 :                 py_data = PyList_New(object->len);
     385           0 :                 if (py_data == NULL) {
     386           0 :                         return NULL;
     387             :                 }
     388             :                 {
     389             :                         int data_cntr_1;
     390           0 :                         for (data_cntr_1 = 0; data_cntr_1 < (object->len); data_cntr_1++) {
     391             :                                 PyObject *py_data_1;
     392           0 :                                 py_data_1 = PyLong_FromLong((uint16_t)object->data[data_cntr_1]);
     393           0 :                                 PyList_SetItem(py_data, data_cntr_1, py_data_1);
     394             :                         }
     395             :                 }
     396             :         }
     397           0 :         return py_data;
     398             : }
     399             : 
     400           0 : static int py_KeySecurityData_set_data(PyObject *py_obj, PyObject *value, void *closure)
     401             : {
     402           0 :         struct KeySecurityData *object = (struct KeySecurityData *)pytalloc_get_ptr(py_obj);
     403           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->data));
     404           0 :         if (value == NULL) {
     405           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->data");
     406           0 :                 return -1;
     407             :         }
     408           0 :         if (value == Py_None) {
     409           0 :                 object->data = NULL;
     410             :         } else {
     411           0 :                 object->data = NULL;
     412           0 :                 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
     413             :                 {
     414             :                         int data_cntr_1;
     415           0 :                         object->data = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->data, PyList_GET_SIZE(value));
     416           0 :                         if (!object->data) { return -1;; }
     417           0 :                         talloc_set_name_const(object->data, "ARRAY: object->data");
     418           0 :                         for (data_cntr_1 = 0; data_cntr_1 < PyList_GET_SIZE(value); data_cntr_1++) {
     419           0 :                                 if (PyList_GET_ITEM(value, data_cntr_1) == NULL) {
     420           0 :                                         PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->data[data_cntr_1]");
     421           0 :                                         return -1;
     422             :                                 }
     423             :                                 {
     424           0 :                                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->data[data_cntr_1]));
     425           0 :                                         if (PyLong_Check(PyList_GET_ITEM(value, data_cntr_1))) {
     426             :                                                 unsigned long long test_var;
     427           0 :                                                 test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, data_cntr_1));
     428           0 :                                                 if (PyErr_Occurred() != NULL) {
     429           0 :                                                         return -1;
     430             :                                                 }
     431           0 :                                                 if (test_var > uint_max) {
     432           0 :                                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     433             :                                                           PyLong_Type.tp_name, uint_max, test_var);
     434           0 :                                                         return -1;
     435             :                                                 }
     436           0 :                                                 object->data[data_cntr_1] = test_var;
     437             :                                         } else {
     438           0 :                                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
     439             :                                                   PyLong_Type.tp_name);
     440           0 :                                                 return -1;
     441             :                                         }
     442             :                                 }
     443             :                         }
     444             :                 }
     445             :         }
     446           0 :         return 0;
     447             : }
     448             : 
     449           0 : static PyObject *py_KeySecurityData_get_size(PyObject *obj, void *closure)
     450             : {
     451           0 :         struct KeySecurityData *object = (struct KeySecurityData *)pytalloc_get_ptr(obj);
     452             :         PyObject *py_size;
     453           0 :         py_size = PyLong_FromUnsignedLongLong((uint32_t)object->size);
     454           0 :         return py_size;
     455             : }
     456             : 
     457           0 : static int py_KeySecurityData_set_size(PyObject *py_obj, PyObject *value, void *closure)
     458             : {
     459           0 :         struct KeySecurityData *object = (struct KeySecurityData *)pytalloc_get_ptr(py_obj);
     460           0 :         if (value == NULL) {
     461           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->size");
     462           0 :                 return -1;
     463             :         }
     464             :         {
     465           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->size));
     466           0 :                 if (PyLong_Check(value)) {
     467             :                         unsigned long long test_var;
     468           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     469           0 :                         if (PyErr_Occurred() != NULL) {
     470           0 :                                 return -1;
     471             :                         }
     472           0 :                         if (test_var > uint_max) {
     473           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     474             :                                   PyLong_Type.tp_name, uint_max, test_var);
     475           0 :                                 return -1;
     476             :                         }
     477           0 :                         object->size = test_var;
     478             :                 } else {
     479           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     480             :                           PyLong_Type.tp_name);
     481           0 :                         return -1;
     482             :                 }
     483             :         }
     484           0 :         return 0;
     485             : }
     486             : 
     487           0 : static PyObject *py_KeySecurityData_get_len(PyObject *obj, void *closure)
     488             : {
     489           0 :         struct KeySecurityData *object = (struct KeySecurityData *)pytalloc_get_ptr(obj);
     490             :         PyObject *py_len;
     491           0 :         py_len = PyLong_FromUnsignedLongLong((uint32_t)object->len);
     492           0 :         return py_len;
     493             : }
     494             : 
     495           0 : static int py_KeySecurityData_set_len(PyObject *py_obj, PyObject *value, void *closure)
     496             : {
     497           0 :         struct KeySecurityData *object = (struct KeySecurityData *)pytalloc_get_ptr(py_obj);
     498           0 :         if (value == NULL) {
     499           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->len");
     500           0 :                 return -1;
     501             :         }
     502             :         {
     503           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->len));
     504           0 :                 if (PyLong_Check(value)) {
     505             :                         unsigned long long test_var;
     506           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     507           0 :                         if (PyErr_Occurred() != NULL) {
     508           0 :                                 return -1;
     509             :                         }
     510           0 :                         if (test_var > uint_max) {
     511           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     512             :                                   PyLong_Type.tp_name, uint_max, test_var);
     513           0 :                                 return -1;
     514             :                         }
     515           0 :                         object->len = test_var;
     516             :                 } else {
     517           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     518             :                           PyLong_Type.tp_name);
     519           0 :                         return -1;
     520             :                 }
     521             :         }
     522           0 :         return 0;
     523             : }
     524             : 
     525             : static PyGetSetDef py_KeySecurityData_getsetters[] = {
     526             :         {
     527             :                 .name = discard_const_p(char, "data"),
     528             :                 .get = py_KeySecurityData_get_data,
     529             :                 .set = py_KeySecurityData_set_data,
     530             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     531             :         },
     532             :         {
     533             :                 .name = discard_const_p(char, "size"),
     534             :                 .get = py_KeySecurityData_get_size,
     535             :                 .set = py_KeySecurityData_set_size,
     536             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
     537             :         },
     538             :         {
     539             :                 .name = discard_const_p(char, "len"),
     540             :                 .get = py_KeySecurityData_get_len,
     541             :                 .set = py_KeySecurityData_set_len,
     542             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
     543             :         },
     544             :         { .name = NULL }
     545             : };
     546             : 
     547           0 : static PyObject *py_KeySecurityData_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     548             : {
     549           0 :         return pytalloc_new(struct KeySecurityData, type);
     550             : }
     551             : 
     552             : 
     553             : static PyTypeObject KeySecurityData_Type = {
     554             :         PyVarObject_HEAD_INIT(NULL, 0)
     555             :         .tp_name = "winreg.KeySecurityData",
     556             :         .tp_getset = py_KeySecurityData_getsetters,
     557             :         .tp_methods = NULL,
     558             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     559             :         .tp_new = py_KeySecurityData_new,
     560             : };
     561             : 
     562             : 
     563           0 : static PyObject *py_winreg_SecBuf_get_length(PyObject *obj, void *closure)
     564             : {
     565           0 :         struct winreg_SecBuf *object = (struct winreg_SecBuf *)pytalloc_get_ptr(obj);
     566             :         PyObject *py_length;
     567           0 :         py_length = PyLong_FromUnsignedLongLong((uint32_t)object->length);
     568           0 :         return py_length;
     569             : }
     570             : 
     571           0 : static int py_winreg_SecBuf_set_length(PyObject *py_obj, PyObject *value, void *closure)
     572             : {
     573           0 :         struct winreg_SecBuf *object = (struct winreg_SecBuf *)pytalloc_get_ptr(py_obj);
     574           0 :         if (value == NULL) {
     575           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
     576           0 :                 return -1;
     577             :         }
     578             :         {
     579           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
     580           0 :                 if (PyLong_Check(value)) {
     581             :                         unsigned long long test_var;
     582           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     583           0 :                         if (PyErr_Occurred() != NULL) {
     584           0 :                                 return -1;
     585             :                         }
     586           0 :                         if (test_var > uint_max) {
     587           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     588             :                                   PyLong_Type.tp_name, uint_max, test_var);
     589           0 :                                 return -1;
     590             :                         }
     591           0 :                         object->length = test_var;
     592             :                 } else {
     593           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     594             :                           PyLong_Type.tp_name);
     595           0 :                         return -1;
     596             :                 }
     597             :         }
     598           0 :         return 0;
     599             : }
     600             : 
     601           0 : static PyObject *py_winreg_SecBuf_get_sd(PyObject *obj, void *closure)
     602             : {
     603           0 :         struct winreg_SecBuf *object = (struct winreg_SecBuf *)pytalloc_get_ptr(obj);
     604             :         PyObject *py_sd;
     605           0 :         py_sd = pytalloc_reference_ex(&KeySecurityData_Type, pytalloc_get_mem_ctx(obj), &object->sd);
     606           0 :         return py_sd;
     607             : }
     608             : 
     609           0 : static int py_winreg_SecBuf_set_sd(PyObject *py_obj, PyObject *value, void *closure)
     610             : {
     611           0 :         struct winreg_SecBuf *object = (struct winreg_SecBuf *)pytalloc_get_ptr(py_obj);
     612           0 :         if (value == NULL) {
     613           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->sd");
     614           0 :                 return -1;
     615             :         }
     616           0 :         PY_CHECK_TYPE(&KeySecurityData_Type, value, return -1;);
     617           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
     618           0 :                 PyErr_NoMemory();
     619           0 :                 return -1;
     620             :         }
     621           0 :         object->sd = *(struct KeySecurityData *)pytalloc_get_ptr(value);
     622           0 :         return 0;
     623             : }
     624             : 
     625           0 : static PyObject *py_winreg_SecBuf_get_inherit(PyObject *obj, void *closure)
     626             : {
     627           0 :         struct winreg_SecBuf *object = (struct winreg_SecBuf *)pytalloc_get_ptr(obj);
     628             :         PyObject *py_inherit;
     629           0 :         py_inherit = PyLong_FromLong((uint16_t)object->inherit);
     630           0 :         return py_inherit;
     631             : }
     632             : 
     633           0 : static int py_winreg_SecBuf_set_inherit(PyObject *py_obj, PyObject *value, void *closure)
     634             : {
     635           0 :         struct winreg_SecBuf *object = (struct winreg_SecBuf *)pytalloc_get_ptr(py_obj);
     636           0 :         if (value == NULL) {
     637           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->inherit");
     638           0 :                 return -1;
     639             :         }
     640             :         {
     641           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->inherit));
     642           0 :                 if (PyLong_Check(value)) {
     643             :                         unsigned long long test_var;
     644           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     645           0 :                         if (PyErr_Occurred() != NULL) {
     646           0 :                                 return -1;
     647             :                         }
     648           0 :                         if (test_var > uint_max) {
     649           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     650             :                                   PyLong_Type.tp_name, uint_max, test_var);
     651           0 :                                 return -1;
     652             :                         }
     653           0 :                         object->inherit = test_var;
     654             :                 } else {
     655           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     656             :                           PyLong_Type.tp_name);
     657           0 :                         return -1;
     658             :                 }
     659             :         }
     660           0 :         return 0;
     661             : }
     662             : 
     663             : static PyGetSetDef py_winreg_SecBuf_getsetters[] = {
     664             :         {
     665             :                 .name = discard_const_p(char, "length"),
     666             :                 .get = py_winreg_SecBuf_get_length,
     667             :                 .set = py_winreg_SecBuf_set_length,
     668             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
     669             :         },
     670             :         {
     671             :                 .name = discard_const_p(char, "sd"),
     672             :                 .get = py_winreg_SecBuf_get_sd,
     673             :                 .set = py_winreg_SecBuf_set_sd,
     674             :                 .doc = discard_const_p(char, "PIDL-generated element of base type KeySecurityData")
     675             :         },
     676             :         {
     677             :                 .name = discard_const_p(char, "inherit"),
     678             :                 .get = py_winreg_SecBuf_get_inherit,
     679             :                 .set = py_winreg_SecBuf_set_inherit,
     680             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
     681             :         },
     682             :         { .name = NULL }
     683             : };
     684             : 
     685           0 : static PyObject *py_winreg_SecBuf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     686             : {
     687           0 :         return pytalloc_new(struct winreg_SecBuf, type);
     688             : }
     689             : 
     690             : 
     691             : static PyTypeObject winreg_SecBuf_Type = {
     692             :         PyVarObject_HEAD_INIT(NULL, 0)
     693             :         .tp_name = "winreg.SecBuf",
     694             :         .tp_getset = py_winreg_SecBuf_getsetters,
     695             :         .tp_methods = NULL,
     696             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     697             :         .tp_new = py_winreg_SecBuf_new,
     698             : };
     699             : 
     700             : 
     701           0 : static PyObject *py_winreg_StringBuf_get_length(PyObject *obj, void *closure)
     702             : {
     703           0 :         struct winreg_StringBuf *object = (struct winreg_StringBuf *)pytalloc_get_ptr(obj);
     704             :         PyObject *py_length;
     705           0 :         py_length = PyLong_FromLong((uint16_t)object->length);
     706           0 :         return py_length;
     707             : }
     708             : 
     709           0 : static int py_winreg_StringBuf_set_length(PyObject *py_obj, PyObject *value, void *closure)
     710             : {
     711           0 :         struct winreg_StringBuf *object = (struct winreg_StringBuf *)pytalloc_get_ptr(py_obj);
     712           0 :         if (value == NULL) {
     713           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
     714           0 :                 return -1;
     715             :         }
     716             :         {
     717           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
     718           0 :                 if (PyLong_Check(value)) {
     719             :                         unsigned long long test_var;
     720           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     721           0 :                         if (PyErr_Occurred() != NULL) {
     722           0 :                                 return -1;
     723             :                         }
     724           0 :                         if (test_var > uint_max) {
     725           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     726             :                                   PyLong_Type.tp_name, uint_max, test_var);
     727           0 :                                 return -1;
     728             :                         }
     729           0 :                         object->length = test_var;
     730             :                 } else {
     731           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     732             :                           PyLong_Type.tp_name);
     733           0 :                         return -1;
     734             :                 }
     735             :         }
     736           0 :         return 0;
     737             : }
     738             : 
     739           0 : static PyObject *py_winreg_StringBuf_get_size(PyObject *obj, void *closure)
     740             : {
     741           0 :         struct winreg_StringBuf *object = (struct winreg_StringBuf *)pytalloc_get_ptr(obj);
     742             :         PyObject *py_size;
     743           0 :         py_size = PyLong_FromLong((uint16_t)object->size);
     744           0 :         return py_size;
     745             : }
     746             : 
     747           0 : static int py_winreg_StringBuf_set_size(PyObject *py_obj, PyObject *value, void *closure)
     748             : {
     749           0 :         struct winreg_StringBuf *object = (struct winreg_StringBuf *)pytalloc_get_ptr(py_obj);
     750           0 :         if (value == NULL) {
     751           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->size");
     752           0 :                 return -1;
     753             :         }
     754             :         {
     755           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->size));
     756           0 :                 if (PyLong_Check(value)) {
     757             :                         unsigned long long test_var;
     758           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     759           0 :                         if (PyErr_Occurred() != NULL) {
     760           0 :                                 return -1;
     761             :                         }
     762           0 :                         if (test_var > uint_max) {
     763           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     764             :                                   PyLong_Type.tp_name, uint_max, test_var);
     765           0 :                                 return -1;
     766             :                         }
     767           0 :                         object->size = test_var;
     768             :                 } else {
     769           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     770             :                           PyLong_Type.tp_name);
     771           0 :                         return -1;
     772             :                 }
     773             :         }
     774           0 :         return 0;
     775             : }
     776             : 
     777           0 : static PyObject *py_winreg_StringBuf_get_name(PyObject *obj, void *closure)
     778             : {
     779           0 :         struct winreg_StringBuf *object = (struct winreg_StringBuf *)pytalloc_get_ptr(obj);
     780             :         PyObject *py_name;
     781           0 :         if (object->name == NULL) {
     782           0 :                 Py_RETURN_NONE;
     783             :         }
     784           0 :         if (object->name == NULL) {
     785           0 :                 py_name = Py_None;
     786           0 :                 Py_INCREF(py_name);
     787             :         } else {
     788           0 :                 if (object->name == NULL) {
     789           0 :                         py_name = Py_None;
     790           0 :                         Py_INCREF(py_name);
     791             :                 } else {
     792           0 :                         py_name = PyUnicode_Decode(object->name, strlen(object->name), "utf-8", "ignore");
     793             :                 }
     794             :         }
     795           0 :         return py_name;
     796             : }
     797             : 
     798           0 : static int py_winreg_StringBuf_set_name(PyObject *py_obj, PyObject *value, void *closure)
     799             : {
     800           0 :         struct winreg_StringBuf *object = (struct winreg_StringBuf *)pytalloc_get_ptr(py_obj);
     801           0 :         if (value == NULL) {
     802           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name");
     803           0 :                 return -1;
     804             :         }
     805           0 :         if (value == Py_None) {
     806           0 :                 object->name = NULL;
     807             :         } else {
     808           0 :                 object->name = NULL;
     809             :                 {
     810             :                         const char *test_str;
     811             :                         const char *talloc_str;
     812           0 :                         PyObject *unicode = NULL;
     813           0 :                         if (PyUnicode_Check(value)) {
     814           0 :                                 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     815           0 :                                 if (unicode == NULL) {
     816           0 :                                         PyErr_NoMemory();
     817           0 :                                         return -1;
     818             :                                 }
     819           0 :                                 test_str = PyBytes_AS_STRING(unicode);
     820           0 :                         } else if (PyBytes_Check(value)) {
     821           0 :                                 test_str = PyBytes_AS_STRING(value);
     822             :                         } else {
     823           0 :                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
     824           0 :                                 return -1;
     825             :                         }
     826           0 :                         talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
     827           0 :                         if (unicode != NULL) {
     828           0 :                                 Py_DECREF(unicode);
     829             :                         }
     830           0 :                         if (talloc_str == NULL) {
     831           0 :                                 PyErr_NoMemory();
     832           0 :                                 return -1;
     833             :                         }
     834           0 :                         object->name = talloc_str;
     835             :                 }
     836             :         }
     837           0 :         return 0;
     838             : }
     839             : 
     840             : static PyGetSetDef py_winreg_StringBuf_getsetters[] = {
     841             :         {
     842             :                 .name = discard_const_p(char, "length"),
     843             :                 .get = py_winreg_StringBuf_get_length,
     844             :                 .set = py_winreg_StringBuf_set_length,
     845             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     846             :         },
     847             :         {
     848             :                 .name = discard_const_p(char, "size"),
     849             :                 .get = py_winreg_StringBuf_get_size,
     850             :                 .set = py_winreg_StringBuf_set_size,
     851             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     852             :         },
     853             :         {
     854             :                 .name = discard_const_p(char, "name"),
     855             :                 .get = py_winreg_StringBuf_get_name,
     856             :                 .set = py_winreg_StringBuf_set_name,
     857             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
     858             :         },
     859             :         { .name = NULL }
     860             : };
     861             : 
     862           0 : static PyObject *py_winreg_StringBuf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
     863             : {
     864           0 :         return pytalloc_new(struct winreg_StringBuf, type);
     865             : }
     866             : 
     867             : 
     868             : static PyTypeObject winreg_StringBuf_Type = {
     869             :         PyVarObject_HEAD_INIT(NULL, 0)
     870             :         .tp_name = "winreg.StringBuf",
     871             :         .tp_getset = py_winreg_StringBuf_getsetters,
     872             :         .tp_methods = NULL,
     873             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     874             :         .tp_new = py_winreg_StringBuf_new,
     875             : };
     876             : 
     877             : 
     878           0 : static PyObject *py_winreg_ValNameBuf_get_length(PyObject *obj, void *closure)
     879             : {
     880           0 :         struct winreg_ValNameBuf *object = (struct winreg_ValNameBuf *)pytalloc_get_ptr(obj);
     881             :         PyObject *py_length;
     882           0 :         py_length = PyLong_FromLong((uint16_t)object->length);
     883           0 :         return py_length;
     884             : }
     885             : 
     886           0 : static int py_winreg_ValNameBuf_set_length(PyObject *py_obj, PyObject *value, void *closure)
     887             : {
     888           0 :         struct winreg_ValNameBuf *object = (struct winreg_ValNameBuf *)pytalloc_get_ptr(py_obj);
     889           0 :         if (value == NULL) {
     890           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->length");
     891           0 :                 return -1;
     892             :         }
     893             :         {
     894           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->length));
     895           0 :                 if (PyLong_Check(value)) {
     896             :                         unsigned long long test_var;
     897           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     898           0 :                         if (PyErr_Occurred() != NULL) {
     899           0 :                                 return -1;
     900             :                         }
     901           0 :                         if (test_var > uint_max) {
     902           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     903             :                                   PyLong_Type.tp_name, uint_max, test_var);
     904           0 :                                 return -1;
     905             :                         }
     906           0 :                         object->length = test_var;
     907             :                 } else {
     908           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     909             :                           PyLong_Type.tp_name);
     910           0 :                         return -1;
     911             :                 }
     912             :         }
     913           0 :         return 0;
     914             : }
     915             : 
     916           0 : static PyObject *py_winreg_ValNameBuf_get_size(PyObject *obj, void *closure)
     917             : {
     918           0 :         struct winreg_ValNameBuf *object = (struct winreg_ValNameBuf *)pytalloc_get_ptr(obj);
     919             :         PyObject *py_size;
     920           0 :         py_size = PyLong_FromLong((uint16_t)object->size);
     921           0 :         return py_size;
     922             : }
     923             : 
     924           0 : static int py_winreg_ValNameBuf_set_size(PyObject *py_obj, PyObject *value, void *closure)
     925             : {
     926           0 :         struct winreg_ValNameBuf *object = (struct winreg_ValNameBuf *)pytalloc_get_ptr(py_obj);
     927           0 :         if (value == NULL) {
     928           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->size");
     929           0 :                 return -1;
     930             :         }
     931             :         {
     932           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->size));
     933           0 :                 if (PyLong_Check(value)) {
     934             :                         unsigned long long test_var;
     935           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
     936           0 :                         if (PyErr_Occurred() != NULL) {
     937           0 :                                 return -1;
     938             :                         }
     939           0 :                         if (test_var > uint_max) {
     940           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
     941             :                                   PyLong_Type.tp_name, uint_max, test_var);
     942           0 :                                 return -1;
     943             :                         }
     944           0 :                         object->size = test_var;
     945             :                 } else {
     946           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
     947             :                           PyLong_Type.tp_name);
     948           0 :                         return -1;
     949             :                 }
     950             :         }
     951           0 :         return 0;
     952             : }
     953             : 
     954           0 : static PyObject *py_winreg_ValNameBuf_get_name(PyObject *obj, void *closure)
     955             : {
     956           0 :         struct winreg_ValNameBuf *object = (struct winreg_ValNameBuf *)pytalloc_get_ptr(obj);
     957             :         PyObject *py_name;
     958           0 :         if (object->name == NULL) {
     959           0 :                 Py_RETURN_NONE;
     960             :         }
     961           0 :         if (object->name == NULL) {
     962           0 :                 py_name = Py_None;
     963           0 :                 Py_INCREF(py_name);
     964             :         } else {
     965           0 :                 if (object->name == NULL) {
     966           0 :                         py_name = Py_None;
     967           0 :                         Py_INCREF(py_name);
     968             :                 } else {
     969           0 :                         py_name = PyUnicode_Decode(object->name, strlen(object->name), "utf-8", "ignore");
     970             :                 }
     971             :         }
     972           0 :         return py_name;
     973             : }
     974             : 
     975           0 : static int py_winreg_ValNameBuf_set_name(PyObject *py_obj, PyObject *value, void *closure)
     976             : {
     977           0 :         struct winreg_ValNameBuf *object = (struct winreg_ValNameBuf *)pytalloc_get_ptr(py_obj);
     978           0 :         if (value == NULL) {
     979           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->name");
     980           0 :                 return -1;
     981             :         }
     982           0 :         if (value == Py_None) {
     983           0 :                 object->name = NULL;
     984             :         } else {
     985           0 :                 object->name = NULL;
     986             :                 {
     987             :                         const char *test_str;
     988             :                         const char *talloc_str;
     989           0 :                         PyObject *unicode = NULL;
     990           0 :                         if (PyUnicode_Check(value)) {
     991           0 :                                 unicode = PyUnicode_AsEncodedString(value, "utf-8", "ignore");
     992           0 :                                 if (unicode == NULL) {
     993           0 :                                         PyErr_NoMemory();
     994           0 :                                         return -1;
     995             :                                 }
     996           0 :                                 test_str = PyBytes_AS_STRING(unicode);
     997           0 :                         } else if (PyBytes_Check(value)) {
     998           0 :                                 test_str = PyBytes_AS_STRING(value);
     999             :                         } else {
    1000           0 :                                 PyErr_Format(PyExc_TypeError, "Expected string or unicode object, got %s", Py_TYPE(value)->tp_name);
    1001           0 :                                 return -1;
    1002             :                         }
    1003           0 :                         talloc_str = talloc_strdup(pytalloc_get_mem_ctx(py_obj), test_str);
    1004           0 :                         if (unicode != NULL) {
    1005           0 :                                 Py_DECREF(unicode);
    1006             :                         }
    1007           0 :                         if (talloc_str == NULL) {
    1008           0 :                                 PyErr_NoMemory();
    1009           0 :                                 return -1;
    1010             :                         }
    1011           0 :                         object->name = talloc_str;
    1012             :                 }
    1013             :         }
    1014           0 :         return 0;
    1015             : }
    1016             : 
    1017             : static PyGetSetDef py_winreg_ValNameBuf_getsetters[] = {
    1018             :         {
    1019             :                 .name = discard_const_p(char, "length"),
    1020             :                 .get = py_winreg_ValNameBuf_get_length,
    1021             :                 .set = py_winreg_ValNameBuf_set_length,
    1022             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    1023             :         },
    1024             :         {
    1025             :                 .name = discard_const_p(char, "size"),
    1026             :                 .get = py_winreg_ValNameBuf_get_size,
    1027             :                 .set = py_winreg_ValNameBuf_set_size,
    1028             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    1029             :         },
    1030             :         {
    1031             :                 .name = discard_const_p(char, "name"),
    1032             :                 .get = py_winreg_ValNameBuf_get_name,
    1033             :                 .set = py_winreg_ValNameBuf_set_name,
    1034             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    1035             :         },
    1036             :         { .name = NULL }
    1037             : };
    1038             : 
    1039           0 : static PyObject *py_winreg_ValNameBuf_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1040             : {
    1041           0 :         return pytalloc_new(struct winreg_ValNameBuf, type);
    1042             : }
    1043             : 
    1044             : 
    1045             : static PyTypeObject winreg_ValNameBuf_Type = {
    1046             :         PyVarObject_HEAD_INIT(NULL, 0)
    1047             :         .tp_name = "winreg.ValNameBuf",
    1048             :         .tp_getset = py_winreg_ValNameBuf_getsetters,
    1049             :         .tp_methods = NULL,
    1050             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1051             :         .tp_new = py_winreg_ValNameBuf_new,
    1052             : };
    1053             : 
    1054             : 
    1055           0 : static PyObject *py_KeySecurityAttribute_get_data_size(PyObject *obj, void *closure)
    1056             : {
    1057           0 :         struct KeySecurityAttribute *object = (struct KeySecurityAttribute *)pytalloc_get_ptr(obj);
    1058             :         PyObject *py_data_size;
    1059           0 :         py_data_size = PyLong_FromUnsignedLongLong((uint32_t)object->data_size);
    1060           0 :         return py_data_size;
    1061             : }
    1062             : 
    1063           0 : static int py_KeySecurityAttribute_set_data_size(PyObject *py_obj, PyObject *value, void *closure)
    1064             : {
    1065           0 :         struct KeySecurityAttribute *object = (struct KeySecurityAttribute *)pytalloc_get_ptr(py_obj);
    1066           0 :         if (value == NULL) {
    1067           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->data_size");
    1068           0 :                 return -1;
    1069             :         }
    1070             :         {
    1071           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->data_size));
    1072           0 :                 if (PyLong_Check(value)) {
    1073             :                         unsigned long long test_var;
    1074           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1075           0 :                         if (PyErr_Occurred() != NULL) {
    1076           0 :                                 return -1;
    1077             :                         }
    1078           0 :                         if (test_var > uint_max) {
    1079           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1080             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1081           0 :                                 return -1;
    1082             :                         }
    1083           0 :                         object->data_size = test_var;
    1084             :                 } else {
    1085           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1086             :                           PyLong_Type.tp_name);
    1087           0 :                         return -1;
    1088             :                 }
    1089             :         }
    1090           0 :         return 0;
    1091             : }
    1092             : 
    1093           0 : static PyObject *py_KeySecurityAttribute_get_sec_data(PyObject *obj, void *closure)
    1094             : {
    1095           0 :         struct KeySecurityAttribute *object = (struct KeySecurityAttribute *)pytalloc_get_ptr(obj);
    1096             :         PyObject *py_sec_data;
    1097           0 :         py_sec_data = pytalloc_reference_ex(&KeySecurityData_Type, pytalloc_get_mem_ctx(obj), &object->sec_data);
    1098           0 :         return py_sec_data;
    1099             : }
    1100             : 
    1101           0 : static int py_KeySecurityAttribute_set_sec_data(PyObject *py_obj, PyObject *value, void *closure)
    1102             : {
    1103           0 :         struct KeySecurityAttribute *object = (struct KeySecurityAttribute *)pytalloc_get_ptr(py_obj);
    1104           0 :         if (value == NULL) {
    1105           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->sec_data");
    1106           0 :                 return -1;
    1107             :         }
    1108           0 :         PY_CHECK_TYPE(&KeySecurityData_Type, value, return -1;);
    1109           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    1110           0 :                 PyErr_NoMemory();
    1111           0 :                 return -1;
    1112             :         }
    1113           0 :         object->sec_data = *(struct KeySecurityData *)pytalloc_get_ptr(value);
    1114           0 :         return 0;
    1115             : }
    1116             : 
    1117           0 : static PyObject *py_KeySecurityAttribute_get_inherit(PyObject *obj, void *closure)
    1118             : {
    1119           0 :         struct KeySecurityAttribute *object = (struct KeySecurityAttribute *)pytalloc_get_ptr(obj);
    1120             :         PyObject *py_inherit;
    1121           0 :         py_inherit = PyLong_FromLong((uint16_t)object->inherit);
    1122           0 :         return py_inherit;
    1123             : }
    1124             : 
    1125           0 : static int py_KeySecurityAttribute_set_inherit(PyObject *py_obj, PyObject *value, void *closure)
    1126             : {
    1127           0 :         struct KeySecurityAttribute *object = (struct KeySecurityAttribute *)pytalloc_get_ptr(py_obj);
    1128           0 :         if (value == NULL) {
    1129           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->inherit");
    1130           0 :                 return -1;
    1131             :         }
    1132             :         {
    1133           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->inherit));
    1134           0 :                 if (PyLong_Check(value)) {
    1135             :                         unsigned long long test_var;
    1136           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1137           0 :                         if (PyErr_Occurred() != NULL) {
    1138           0 :                                 return -1;
    1139             :                         }
    1140           0 :                         if (test_var > uint_max) {
    1141           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1142             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1143           0 :                                 return -1;
    1144             :                         }
    1145           0 :                         object->inherit = test_var;
    1146             :                 } else {
    1147           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1148             :                           PyLong_Type.tp_name);
    1149           0 :                         return -1;
    1150             :                 }
    1151             :         }
    1152           0 :         return 0;
    1153             : }
    1154             : 
    1155             : static PyGetSetDef py_KeySecurityAttribute_getsetters[] = {
    1156             :         {
    1157             :                 .name = discard_const_p(char, "data_size"),
    1158             :                 .get = py_KeySecurityAttribute_get_data_size,
    1159             :                 .set = py_KeySecurityAttribute_set_data_size,
    1160             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1161             :         },
    1162             :         {
    1163             :                 .name = discard_const_p(char, "sec_data"),
    1164             :                 .get = py_KeySecurityAttribute_get_sec_data,
    1165             :                 .set = py_KeySecurityAttribute_set_sec_data,
    1166             :                 .doc = discard_const_p(char, "PIDL-generated element of base type KeySecurityData")
    1167             :         },
    1168             :         {
    1169             :                 .name = discard_const_p(char, "inherit"),
    1170             :                 .get = py_KeySecurityAttribute_get_inherit,
    1171             :                 .set = py_KeySecurityAttribute_set_inherit,
    1172             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    1173             :         },
    1174             :         { .name = NULL }
    1175             : };
    1176             : 
    1177           0 : static PyObject *py_KeySecurityAttribute_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1178             : {
    1179           0 :         return pytalloc_new(struct KeySecurityAttribute, type);
    1180             : }
    1181             : 
    1182             : 
    1183             : static PyTypeObject KeySecurityAttribute_Type = {
    1184             :         PyVarObject_HEAD_INIT(NULL, 0)
    1185             :         .tp_name = "winreg.KeySecurityAttribute",
    1186             :         .tp_getset = py_KeySecurityAttribute_getsetters,
    1187             :         .tp_methods = NULL,
    1188             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1189             :         .tp_new = py_KeySecurityAttribute_new,
    1190             : };
    1191             : 
    1192             : 
    1193           0 : static PyObject *py_QueryMultipleValue_get_ve_valuename(PyObject *obj, void *closure)
    1194             : {
    1195           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(obj);
    1196             :         PyObject *py_ve_valuename;
    1197           0 :         if (object->ve_valuename == NULL) {
    1198           0 :                 Py_RETURN_NONE;
    1199             :         }
    1200           0 :         if (object->ve_valuename == NULL) {
    1201           0 :                 py_ve_valuename = Py_None;
    1202           0 :                 Py_INCREF(py_ve_valuename);
    1203             :         } else {
    1204           0 :                 py_ve_valuename = pytalloc_reference_ex(&winreg_ValNameBuf_Type, object->ve_valuename, object->ve_valuename);
    1205             :         }
    1206           0 :         return py_ve_valuename;
    1207             : }
    1208             : 
    1209           0 : static int py_QueryMultipleValue_set_ve_valuename(PyObject *py_obj, PyObject *value, void *closure)
    1210             : {
    1211           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(py_obj);
    1212           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->ve_valuename));
    1213           0 :         if (value == NULL) {
    1214           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ve_valuename");
    1215           0 :                 return -1;
    1216             :         }
    1217           0 :         if (value == Py_None) {
    1218           0 :                 object->ve_valuename = NULL;
    1219             :         } else {
    1220           0 :                 object->ve_valuename = NULL;
    1221           0 :                 PY_CHECK_TYPE(&winreg_ValNameBuf_Type, value, return -1;);
    1222           0 :                 if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    1223           0 :                         PyErr_NoMemory();
    1224           0 :                         return -1;
    1225             :                 }
    1226           0 :                 object->ve_valuename = (struct winreg_ValNameBuf *)pytalloc_get_ptr(value);
    1227             :         }
    1228           0 :         return 0;
    1229             : }
    1230             : 
    1231           0 : static PyObject *py_QueryMultipleValue_get_ve_valuelen(PyObject *obj, void *closure)
    1232             : {
    1233           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(obj);
    1234             :         PyObject *py_ve_valuelen;
    1235           0 :         py_ve_valuelen = PyLong_FromUnsignedLongLong((uint32_t)object->ve_valuelen);
    1236           0 :         return py_ve_valuelen;
    1237             : }
    1238             : 
    1239           0 : static int py_QueryMultipleValue_set_ve_valuelen(PyObject *py_obj, PyObject *value, void *closure)
    1240             : {
    1241           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(py_obj);
    1242           0 :         if (value == NULL) {
    1243           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ve_valuelen");
    1244           0 :                 return -1;
    1245             :         }
    1246             :         {
    1247           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->ve_valuelen));
    1248           0 :                 if (PyLong_Check(value)) {
    1249             :                         unsigned long long test_var;
    1250           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1251           0 :                         if (PyErr_Occurred() != NULL) {
    1252           0 :                                 return -1;
    1253             :                         }
    1254           0 :                         if (test_var > uint_max) {
    1255           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1256             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1257           0 :                                 return -1;
    1258             :                         }
    1259           0 :                         object->ve_valuelen = test_var;
    1260             :                 } else {
    1261           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1262             :                           PyLong_Type.tp_name);
    1263           0 :                         return -1;
    1264             :                 }
    1265             :         }
    1266           0 :         return 0;
    1267             : }
    1268             : 
    1269           0 : static PyObject *py_QueryMultipleValue_get_ve_valueptr(PyObject *obj, void *closure)
    1270             : {
    1271           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(obj);
    1272             :         PyObject *py_ve_valueptr;
    1273           0 :         py_ve_valueptr = PyLong_FromUnsignedLongLong((uint32_t)object->ve_valueptr);
    1274           0 :         return py_ve_valueptr;
    1275             : }
    1276             : 
    1277           0 : static int py_QueryMultipleValue_set_ve_valueptr(PyObject *py_obj, PyObject *value, void *closure)
    1278             : {
    1279           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(py_obj);
    1280           0 :         if (value == NULL) {
    1281           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ve_valueptr");
    1282           0 :                 return -1;
    1283             :         }
    1284             :         {
    1285           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->ve_valueptr));
    1286           0 :                 if (PyLong_Check(value)) {
    1287             :                         unsigned long long test_var;
    1288           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1289           0 :                         if (PyErr_Occurred() != NULL) {
    1290           0 :                                 return -1;
    1291             :                         }
    1292           0 :                         if (test_var > uint_max) {
    1293           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1294             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1295           0 :                                 return -1;
    1296             :                         }
    1297           0 :                         object->ve_valueptr = test_var;
    1298             :                 } else {
    1299           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1300             :                           PyLong_Type.tp_name);
    1301           0 :                         return -1;
    1302             :                 }
    1303             :         }
    1304           0 :         return 0;
    1305             : }
    1306             : 
    1307           0 : static PyObject *py_QueryMultipleValue_get_ve_type(PyObject *obj, void *closure)
    1308             : {
    1309           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(obj);
    1310             :         PyObject *py_ve_type;
    1311           0 :         py_ve_type = PyLong_FromUnsignedLongLong((uint32_t)object->ve_type);
    1312           0 :         return py_ve_type;
    1313             : }
    1314             : 
    1315           0 : static int py_QueryMultipleValue_set_ve_type(PyObject *py_obj, PyObject *value, void *closure)
    1316             : {
    1317           0 :         struct QueryMultipleValue *object = (struct QueryMultipleValue *)pytalloc_get_ptr(py_obj);
    1318           0 :         if (value == NULL) {
    1319           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->ve_type");
    1320           0 :                 return -1;
    1321             :         }
    1322             :         {
    1323           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->ve_type));
    1324           0 :                 if (PyLong_Check(value)) {
    1325             :                         unsigned long long test_var;
    1326           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1327           0 :                         if (PyErr_Occurred() != NULL) {
    1328           0 :                                 return -1;
    1329             :                         }
    1330           0 :                         if (test_var > uint_max) {
    1331           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1332             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1333           0 :                                 return -1;
    1334             :                         }
    1335           0 :                         object->ve_type = test_var;
    1336             :                 } else {
    1337           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1338             :                           PyLong_Type.tp_name);
    1339           0 :                         return -1;
    1340             :                 }
    1341             :         }
    1342           0 :         return 0;
    1343             : }
    1344             : 
    1345             : static PyGetSetDef py_QueryMultipleValue_getsetters[] = {
    1346             :         {
    1347             :                 .name = discard_const_p(char, "ve_valuename"),
    1348             :                 .get = py_QueryMultipleValue_get_ve_valuename,
    1349             :                 .set = py_QueryMultipleValue_set_ve_valuename,
    1350             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_ValNameBuf")
    1351             :         },
    1352             :         {
    1353             :                 .name = discard_const_p(char, "ve_valuelen"),
    1354             :                 .get = py_QueryMultipleValue_get_ve_valuelen,
    1355             :                 .set = py_QueryMultipleValue_set_ve_valuelen,
    1356             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1357             :         },
    1358             :         {
    1359             :                 .name = discard_const_p(char, "ve_valueptr"),
    1360             :                 .get = py_QueryMultipleValue_get_ve_valueptr,
    1361             :                 .set = py_QueryMultipleValue_set_ve_valueptr,
    1362             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    1363             :         },
    1364             :         {
    1365             :                 .name = discard_const_p(char, "ve_type"),
    1366             :                 .get = py_QueryMultipleValue_get_ve_type,
    1367             :                 .set = py_QueryMultipleValue_set_ve_type,
    1368             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_Type")
    1369             :         },
    1370             :         { .name = NULL }
    1371             : };
    1372             : 
    1373           0 : static PyObject *py_QueryMultipleValue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1374             : {
    1375           0 :         return pytalloc_new(struct QueryMultipleValue, type);
    1376             : }
    1377             : 
    1378             : 
    1379             : static PyTypeObject QueryMultipleValue_Type = {
    1380             :         PyVarObject_HEAD_INIT(NULL, 0)
    1381             :         .tp_name = "winreg.QueryMultipleValue",
    1382             :         .tp_getset = py_QueryMultipleValue_getsetters,
    1383             :         .tp_methods = NULL,
    1384             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1385             :         .tp_new = py_QueryMultipleValue_new,
    1386             : };
    1387             : 
    1388             : 
    1389             : 
    1390           0 : static PyObject *py_winreg_OpenHKCR_in_get_system_name(PyObject *obj, void *closure)
    1391             : {
    1392           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(obj);
    1393             :         PyObject *py_system_name;
    1394           0 :         if (object->in.system_name == NULL) {
    1395           0 :                 Py_RETURN_NONE;
    1396             :         }
    1397           0 :         if (object->in.system_name == NULL) {
    1398           0 :                 py_system_name = Py_None;
    1399           0 :                 Py_INCREF(py_system_name);
    1400             :         } else {
    1401           0 :                 py_system_name = PyLong_FromLong((uint16_t)*object->in.system_name);
    1402             :         }
    1403           0 :         return py_system_name;
    1404             : }
    1405             : 
    1406           0 : static int py_winreg_OpenHKCR_in_set_system_name(PyObject *py_obj, PyObject *value, void *closure)
    1407             : {
    1408           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1409           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.system_name));
    1410           0 :         if (value == NULL) {
    1411           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.system_name");
    1412           0 :                 return -1;
    1413             :         }
    1414           0 :         if (value == Py_None) {
    1415           0 :                 object->in.system_name = NULL;
    1416             :         } else {
    1417           0 :                 object->in.system_name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.system_name);
    1418           0 :                 if (object->in.system_name == NULL) {
    1419           0 :                         PyErr_NoMemory();
    1420           0 :                         return -1;
    1421             :                 }
    1422             :                 {
    1423           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.system_name));
    1424           0 :                         if (PyLong_Check(value)) {
    1425             :                                 unsigned long long test_var;
    1426           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    1427           0 :                                 if (PyErr_Occurred() != NULL) {
    1428           0 :                                         return -1;
    1429             :                                 }
    1430           0 :                                 if (test_var > uint_max) {
    1431           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1432             :                                           PyLong_Type.tp_name, uint_max, test_var);
    1433           0 :                                         return -1;
    1434             :                                 }
    1435           0 :                                 *object->in.system_name = test_var;
    1436             :                         } else {
    1437           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1438             :                                   PyLong_Type.tp_name);
    1439           0 :                                 return -1;
    1440             :                         }
    1441             :                 }
    1442             :         }
    1443           0 :         return 0;
    1444             : }
    1445             : 
    1446           0 : static PyObject *py_winreg_OpenHKCR_in_get_access_mask(PyObject *obj, void *closure)
    1447             : {
    1448           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(obj);
    1449             :         PyObject *py_access_mask;
    1450           0 :         py_access_mask = PyLong_FromUnsignedLongLong((uint32_t)object->in.access_mask);
    1451           0 :         return py_access_mask;
    1452             : }
    1453             : 
    1454           0 : static int py_winreg_OpenHKCR_in_set_access_mask(PyObject *py_obj, PyObject *value, void *closure)
    1455             : {
    1456           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1457           0 :         if (value == NULL) {
    1458           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.access_mask");
    1459           0 :                 return -1;
    1460             :         }
    1461             :         {
    1462           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.access_mask));
    1463           0 :                 if (PyLong_Check(value)) {
    1464             :                         unsigned long long test_var;
    1465           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    1466           0 :                         if (PyErr_Occurred() != NULL) {
    1467           0 :                                 return -1;
    1468             :                         }
    1469           0 :                         if (test_var > uint_max) {
    1470           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1471             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1472           0 :                                 return -1;
    1473             :                         }
    1474           0 :                         object->in.access_mask = test_var;
    1475             :                 } else {
    1476           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1477             :                           PyLong_Type.tp_name);
    1478           0 :                         return -1;
    1479             :                 }
    1480             :         }
    1481           0 :         return 0;
    1482             : }
    1483             : 
    1484           0 : static PyObject *py_winreg_OpenHKCR_out_get_handle(PyObject *obj, void *closure)
    1485             : {
    1486           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(obj);
    1487             :         PyObject *py_handle;
    1488           0 :         if (object->out.handle == NULL) {
    1489           0 :                 Py_RETURN_NONE;
    1490             :         }
    1491           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->out.handle, object->out.handle);
    1492           0 :         return py_handle;
    1493             : }
    1494             : 
    1495           0 : static int py_winreg_OpenHKCR_out_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    1496             : {
    1497           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1498           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.handle));
    1499           0 :         if (value == NULL) {
    1500           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.handle");
    1501           0 :                 return -1;
    1502             :         }
    1503           0 :         object->out.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.handle);
    1504           0 :         if (object->out.handle == NULL) {
    1505           0 :                 PyErr_NoMemory();
    1506           0 :                 return -1;
    1507             :         }
    1508           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    1509           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    1510           0 :                 PyErr_NoMemory();
    1511           0 :                 return -1;
    1512             :         }
    1513           0 :         object->out.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    1514           0 :         return 0;
    1515             : }
    1516             : 
    1517           0 : static PyObject *py_winreg_OpenHKCR_get_result(PyObject *obj, void *closure)
    1518             : {
    1519           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(obj);
    1520             :         PyObject *py_result;
    1521           0 :         py_result = PyErr_FromWERROR(object->out.result);
    1522           0 :         return py_result;
    1523             : }
    1524             : 
    1525           0 : static int py_winreg_OpenHKCR_set_result(PyObject *py_obj, PyObject *value, void *closure)
    1526             : {
    1527           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1528           0 :         if (value == NULL) {
    1529           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    1530           0 :                 return -1;
    1531             :         }
    1532           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    1533           0 :         return 0;
    1534             : }
    1535             : 
    1536             : static PyGetSetDef py_winreg_OpenHKCR_getsetters[] = {
    1537             :         {
    1538             :                 .name = discard_const_p(char, "in_system_name"),
    1539             :                 .get = py_winreg_OpenHKCR_in_get_system_name,
    1540             :                 .set = py_winreg_OpenHKCR_in_set_system_name,
    1541             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    1542             :         },
    1543             :         {
    1544             :                 .name = discard_const_p(char, "in_access_mask"),
    1545             :                 .get = py_winreg_OpenHKCR_in_get_access_mask,
    1546             :                 .set = py_winreg_OpenHKCR_in_set_access_mask,
    1547             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_AccessMask")
    1548             :         },
    1549             :         {
    1550             :                 .name = discard_const_p(char, "out_handle"),
    1551             :                 .get = py_winreg_OpenHKCR_out_get_handle,
    1552             :                 .set = py_winreg_OpenHKCR_out_set_handle,
    1553             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    1554             :         },
    1555             :         {
    1556             :                 .name = discard_const_p(char, "result"),
    1557             :                 .get = py_winreg_OpenHKCR_get_result,
    1558             :                 .set = py_winreg_OpenHKCR_set_result,
    1559             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    1560             :         },
    1561             :         { .name = NULL }
    1562             : };
    1563             : 
    1564           0 : static PyObject *py_winreg_OpenHKCR_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    1565             : {
    1566           0 :         PyObject *self = pytalloc_new(struct winreg_OpenHKCR, type);
    1567           0 :         struct winreg_OpenHKCR *_self = (struct winreg_OpenHKCR *)pytalloc_get_ptr(self);
    1568           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    1569           0 :         _self->out.handle = talloc_zero(mem_ctx, struct policy_handle);
    1570           0 :         return self;
    1571             : }
    1572             : 
    1573           0 : static PyObject *py_winreg_OpenHKCR_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    1574             : {
    1575             : 
    1576             : 
    1577           0 :         return PyLong_FromLong(0);
    1578             : }
    1579             : 
    1580           0 : static PyObject *py_winreg_OpenHKCR_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    1581             : {
    1582           0 :         const struct ndr_interface_call *call = NULL;
    1583           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1584           0 :         PyObject *ret = NULL;
    1585           0 :         struct ndr_push *push = NULL;
    1586             :         DATA_BLOB blob;
    1587             :         enum ndr_err_code err;
    1588             : 
    1589           0 :         if (ndr_table_winreg.num_calls < 1) {
    1590           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKCR_ndr_pack");
    1591           0 :                 return NULL;
    1592             :         }
    1593           0 :         call = &ndr_table_winreg.calls[0];
    1594             : 
    1595           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    1596           0 :         if (push == NULL) {
    1597           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    1598           0 :                 return NULL;
    1599             :         }
    1600             : 
    1601           0 :         push->flags |= ndr_push_flags;
    1602             : 
    1603           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    1604           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1605           0 :                 TALLOC_FREE(push);
    1606           0 :                 PyErr_SetNdrError(err);
    1607           0 :                 return NULL;
    1608             :         }
    1609           0 :         blob = ndr_push_blob(push);
    1610           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    1611           0 :         TALLOC_FREE(push);
    1612           0 :         return ret;
    1613             : }
    1614             : 
    1615           0 : static PyObject *py_winreg_OpenHKCR_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1616             : {
    1617           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    1618           0 :         PyObject *bigendian_obj = NULL;
    1619           0 :         PyObject *ndr64_obj = NULL;
    1620           0 :         uint32_t ndr_push_flags = 0;
    1621             : 
    1622           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    1623             :                 discard_const_p(char *, kwnames),
    1624             :                 &bigendian_obj,
    1625             :                 &ndr64_obj)) {
    1626           0 :                 return NULL;
    1627             :         }
    1628             : 
    1629           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1630           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    1631             :         }
    1632           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1633           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    1634             :         }
    1635             : 
    1636           0 :         return py_winreg_OpenHKCR_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    1637             : }
    1638             : 
    1639           0 : static PyObject *py_winreg_OpenHKCR_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1640             : {
    1641           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    1642           0 :         PyObject *bigendian_obj = NULL;
    1643           0 :         PyObject *ndr64_obj = NULL;
    1644           0 :         uint32_t ndr_push_flags = 0;
    1645             : 
    1646           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    1647             :                 discard_const_p(char *, kwnames),
    1648             :                 &bigendian_obj,
    1649             :                 &ndr64_obj)) {
    1650           0 :                 return NULL;
    1651             :         }
    1652             : 
    1653           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1654           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    1655             :         }
    1656           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1657           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    1658             :         }
    1659             : 
    1660           0 :         return py_winreg_OpenHKCR_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    1661             : }
    1662             : 
    1663           0 : static PyObject *py_winreg_OpenHKCR_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    1664             : {
    1665           0 :         const struct ndr_interface_call *call = NULL;
    1666           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1667           0 :         struct ndr_pull *pull = NULL;
    1668             :         enum ndr_err_code err;
    1669             : 
    1670           0 :         if (ndr_table_winreg.num_calls < 1) {
    1671           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKCR_ndr_unpack");
    1672           0 :                 return NULL;
    1673             :         }
    1674           0 :         call = &ndr_table_winreg.calls[0];
    1675             : 
    1676           0 :         pull = ndr_pull_init_blob(blob, object);
    1677           0 :         if (pull == NULL) {
    1678           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    1679           0 :                 return NULL;
    1680             :         }
    1681             : 
    1682           0 :         pull->flags |= ndr_pull_flags;
    1683             : 
    1684           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    1685           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    1686           0 :                 TALLOC_FREE(pull);
    1687           0 :                 PyErr_SetNdrError(err);
    1688           0 :                 return NULL;
    1689             :         }
    1690           0 :         if (!allow_remaining) {
    1691             :                 uint32_t highest_ofs;
    1692             : 
    1693           0 :                 if (pull->offset > pull->relative_highest_offset) {
    1694           0 :                         highest_ofs = pull->offset;
    1695             :                 } else {
    1696           0 :                         highest_ofs = pull->relative_highest_offset;
    1697             :                 }
    1698           0 :                 if (highest_ofs < pull->data_size) {
    1699           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    1700             :                                 "not all bytes consumed ofs[%u] size[%u]",
    1701             :                                 highest_ofs, pull->data_size);
    1702           0 :                         TALLOC_FREE(pull);
    1703           0 :                         PyErr_SetNdrError(err);
    1704           0 :                         return NULL;
    1705             :                 }
    1706             :         }
    1707             : 
    1708           0 :         TALLOC_FREE(pull);
    1709           0 :         Py_RETURN_NONE;
    1710             : }
    1711             : 
    1712           0 : static PyObject *py_winreg_OpenHKCR_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1713             : {
    1714             :         DATA_BLOB blob;
    1715           0 :         Py_ssize_t blob_length = 0;
    1716           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    1717           0 :         PyObject *bigendian_obj = NULL;
    1718           0 :         PyObject *ndr64_obj = NULL;
    1719           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    1720           0 :         PyObject *allow_remaining_obj = NULL;
    1721           0 :         bool allow_remaining = false;
    1722             : 
    1723           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    1724             :                 discard_const_p(char *, kwnames),
    1725             :                 &blob.data, &blob_length,
    1726             :                 &bigendian_obj,
    1727             :                 &ndr64_obj,
    1728             :                 &allow_remaining_obj)) {
    1729           0 :                 return NULL;
    1730             :         }
    1731           0 :         blob.length = blob_length;
    1732             : 
    1733           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1734           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    1735             :         }
    1736           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1737           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    1738             :         }
    1739             : 
    1740           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    1741           0 :                 allow_remaining = true;
    1742             :         }
    1743             : 
    1744           0 :         return py_winreg_OpenHKCR_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    1745             : }
    1746             : 
    1747           0 : static PyObject *py_winreg_OpenHKCR_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    1748             : {
    1749             :         DATA_BLOB blob;
    1750           0 :         Py_ssize_t blob_length = 0;
    1751           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    1752           0 :         PyObject *bigendian_obj = NULL;
    1753           0 :         PyObject *ndr64_obj = NULL;
    1754           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    1755           0 :         PyObject *allow_remaining_obj = NULL;
    1756           0 :         bool allow_remaining = false;
    1757             : 
    1758           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    1759             :                 discard_const_p(char *, kwnames),
    1760             :                 &blob.data, &blob_length,
    1761             :                 &bigendian_obj,
    1762             :                 &ndr64_obj,
    1763             :                 &allow_remaining_obj)) {
    1764           0 :                 return NULL;
    1765             :         }
    1766           0 :         blob.length = blob_length;
    1767             : 
    1768           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    1769           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    1770             :         }
    1771           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    1772           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    1773             :         }
    1774             : 
    1775           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    1776           0 :                 allow_remaining = true;
    1777             :         }
    1778             : 
    1779           0 :         return py_winreg_OpenHKCR_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    1780             : }
    1781             : 
    1782           0 : static PyObject *py_winreg_OpenHKCR_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    1783             : {
    1784           0 :         const struct ndr_interface_call *call = NULL;
    1785           0 :         struct winreg_OpenHKCR *object = (struct winreg_OpenHKCR *)pytalloc_get_ptr(py_obj);
    1786             :         PyObject *ret;
    1787             :         char *retstr;
    1788             : 
    1789           0 :         if (ndr_table_winreg.num_calls < 1) {
    1790           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKCR_ndr_print");
    1791           0 :                 return NULL;
    1792             :         }
    1793           0 :         call = &ndr_table_winreg.calls[0];
    1794             : 
    1795           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    1796           0 :         ret = PyUnicode_FromString(retstr);
    1797           0 :         TALLOC_FREE(retstr);
    1798             : 
    1799           0 :         return ret;
    1800             : }
    1801             : 
    1802           0 : static PyObject *py_winreg_OpenHKCR_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    1803             : {
    1804           0 :         return py_winreg_OpenHKCR_ndr_print(py_obj, "winreg_OpenHKCR_in", NDR_IN);
    1805             : }
    1806             : 
    1807           0 : static PyObject *py_winreg_OpenHKCR_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    1808             : {
    1809           0 :         return py_winreg_OpenHKCR_ndr_print(py_obj, "winreg_OpenHKCR_out", NDR_OUT);
    1810             : }
    1811             : 
    1812             : static PyMethodDef py_winreg_OpenHKCR_methods[] = {
    1813             :         { "opnum", (PyCFunction)py_winreg_OpenHKCR_ndr_opnum, METH_NOARGS|METH_CLASS,
    1814             :                 "winreg.OpenHKCR.opnum() -> 0 (0x00) " },
    1815             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCR_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    1816             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    1817             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCR_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    1818             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    1819             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCR_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    1820             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    1821             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCR_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    1822             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    1823             :         { "__ndr_print_in__", (PyCFunction)py_winreg_OpenHKCR_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    1824             :         { "__ndr_print_out__", (PyCFunction)py_winreg_OpenHKCR_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    1825             :         { NULL, NULL, 0, NULL }
    1826             : };
    1827             : 
    1828             : 
    1829             : static PyTypeObject winreg_OpenHKCR_Type = {
    1830             :         PyVarObject_HEAD_INIT(NULL, 0)
    1831             :         .tp_name = "winreg.OpenHKCR",
    1832             :         .tp_getset = py_winreg_OpenHKCR_getsetters,
    1833             :         .tp_methods = py_winreg_OpenHKCR_methods,
    1834             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    1835             :         .tp_new = py_winreg_OpenHKCR_new,
    1836             : };
    1837             : 
    1838           0 : static bool pack_py_winreg_OpenHKCR_args_in(PyObject *args, PyObject *kwargs, struct winreg_OpenHKCR *r)
    1839             : {
    1840             :         PyObject *py_system_name;
    1841             :         PyObject *py_access_mask;
    1842           0 :         const char *kwnames[] = {
    1843             :                 "system_name", "access_mask", NULL
    1844             :         };
    1845             : 
    1846           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_OpenHKCR", discard_const_p(char *, kwnames), &py_system_name, &py_access_mask)) {
    1847           0 :                 return false;
    1848             :         }
    1849             : 
    1850           0 :         if (py_system_name == NULL) {
    1851           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.system_name");
    1852           0 :                 return false;
    1853             :         }
    1854           0 :         if (py_system_name == Py_None) {
    1855           0 :                 r->in.system_name = NULL;
    1856             :         } else {
    1857           0 :                 r->in.system_name = talloc_ptrtype(r, r->in.system_name);
    1858           0 :                 if (r->in.system_name == NULL) {
    1859           0 :                         PyErr_NoMemory();
    1860           0 :                         return false;
    1861             :                 }
    1862             :                 {
    1863           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.system_name));
    1864           0 :                         if (PyLong_Check(py_system_name)) {
    1865             :                                 unsigned long long test_var;
    1866           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_system_name);
    1867           0 :                                 if (PyErr_Occurred() != NULL) {
    1868           0 :                                         return false;
    1869             :                                 }
    1870           0 :                                 if (test_var > uint_max) {
    1871           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1872             :                                           PyLong_Type.tp_name, uint_max, test_var);
    1873           0 :                                         return false;
    1874             :                                 }
    1875           0 :                                 *r->in.system_name = test_var;
    1876             :                         } else {
    1877           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1878             :                                   PyLong_Type.tp_name);
    1879           0 :                                 return false;
    1880             :                         }
    1881             :                 }
    1882             :         }
    1883           0 :         if (py_access_mask == NULL) {
    1884           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.access_mask");
    1885           0 :                 return false;
    1886             :         }
    1887             :         {
    1888           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.access_mask));
    1889           0 :                 if (PyLong_Check(py_access_mask)) {
    1890             :                         unsigned long long test_var;
    1891           0 :                         test_var = PyLong_AsUnsignedLongLong(py_access_mask);
    1892           0 :                         if (PyErr_Occurred() != NULL) {
    1893           0 :                                 return false;
    1894             :                         }
    1895           0 :                         if (test_var > uint_max) {
    1896           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1897             :                                   PyLong_Type.tp_name, uint_max, test_var);
    1898           0 :                                 return false;
    1899             :                         }
    1900           0 :                         r->in.access_mask = test_var;
    1901             :                 } else {
    1902           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1903             :                           PyLong_Type.tp_name);
    1904           0 :                         return false;
    1905             :                 }
    1906             :         }
    1907           0 :         return true;
    1908             : }
    1909             : 
    1910           0 : static PyObject *unpack_py_winreg_OpenHKCR_args_out(struct winreg_OpenHKCR *r)
    1911             : {
    1912             :         PyObject *result;
    1913             :         PyObject *py_handle;
    1914           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, r->out.handle, r->out.handle);
    1915           0 :         result = py_handle;
    1916           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    1917           0 :                 PyErr_SetWERROR(r->out.result);
    1918           0 :                 return NULL;
    1919             :         }
    1920             : 
    1921           0 :         return result;
    1922             : }
    1923             : 
    1924             : 
    1925           0 : static PyObject *py_winreg_OpenHKCU_in_get_system_name(PyObject *obj, void *closure)
    1926             : {
    1927           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(obj);
    1928             :         PyObject *py_system_name;
    1929           0 :         if (object->in.system_name == NULL) {
    1930           0 :                 Py_RETURN_NONE;
    1931             :         }
    1932           0 :         if (object->in.system_name == NULL) {
    1933           0 :                 py_system_name = Py_None;
    1934           0 :                 Py_INCREF(py_system_name);
    1935             :         } else {
    1936           0 :                 py_system_name = PyLong_FromLong((uint16_t)*object->in.system_name);
    1937             :         }
    1938           0 :         return py_system_name;
    1939             : }
    1940             : 
    1941           0 : static int py_winreg_OpenHKCU_in_set_system_name(PyObject *py_obj, PyObject *value, void *closure)
    1942             : {
    1943           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    1944           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.system_name));
    1945           0 :         if (value == NULL) {
    1946           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.system_name");
    1947           0 :                 return -1;
    1948             :         }
    1949           0 :         if (value == Py_None) {
    1950           0 :                 object->in.system_name = NULL;
    1951             :         } else {
    1952           0 :                 object->in.system_name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.system_name);
    1953           0 :                 if (object->in.system_name == NULL) {
    1954           0 :                         PyErr_NoMemory();
    1955           0 :                         return -1;
    1956             :                 }
    1957             :                 {
    1958           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.system_name));
    1959           0 :                         if (PyLong_Check(value)) {
    1960             :                                 unsigned long long test_var;
    1961           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    1962           0 :                                 if (PyErr_Occurred() != NULL) {
    1963           0 :                                         return -1;
    1964             :                                 }
    1965           0 :                                 if (test_var > uint_max) {
    1966           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    1967             :                                           PyLong_Type.tp_name, uint_max, test_var);
    1968           0 :                                         return -1;
    1969             :                                 }
    1970           0 :                                 *object->in.system_name = test_var;
    1971             :                         } else {
    1972           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    1973             :                                   PyLong_Type.tp_name);
    1974           0 :                                 return -1;
    1975             :                         }
    1976             :                 }
    1977             :         }
    1978           0 :         return 0;
    1979             : }
    1980             : 
    1981           0 : static PyObject *py_winreg_OpenHKCU_in_get_access_mask(PyObject *obj, void *closure)
    1982             : {
    1983           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(obj);
    1984             :         PyObject *py_access_mask;
    1985           0 :         py_access_mask = PyLong_FromUnsignedLongLong((uint32_t)object->in.access_mask);
    1986           0 :         return py_access_mask;
    1987             : }
    1988             : 
    1989           0 : static int py_winreg_OpenHKCU_in_set_access_mask(PyObject *py_obj, PyObject *value, void *closure)
    1990             : {
    1991           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    1992           0 :         if (value == NULL) {
    1993           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.access_mask");
    1994           0 :                 return -1;
    1995             :         }
    1996             :         {
    1997           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.access_mask));
    1998           0 :                 if (PyLong_Check(value)) {
    1999             :                         unsigned long long test_var;
    2000           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    2001           0 :                         if (PyErr_Occurred() != NULL) {
    2002           0 :                                 return -1;
    2003             :                         }
    2004           0 :                         if (test_var > uint_max) {
    2005           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2006             :                                   PyLong_Type.tp_name, uint_max, test_var);
    2007           0 :                                 return -1;
    2008             :                         }
    2009           0 :                         object->in.access_mask = test_var;
    2010             :                 } else {
    2011           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2012             :                           PyLong_Type.tp_name);
    2013           0 :                         return -1;
    2014             :                 }
    2015             :         }
    2016           0 :         return 0;
    2017             : }
    2018             : 
    2019           0 : static PyObject *py_winreg_OpenHKCU_out_get_handle(PyObject *obj, void *closure)
    2020             : {
    2021           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(obj);
    2022             :         PyObject *py_handle;
    2023           0 :         if (object->out.handle == NULL) {
    2024           0 :                 Py_RETURN_NONE;
    2025             :         }
    2026           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->out.handle, object->out.handle);
    2027           0 :         return py_handle;
    2028             : }
    2029             : 
    2030           0 : static int py_winreg_OpenHKCU_out_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    2031             : {
    2032           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    2033           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.handle));
    2034           0 :         if (value == NULL) {
    2035           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.handle");
    2036           0 :                 return -1;
    2037             :         }
    2038           0 :         object->out.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.handle);
    2039           0 :         if (object->out.handle == NULL) {
    2040           0 :                 PyErr_NoMemory();
    2041           0 :                 return -1;
    2042             :         }
    2043           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    2044           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    2045           0 :                 PyErr_NoMemory();
    2046           0 :                 return -1;
    2047             :         }
    2048           0 :         object->out.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    2049           0 :         return 0;
    2050             : }
    2051             : 
    2052           0 : static PyObject *py_winreg_OpenHKCU_get_result(PyObject *obj, void *closure)
    2053             : {
    2054           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(obj);
    2055             :         PyObject *py_result;
    2056           0 :         py_result = PyErr_FromWERROR(object->out.result);
    2057           0 :         return py_result;
    2058             : }
    2059             : 
    2060           0 : static int py_winreg_OpenHKCU_set_result(PyObject *py_obj, PyObject *value, void *closure)
    2061             : {
    2062           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    2063           0 :         if (value == NULL) {
    2064           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    2065           0 :                 return -1;
    2066             :         }
    2067           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    2068           0 :         return 0;
    2069             : }
    2070             : 
    2071             : static PyGetSetDef py_winreg_OpenHKCU_getsetters[] = {
    2072             :         {
    2073             :                 .name = discard_const_p(char, "in_system_name"),
    2074             :                 .get = py_winreg_OpenHKCU_in_get_system_name,
    2075             :                 .set = py_winreg_OpenHKCU_in_set_system_name,
    2076             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    2077             :         },
    2078             :         {
    2079             :                 .name = discard_const_p(char, "in_access_mask"),
    2080             :                 .get = py_winreg_OpenHKCU_in_get_access_mask,
    2081             :                 .set = py_winreg_OpenHKCU_in_set_access_mask,
    2082             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_AccessMask")
    2083             :         },
    2084             :         {
    2085             :                 .name = discard_const_p(char, "out_handle"),
    2086             :                 .get = py_winreg_OpenHKCU_out_get_handle,
    2087             :                 .set = py_winreg_OpenHKCU_out_set_handle,
    2088             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    2089             :         },
    2090             :         {
    2091             :                 .name = discard_const_p(char, "result"),
    2092             :                 .get = py_winreg_OpenHKCU_get_result,
    2093             :                 .set = py_winreg_OpenHKCU_set_result,
    2094             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    2095             :         },
    2096             :         { .name = NULL }
    2097             : };
    2098             : 
    2099           0 : static PyObject *py_winreg_OpenHKCU_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    2100             : {
    2101           0 :         PyObject *self = pytalloc_new(struct winreg_OpenHKCU, type);
    2102           0 :         struct winreg_OpenHKCU *_self = (struct winreg_OpenHKCU *)pytalloc_get_ptr(self);
    2103           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    2104           0 :         _self->out.handle = talloc_zero(mem_ctx, struct policy_handle);
    2105           0 :         return self;
    2106             : }
    2107             : 
    2108           0 : static PyObject *py_winreg_OpenHKCU_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    2109             : {
    2110             : 
    2111             : 
    2112           0 :         return PyLong_FromLong(1);
    2113             : }
    2114             : 
    2115           0 : static PyObject *py_winreg_OpenHKCU_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    2116             : {
    2117           0 :         const struct ndr_interface_call *call = NULL;
    2118           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    2119           0 :         PyObject *ret = NULL;
    2120           0 :         struct ndr_push *push = NULL;
    2121             :         DATA_BLOB blob;
    2122             :         enum ndr_err_code err;
    2123             : 
    2124           0 :         if (ndr_table_winreg.num_calls < 2) {
    2125           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKCU_ndr_pack");
    2126           0 :                 return NULL;
    2127             :         }
    2128           0 :         call = &ndr_table_winreg.calls[1];
    2129             : 
    2130           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    2131           0 :         if (push == NULL) {
    2132           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2133           0 :                 return NULL;
    2134             :         }
    2135             : 
    2136           0 :         push->flags |= ndr_push_flags;
    2137             : 
    2138           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    2139           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2140           0 :                 TALLOC_FREE(push);
    2141           0 :                 PyErr_SetNdrError(err);
    2142           0 :                 return NULL;
    2143             :         }
    2144           0 :         blob = ndr_push_blob(push);
    2145           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    2146           0 :         TALLOC_FREE(push);
    2147           0 :         return ret;
    2148             : }
    2149             : 
    2150           0 : static PyObject *py_winreg_OpenHKCU_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2151             : {
    2152           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2153           0 :         PyObject *bigendian_obj = NULL;
    2154           0 :         PyObject *ndr64_obj = NULL;
    2155           0 :         uint32_t ndr_push_flags = 0;
    2156             : 
    2157           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    2158             :                 discard_const_p(char *, kwnames),
    2159             :                 &bigendian_obj,
    2160             :                 &ndr64_obj)) {
    2161           0 :                 return NULL;
    2162             :         }
    2163             : 
    2164           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2165           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2166             :         }
    2167           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2168           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2169             :         }
    2170             : 
    2171           0 :         return py_winreg_OpenHKCU_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    2172             : }
    2173             : 
    2174           0 : static PyObject *py_winreg_OpenHKCU_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2175             : {
    2176           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2177           0 :         PyObject *bigendian_obj = NULL;
    2178           0 :         PyObject *ndr64_obj = NULL;
    2179           0 :         uint32_t ndr_push_flags = 0;
    2180             : 
    2181           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    2182             :                 discard_const_p(char *, kwnames),
    2183             :                 &bigendian_obj,
    2184             :                 &ndr64_obj)) {
    2185           0 :                 return NULL;
    2186             :         }
    2187             : 
    2188           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2189           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2190             :         }
    2191           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2192           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2193             :         }
    2194             : 
    2195           0 :         return py_winreg_OpenHKCU_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    2196             : }
    2197             : 
    2198           0 : static PyObject *py_winreg_OpenHKCU_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    2199             : {
    2200           0 :         const struct ndr_interface_call *call = NULL;
    2201           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    2202           0 :         struct ndr_pull *pull = NULL;
    2203             :         enum ndr_err_code err;
    2204             : 
    2205           0 :         if (ndr_table_winreg.num_calls < 2) {
    2206           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKCU_ndr_unpack");
    2207           0 :                 return NULL;
    2208             :         }
    2209           0 :         call = &ndr_table_winreg.calls[1];
    2210             : 
    2211           0 :         pull = ndr_pull_init_blob(blob, object);
    2212           0 :         if (pull == NULL) {
    2213           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2214           0 :                 return NULL;
    2215             :         }
    2216             : 
    2217           0 :         pull->flags |= ndr_pull_flags;
    2218             : 
    2219           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    2220           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2221           0 :                 TALLOC_FREE(pull);
    2222           0 :                 PyErr_SetNdrError(err);
    2223           0 :                 return NULL;
    2224             :         }
    2225           0 :         if (!allow_remaining) {
    2226             :                 uint32_t highest_ofs;
    2227             : 
    2228           0 :                 if (pull->offset > pull->relative_highest_offset) {
    2229           0 :                         highest_ofs = pull->offset;
    2230             :                 } else {
    2231           0 :                         highest_ofs = pull->relative_highest_offset;
    2232             :                 }
    2233           0 :                 if (highest_ofs < pull->data_size) {
    2234           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    2235             :                                 "not all bytes consumed ofs[%u] size[%u]",
    2236             :                                 highest_ofs, pull->data_size);
    2237           0 :                         TALLOC_FREE(pull);
    2238           0 :                         PyErr_SetNdrError(err);
    2239           0 :                         return NULL;
    2240             :                 }
    2241             :         }
    2242             : 
    2243           0 :         TALLOC_FREE(pull);
    2244           0 :         Py_RETURN_NONE;
    2245             : }
    2246             : 
    2247           0 : static PyObject *py_winreg_OpenHKCU_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2248             : {
    2249             :         DATA_BLOB blob;
    2250           0 :         Py_ssize_t blob_length = 0;
    2251           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2252           0 :         PyObject *bigendian_obj = NULL;
    2253           0 :         PyObject *ndr64_obj = NULL;
    2254           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2255           0 :         PyObject *allow_remaining_obj = NULL;
    2256           0 :         bool allow_remaining = false;
    2257             : 
    2258           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    2259             :                 discard_const_p(char *, kwnames),
    2260             :                 &blob.data, &blob_length,
    2261             :                 &bigendian_obj,
    2262             :                 &ndr64_obj,
    2263             :                 &allow_remaining_obj)) {
    2264           0 :                 return NULL;
    2265             :         }
    2266           0 :         blob.length = blob_length;
    2267             : 
    2268           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2269           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2270             :         }
    2271           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2272           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2273             :         }
    2274             : 
    2275           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2276           0 :                 allow_remaining = true;
    2277             :         }
    2278             : 
    2279           0 :         return py_winreg_OpenHKCU_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    2280             : }
    2281             : 
    2282           0 : static PyObject *py_winreg_OpenHKCU_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2283             : {
    2284             :         DATA_BLOB blob;
    2285           0 :         Py_ssize_t blob_length = 0;
    2286           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2287           0 :         PyObject *bigendian_obj = NULL;
    2288           0 :         PyObject *ndr64_obj = NULL;
    2289           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2290           0 :         PyObject *allow_remaining_obj = NULL;
    2291           0 :         bool allow_remaining = false;
    2292             : 
    2293           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    2294             :                 discard_const_p(char *, kwnames),
    2295             :                 &blob.data, &blob_length,
    2296             :                 &bigendian_obj,
    2297             :                 &ndr64_obj,
    2298             :                 &allow_remaining_obj)) {
    2299           0 :                 return NULL;
    2300             :         }
    2301           0 :         blob.length = blob_length;
    2302             : 
    2303           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2304           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2305             :         }
    2306           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2307           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2308             :         }
    2309             : 
    2310           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2311           0 :                 allow_remaining = true;
    2312             :         }
    2313             : 
    2314           0 :         return py_winreg_OpenHKCU_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    2315             : }
    2316             : 
    2317           0 : static PyObject *py_winreg_OpenHKCU_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    2318             : {
    2319           0 :         const struct ndr_interface_call *call = NULL;
    2320           0 :         struct winreg_OpenHKCU *object = (struct winreg_OpenHKCU *)pytalloc_get_ptr(py_obj);
    2321             :         PyObject *ret;
    2322             :         char *retstr;
    2323             : 
    2324           0 :         if (ndr_table_winreg.num_calls < 2) {
    2325           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKCU_ndr_print");
    2326           0 :                 return NULL;
    2327             :         }
    2328           0 :         call = &ndr_table_winreg.calls[1];
    2329             : 
    2330           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    2331           0 :         ret = PyUnicode_FromString(retstr);
    2332           0 :         TALLOC_FREE(retstr);
    2333             : 
    2334           0 :         return ret;
    2335             : }
    2336             : 
    2337           0 : static PyObject *py_winreg_OpenHKCU_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2338             : {
    2339           0 :         return py_winreg_OpenHKCU_ndr_print(py_obj, "winreg_OpenHKCU_in", NDR_IN);
    2340             : }
    2341             : 
    2342           0 : static PyObject *py_winreg_OpenHKCU_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2343             : {
    2344           0 :         return py_winreg_OpenHKCU_ndr_print(py_obj, "winreg_OpenHKCU_out", NDR_OUT);
    2345             : }
    2346             : 
    2347             : static PyMethodDef py_winreg_OpenHKCU_methods[] = {
    2348             :         { "opnum", (PyCFunction)py_winreg_OpenHKCU_ndr_opnum, METH_NOARGS|METH_CLASS,
    2349             :                 "winreg.OpenHKCU.opnum() -> 1 (0x01) " },
    2350             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCU_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    2351             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    2352             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCU_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    2353             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    2354             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCU_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    2355             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    2356             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKCU_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    2357             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    2358             :         { "__ndr_print_in__", (PyCFunction)py_winreg_OpenHKCU_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    2359             :         { "__ndr_print_out__", (PyCFunction)py_winreg_OpenHKCU_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    2360             :         { NULL, NULL, 0, NULL }
    2361             : };
    2362             : 
    2363             : 
    2364             : static PyTypeObject winreg_OpenHKCU_Type = {
    2365             :         PyVarObject_HEAD_INIT(NULL, 0)
    2366             :         .tp_name = "winreg.OpenHKCU",
    2367             :         .tp_getset = py_winreg_OpenHKCU_getsetters,
    2368             :         .tp_methods = py_winreg_OpenHKCU_methods,
    2369             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    2370             :         .tp_new = py_winreg_OpenHKCU_new,
    2371             : };
    2372             : 
    2373           0 : static bool pack_py_winreg_OpenHKCU_args_in(PyObject *args, PyObject *kwargs, struct winreg_OpenHKCU *r)
    2374             : {
    2375             :         PyObject *py_system_name;
    2376             :         PyObject *py_access_mask;
    2377           0 :         const char *kwnames[] = {
    2378             :                 "system_name", "access_mask", NULL
    2379             :         };
    2380             : 
    2381           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_OpenHKCU", discard_const_p(char *, kwnames), &py_system_name, &py_access_mask)) {
    2382           0 :                 return false;
    2383             :         }
    2384             : 
    2385           0 :         if (py_system_name == NULL) {
    2386           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.system_name");
    2387           0 :                 return false;
    2388             :         }
    2389           0 :         if (py_system_name == Py_None) {
    2390           0 :                 r->in.system_name = NULL;
    2391             :         } else {
    2392           0 :                 r->in.system_name = talloc_ptrtype(r, r->in.system_name);
    2393           0 :                 if (r->in.system_name == NULL) {
    2394           0 :                         PyErr_NoMemory();
    2395           0 :                         return false;
    2396             :                 }
    2397             :                 {
    2398           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.system_name));
    2399           0 :                         if (PyLong_Check(py_system_name)) {
    2400             :                                 unsigned long long test_var;
    2401           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_system_name);
    2402           0 :                                 if (PyErr_Occurred() != NULL) {
    2403           0 :                                         return false;
    2404             :                                 }
    2405           0 :                                 if (test_var > uint_max) {
    2406           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2407             :                                           PyLong_Type.tp_name, uint_max, test_var);
    2408           0 :                                         return false;
    2409             :                                 }
    2410           0 :                                 *r->in.system_name = test_var;
    2411             :                         } else {
    2412           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2413             :                                   PyLong_Type.tp_name);
    2414           0 :                                 return false;
    2415             :                         }
    2416             :                 }
    2417             :         }
    2418           0 :         if (py_access_mask == NULL) {
    2419           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.access_mask");
    2420           0 :                 return false;
    2421             :         }
    2422             :         {
    2423           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.access_mask));
    2424           0 :                 if (PyLong_Check(py_access_mask)) {
    2425             :                         unsigned long long test_var;
    2426           0 :                         test_var = PyLong_AsUnsignedLongLong(py_access_mask);
    2427           0 :                         if (PyErr_Occurred() != NULL) {
    2428           0 :                                 return false;
    2429             :                         }
    2430           0 :                         if (test_var > uint_max) {
    2431           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2432             :                                   PyLong_Type.tp_name, uint_max, test_var);
    2433           0 :                                 return false;
    2434             :                         }
    2435           0 :                         r->in.access_mask = test_var;
    2436             :                 } else {
    2437           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2438             :                           PyLong_Type.tp_name);
    2439           0 :                         return false;
    2440             :                 }
    2441             :         }
    2442           0 :         return true;
    2443             : }
    2444             : 
    2445           0 : static PyObject *unpack_py_winreg_OpenHKCU_args_out(struct winreg_OpenHKCU *r)
    2446             : {
    2447             :         PyObject *result;
    2448             :         PyObject *py_handle;
    2449           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, r->out.handle, r->out.handle);
    2450           0 :         result = py_handle;
    2451           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    2452           0 :                 PyErr_SetWERROR(r->out.result);
    2453           0 :                 return NULL;
    2454             :         }
    2455             : 
    2456           0 :         return result;
    2457             : }
    2458             : 
    2459             : 
    2460           0 : static PyObject *py_winreg_OpenHKLM_in_get_system_name(PyObject *obj, void *closure)
    2461             : {
    2462           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(obj);
    2463             :         PyObject *py_system_name;
    2464           0 :         if (object->in.system_name == NULL) {
    2465           0 :                 Py_RETURN_NONE;
    2466             :         }
    2467           0 :         if (object->in.system_name == NULL) {
    2468           0 :                 py_system_name = Py_None;
    2469           0 :                 Py_INCREF(py_system_name);
    2470             :         } else {
    2471           0 :                 py_system_name = PyLong_FromLong((uint16_t)*object->in.system_name);
    2472             :         }
    2473           0 :         return py_system_name;
    2474             : }
    2475             : 
    2476           0 : static int py_winreg_OpenHKLM_in_set_system_name(PyObject *py_obj, PyObject *value, void *closure)
    2477             : {
    2478           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2479           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.system_name));
    2480           0 :         if (value == NULL) {
    2481           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.system_name");
    2482           0 :                 return -1;
    2483             :         }
    2484           0 :         if (value == Py_None) {
    2485           0 :                 object->in.system_name = NULL;
    2486             :         } else {
    2487           0 :                 object->in.system_name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.system_name);
    2488           0 :                 if (object->in.system_name == NULL) {
    2489           0 :                         PyErr_NoMemory();
    2490           0 :                         return -1;
    2491             :                 }
    2492             :                 {
    2493           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.system_name));
    2494           0 :                         if (PyLong_Check(value)) {
    2495             :                                 unsigned long long test_var;
    2496           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    2497           0 :                                 if (PyErr_Occurred() != NULL) {
    2498           0 :                                         return -1;
    2499             :                                 }
    2500           0 :                                 if (test_var > uint_max) {
    2501           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2502             :                                           PyLong_Type.tp_name, uint_max, test_var);
    2503           0 :                                         return -1;
    2504             :                                 }
    2505           0 :                                 *object->in.system_name = test_var;
    2506             :                         } else {
    2507           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2508             :                                   PyLong_Type.tp_name);
    2509           0 :                                 return -1;
    2510             :                         }
    2511             :                 }
    2512             :         }
    2513           0 :         return 0;
    2514             : }
    2515             : 
    2516           0 : static PyObject *py_winreg_OpenHKLM_in_get_access_mask(PyObject *obj, void *closure)
    2517             : {
    2518           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(obj);
    2519             :         PyObject *py_access_mask;
    2520           0 :         py_access_mask = PyLong_FromUnsignedLongLong((uint32_t)object->in.access_mask);
    2521           0 :         return py_access_mask;
    2522             : }
    2523             : 
    2524           0 : static int py_winreg_OpenHKLM_in_set_access_mask(PyObject *py_obj, PyObject *value, void *closure)
    2525             : {
    2526           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2527           0 :         if (value == NULL) {
    2528           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.access_mask");
    2529           0 :                 return -1;
    2530             :         }
    2531             :         {
    2532           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.access_mask));
    2533           0 :                 if (PyLong_Check(value)) {
    2534             :                         unsigned long long test_var;
    2535           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    2536           0 :                         if (PyErr_Occurred() != NULL) {
    2537           0 :                                 return -1;
    2538             :                         }
    2539           0 :                         if (test_var > uint_max) {
    2540           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2541             :                                   PyLong_Type.tp_name, uint_max, test_var);
    2542           0 :                                 return -1;
    2543             :                         }
    2544           0 :                         object->in.access_mask = test_var;
    2545             :                 } else {
    2546           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2547             :                           PyLong_Type.tp_name);
    2548           0 :                         return -1;
    2549             :                 }
    2550             :         }
    2551           0 :         return 0;
    2552             : }
    2553             : 
    2554           0 : static PyObject *py_winreg_OpenHKLM_out_get_handle(PyObject *obj, void *closure)
    2555             : {
    2556           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(obj);
    2557             :         PyObject *py_handle;
    2558           0 :         if (object->out.handle == NULL) {
    2559           0 :                 Py_RETURN_NONE;
    2560             :         }
    2561           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->out.handle, object->out.handle);
    2562           0 :         return py_handle;
    2563             : }
    2564             : 
    2565           0 : static int py_winreg_OpenHKLM_out_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    2566             : {
    2567           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2568           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.handle));
    2569           0 :         if (value == NULL) {
    2570           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.handle");
    2571           0 :                 return -1;
    2572             :         }
    2573           0 :         object->out.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.handle);
    2574           0 :         if (object->out.handle == NULL) {
    2575           0 :                 PyErr_NoMemory();
    2576           0 :                 return -1;
    2577             :         }
    2578           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    2579           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    2580           0 :                 PyErr_NoMemory();
    2581           0 :                 return -1;
    2582             :         }
    2583           0 :         object->out.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    2584           0 :         return 0;
    2585             : }
    2586             : 
    2587           0 : static PyObject *py_winreg_OpenHKLM_get_result(PyObject *obj, void *closure)
    2588             : {
    2589           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(obj);
    2590             :         PyObject *py_result;
    2591           0 :         py_result = PyErr_FromWERROR(object->out.result);
    2592           0 :         return py_result;
    2593             : }
    2594             : 
    2595           0 : static int py_winreg_OpenHKLM_set_result(PyObject *py_obj, PyObject *value, void *closure)
    2596             : {
    2597           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2598           0 :         if (value == NULL) {
    2599           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    2600           0 :                 return -1;
    2601             :         }
    2602           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    2603           0 :         return 0;
    2604             : }
    2605             : 
    2606             : static PyGetSetDef py_winreg_OpenHKLM_getsetters[] = {
    2607             :         {
    2608             :                 .name = discard_const_p(char, "in_system_name"),
    2609             :                 .get = py_winreg_OpenHKLM_in_get_system_name,
    2610             :                 .set = py_winreg_OpenHKLM_in_set_system_name,
    2611             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    2612             :         },
    2613             :         {
    2614             :                 .name = discard_const_p(char, "in_access_mask"),
    2615             :                 .get = py_winreg_OpenHKLM_in_get_access_mask,
    2616             :                 .set = py_winreg_OpenHKLM_in_set_access_mask,
    2617             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_AccessMask")
    2618             :         },
    2619             :         {
    2620             :                 .name = discard_const_p(char, "out_handle"),
    2621             :                 .get = py_winreg_OpenHKLM_out_get_handle,
    2622             :                 .set = py_winreg_OpenHKLM_out_set_handle,
    2623             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    2624             :         },
    2625             :         {
    2626             :                 .name = discard_const_p(char, "result"),
    2627             :                 .get = py_winreg_OpenHKLM_get_result,
    2628             :                 .set = py_winreg_OpenHKLM_set_result,
    2629             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    2630             :         },
    2631             :         { .name = NULL }
    2632             : };
    2633             : 
    2634           0 : static PyObject *py_winreg_OpenHKLM_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    2635             : {
    2636           0 :         PyObject *self = pytalloc_new(struct winreg_OpenHKLM, type);
    2637           0 :         struct winreg_OpenHKLM *_self = (struct winreg_OpenHKLM *)pytalloc_get_ptr(self);
    2638           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    2639           0 :         _self->out.handle = talloc_zero(mem_ctx, struct policy_handle);
    2640           0 :         return self;
    2641             : }
    2642             : 
    2643           0 : static PyObject *py_winreg_OpenHKLM_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    2644             : {
    2645             : 
    2646             : 
    2647           0 :         return PyLong_FromLong(2);
    2648             : }
    2649             : 
    2650           0 : static PyObject *py_winreg_OpenHKLM_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    2651             : {
    2652           0 :         const struct ndr_interface_call *call = NULL;
    2653           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2654           0 :         PyObject *ret = NULL;
    2655           0 :         struct ndr_push *push = NULL;
    2656             :         DATA_BLOB blob;
    2657             :         enum ndr_err_code err;
    2658             : 
    2659           0 :         if (ndr_table_winreg.num_calls < 3) {
    2660           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKLM_ndr_pack");
    2661           0 :                 return NULL;
    2662             :         }
    2663           0 :         call = &ndr_table_winreg.calls[2];
    2664             : 
    2665           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    2666           0 :         if (push == NULL) {
    2667           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2668           0 :                 return NULL;
    2669             :         }
    2670             : 
    2671           0 :         push->flags |= ndr_push_flags;
    2672             : 
    2673           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    2674           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2675           0 :                 TALLOC_FREE(push);
    2676           0 :                 PyErr_SetNdrError(err);
    2677           0 :                 return NULL;
    2678             :         }
    2679           0 :         blob = ndr_push_blob(push);
    2680           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    2681           0 :         TALLOC_FREE(push);
    2682           0 :         return ret;
    2683             : }
    2684             : 
    2685           0 : static PyObject *py_winreg_OpenHKLM_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2686             : {
    2687           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2688           0 :         PyObject *bigendian_obj = NULL;
    2689           0 :         PyObject *ndr64_obj = NULL;
    2690           0 :         uint32_t ndr_push_flags = 0;
    2691             : 
    2692           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    2693             :                 discard_const_p(char *, kwnames),
    2694             :                 &bigendian_obj,
    2695             :                 &ndr64_obj)) {
    2696           0 :                 return NULL;
    2697             :         }
    2698             : 
    2699           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2700           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2701             :         }
    2702           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2703           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2704             :         }
    2705             : 
    2706           0 :         return py_winreg_OpenHKLM_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    2707             : }
    2708             : 
    2709           0 : static PyObject *py_winreg_OpenHKLM_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2710             : {
    2711           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    2712           0 :         PyObject *bigendian_obj = NULL;
    2713           0 :         PyObject *ndr64_obj = NULL;
    2714           0 :         uint32_t ndr_push_flags = 0;
    2715             : 
    2716           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    2717             :                 discard_const_p(char *, kwnames),
    2718             :                 &bigendian_obj,
    2719             :                 &ndr64_obj)) {
    2720           0 :                 return NULL;
    2721             :         }
    2722             : 
    2723           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2724           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    2725             :         }
    2726           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2727           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    2728             :         }
    2729             : 
    2730           0 :         return py_winreg_OpenHKLM_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    2731             : }
    2732             : 
    2733           0 : static PyObject *py_winreg_OpenHKLM_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    2734             : {
    2735           0 :         const struct ndr_interface_call *call = NULL;
    2736           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2737           0 :         struct ndr_pull *pull = NULL;
    2738             :         enum ndr_err_code err;
    2739             : 
    2740           0 :         if (ndr_table_winreg.num_calls < 3) {
    2741           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKLM_ndr_unpack");
    2742           0 :                 return NULL;
    2743             :         }
    2744           0 :         call = &ndr_table_winreg.calls[2];
    2745             : 
    2746           0 :         pull = ndr_pull_init_blob(blob, object);
    2747           0 :         if (pull == NULL) {
    2748           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    2749           0 :                 return NULL;
    2750             :         }
    2751             : 
    2752           0 :         pull->flags |= ndr_pull_flags;
    2753             : 
    2754           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    2755           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    2756           0 :                 TALLOC_FREE(pull);
    2757           0 :                 PyErr_SetNdrError(err);
    2758           0 :                 return NULL;
    2759             :         }
    2760           0 :         if (!allow_remaining) {
    2761             :                 uint32_t highest_ofs;
    2762             : 
    2763           0 :                 if (pull->offset > pull->relative_highest_offset) {
    2764           0 :                         highest_ofs = pull->offset;
    2765             :                 } else {
    2766           0 :                         highest_ofs = pull->relative_highest_offset;
    2767             :                 }
    2768           0 :                 if (highest_ofs < pull->data_size) {
    2769           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    2770             :                                 "not all bytes consumed ofs[%u] size[%u]",
    2771             :                                 highest_ofs, pull->data_size);
    2772           0 :                         TALLOC_FREE(pull);
    2773           0 :                         PyErr_SetNdrError(err);
    2774           0 :                         return NULL;
    2775             :                 }
    2776             :         }
    2777             : 
    2778           0 :         TALLOC_FREE(pull);
    2779           0 :         Py_RETURN_NONE;
    2780             : }
    2781             : 
    2782           0 : static PyObject *py_winreg_OpenHKLM_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2783             : {
    2784             :         DATA_BLOB blob;
    2785           0 :         Py_ssize_t blob_length = 0;
    2786           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2787           0 :         PyObject *bigendian_obj = NULL;
    2788           0 :         PyObject *ndr64_obj = NULL;
    2789           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2790           0 :         PyObject *allow_remaining_obj = NULL;
    2791           0 :         bool allow_remaining = false;
    2792             : 
    2793           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    2794             :                 discard_const_p(char *, kwnames),
    2795             :                 &blob.data, &blob_length,
    2796             :                 &bigendian_obj,
    2797             :                 &ndr64_obj,
    2798             :                 &allow_remaining_obj)) {
    2799           0 :                 return NULL;
    2800             :         }
    2801           0 :         blob.length = blob_length;
    2802             : 
    2803           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2804           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2805             :         }
    2806           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2807           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2808             :         }
    2809             : 
    2810           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2811           0 :                 allow_remaining = true;
    2812             :         }
    2813             : 
    2814           0 :         return py_winreg_OpenHKLM_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    2815             : }
    2816             : 
    2817           0 : static PyObject *py_winreg_OpenHKLM_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    2818             : {
    2819             :         DATA_BLOB blob;
    2820           0 :         Py_ssize_t blob_length = 0;
    2821           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    2822           0 :         PyObject *bigendian_obj = NULL;
    2823           0 :         PyObject *ndr64_obj = NULL;
    2824           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    2825           0 :         PyObject *allow_remaining_obj = NULL;
    2826           0 :         bool allow_remaining = false;
    2827             : 
    2828           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    2829             :                 discard_const_p(char *, kwnames),
    2830             :                 &blob.data, &blob_length,
    2831             :                 &bigendian_obj,
    2832             :                 &ndr64_obj,
    2833             :                 &allow_remaining_obj)) {
    2834           0 :                 return NULL;
    2835             :         }
    2836           0 :         blob.length = blob_length;
    2837             : 
    2838           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    2839           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    2840             :         }
    2841           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    2842           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    2843             :         }
    2844             : 
    2845           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    2846           0 :                 allow_remaining = true;
    2847             :         }
    2848             : 
    2849           0 :         return py_winreg_OpenHKLM_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    2850             : }
    2851             : 
    2852           0 : static PyObject *py_winreg_OpenHKLM_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    2853             : {
    2854           0 :         const struct ndr_interface_call *call = NULL;
    2855           0 :         struct winreg_OpenHKLM *object = (struct winreg_OpenHKLM *)pytalloc_get_ptr(py_obj);
    2856             :         PyObject *ret;
    2857             :         char *retstr;
    2858             : 
    2859           0 :         if (ndr_table_winreg.num_calls < 3) {
    2860           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKLM_ndr_print");
    2861           0 :                 return NULL;
    2862             :         }
    2863           0 :         call = &ndr_table_winreg.calls[2];
    2864             : 
    2865           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    2866           0 :         ret = PyUnicode_FromString(retstr);
    2867           0 :         TALLOC_FREE(retstr);
    2868             : 
    2869           0 :         return ret;
    2870             : }
    2871             : 
    2872           0 : static PyObject *py_winreg_OpenHKLM_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2873             : {
    2874           0 :         return py_winreg_OpenHKLM_ndr_print(py_obj, "winreg_OpenHKLM_in", NDR_IN);
    2875             : }
    2876             : 
    2877           0 : static PyObject *py_winreg_OpenHKLM_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    2878             : {
    2879           0 :         return py_winreg_OpenHKLM_ndr_print(py_obj, "winreg_OpenHKLM_out", NDR_OUT);
    2880             : }
    2881             : 
    2882             : static PyMethodDef py_winreg_OpenHKLM_methods[] = {
    2883             :         { "opnum", (PyCFunction)py_winreg_OpenHKLM_ndr_opnum, METH_NOARGS|METH_CLASS,
    2884             :                 "winreg.OpenHKLM.opnum() -> 2 (0x02) " },
    2885             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKLM_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    2886             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    2887             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKLM_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    2888             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    2889             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKLM_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    2890             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    2891             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKLM_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    2892             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    2893             :         { "__ndr_print_in__", (PyCFunction)py_winreg_OpenHKLM_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    2894             :         { "__ndr_print_out__", (PyCFunction)py_winreg_OpenHKLM_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    2895             :         { NULL, NULL, 0, NULL }
    2896             : };
    2897             : 
    2898             : 
    2899             : static PyTypeObject winreg_OpenHKLM_Type = {
    2900             :         PyVarObject_HEAD_INIT(NULL, 0)
    2901             :         .tp_name = "winreg.OpenHKLM",
    2902             :         .tp_getset = py_winreg_OpenHKLM_getsetters,
    2903             :         .tp_methods = py_winreg_OpenHKLM_methods,
    2904             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    2905             :         .tp_new = py_winreg_OpenHKLM_new,
    2906             : };
    2907             : 
    2908           3 : static bool pack_py_winreg_OpenHKLM_args_in(PyObject *args, PyObject *kwargs, struct winreg_OpenHKLM *r)
    2909             : {
    2910             :         PyObject *py_system_name;
    2911             :         PyObject *py_access_mask;
    2912           3 :         const char *kwnames[] = {
    2913             :                 "system_name", "access_mask", NULL
    2914             :         };
    2915             : 
    2916           3 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_OpenHKLM", discard_const_p(char *, kwnames), &py_system_name, &py_access_mask)) {
    2917           0 :                 return false;
    2918             :         }
    2919             : 
    2920           3 :         if (py_system_name == NULL) {
    2921           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.system_name");
    2922           0 :                 return false;
    2923             :         }
    2924           3 :         if (py_system_name == Py_None) {
    2925           3 :                 r->in.system_name = NULL;
    2926             :         } else {
    2927           0 :                 r->in.system_name = talloc_ptrtype(r, r->in.system_name);
    2928           0 :                 if (r->in.system_name == NULL) {
    2929           0 :                         PyErr_NoMemory();
    2930           0 :                         return false;
    2931             :                 }
    2932             :                 {
    2933           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.system_name));
    2934           0 :                         if (PyLong_Check(py_system_name)) {
    2935             :                                 unsigned long long test_var;
    2936           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_system_name);
    2937           0 :                                 if (PyErr_Occurred() != NULL) {
    2938           0 :                                         return false;
    2939             :                                 }
    2940           0 :                                 if (test_var > uint_max) {
    2941           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2942             :                                           PyLong_Type.tp_name, uint_max, test_var);
    2943           0 :                                         return false;
    2944             :                                 }
    2945           0 :                                 *r->in.system_name = test_var;
    2946             :                         } else {
    2947           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2948             :                                   PyLong_Type.tp_name);
    2949           0 :                                 return false;
    2950             :                         }
    2951             :                 }
    2952             :         }
    2953           3 :         if (py_access_mask == NULL) {
    2954           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.access_mask");
    2955           0 :                 return false;
    2956             :         }
    2957             :         {
    2958           3 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.access_mask));
    2959           3 :                 if (PyLong_Check(py_access_mask)) {
    2960             :                         unsigned long long test_var;
    2961           3 :                         test_var = PyLong_AsUnsignedLongLong(py_access_mask);
    2962           3 :                         if (PyErr_Occurred() != NULL) {
    2963           0 :                                 return false;
    2964             :                         }
    2965           3 :                         if (test_var > uint_max) {
    2966           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    2967             :                                   PyLong_Type.tp_name, uint_max, test_var);
    2968           0 :                                 return false;
    2969             :                         }
    2970           3 :                         r->in.access_mask = test_var;
    2971             :                 } else {
    2972           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    2973             :                           PyLong_Type.tp_name);
    2974           0 :                         return false;
    2975             :                 }
    2976             :         }
    2977           3 :         return true;
    2978             : }
    2979             : 
    2980           3 : static PyObject *unpack_py_winreg_OpenHKLM_args_out(struct winreg_OpenHKLM *r)
    2981             : {
    2982             :         PyObject *result;
    2983             :         PyObject *py_handle;
    2984           3 :         py_handle = pytalloc_reference_ex(policy_handle_Type, r->out.handle, r->out.handle);
    2985           3 :         result = py_handle;
    2986           3 :         if (!W_ERROR_IS_OK(r->out.result)) {
    2987           0 :                 PyErr_SetWERROR(r->out.result);
    2988           0 :                 return NULL;
    2989             :         }
    2990             : 
    2991           3 :         return result;
    2992             : }
    2993             : 
    2994             : 
    2995           0 : static PyObject *py_winreg_OpenHKPD_in_get_system_name(PyObject *obj, void *closure)
    2996             : {
    2997           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(obj);
    2998             :         PyObject *py_system_name;
    2999           0 :         if (object->in.system_name == NULL) {
    3000           0 :                 Py_RETURN_NONE;
    3001             :         }
    3002           0 :         if (object->in.system_name == NULL) {
    3003           0 :                 py_system_name = Py_None;
    3004           0 :                 Py_INCREF(py_system_name);
    3005             :         } else {
    3006           0 :                 py_system_name = PyLong_FromLong((uint16_t)*object->in.system_name);
    3007             :         }
    3008           0 :         return py_system_name;
    3009             : }
    3010             : 
    3011           0 : static int py_winreg_OpenHKPD_in_set_system_name(PyObject *py_obj, PyObject *value, void *closure)
    3012             : {
    3013           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3014           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.system_name));
    3015           0 :         if (value == NULL) {
    3016           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.system_name");
    3017           0 :                 return -1;
    3018             :         }
    3019           0 :         if (value == Py_None) {
    3020           0 :                 object->in.system_name = NULL;
    3021             :         } else {
    3022           0 :                 object->in.system_name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.system_name);
    3023           0 :                 if (object->in.system_name == NULL) {
    3024           0 :                         PyErr_NoMemory();
    3025           0 :                         return -1;
    3026             :                 }
    3027             :                 {
    3028           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.system_name));
    3029           0 :                         if (PyLong_Check(value)) {
    3030             :                                 unsigned long long test_var;
    3031           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    3032           0 :                                 if (PyErr_Occurred() != NULL) {
    3033           0 :                                         return -1;
    3034             :                                 }
    3035           0 :                                 if (test_var > uint_max) {
    3036           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    3037             :                                           PyLong_Type.tp_name, uint_max, test_var);
    3038           0 :                                         return -1;
    3039             :                                 }
    3040           0 :                                 *object->in.system_name = test_var;
    3041             :                         } else {
    3042           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    3043             :                                   PyLong_Type.tp_name);
    3044           0 :                                 return -1;
    3045             :                         }
    3046             :                 }
    3047             :         }
    3048           0 :         return 0;
    3049             : }
    3050             : 
    3051           0 : static PyObject *py_winreg_OpenHKPD_in_get_access_mask(PyObject *obj, void *closure)
    3052             : {
    3053           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(obj);
    3054             :         PyObject *py_access_mask;
    3055           0 :         py_access_mask = PyLong_FromUnsignedLongLong((uint32_t)object->in.access_mask);
    3056           0 :         return py_access_mask;
    3057             : }
    3058             : 
    3059           0 : static int py_winreg_OpenHKPD_in_set_access_mask(PyObject *py_obj, PyObject *value, void *closure)
    3060             : {
    3061           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3062           0 :         if (value == NULL) {
    3063           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.access_mask");
    3064           0 :                 return -1;
    3065             :         }
    3066             :         {
    3067           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.access_mask));
    3068           0 :                 if (PyLong_Check(value)) {
    3069             :                         unsigned long long test_var;
    3070           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    3071           0 :                         if (PyErr_Occurred() != NULL) {
    3072           0 :                                 return -1;
    3073             :                         }
    3074           0 :                         if (test_var > uint_max) {
    3075           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    3076             :                                   PyLong_Type.tp_name, uint_max, test_var);
    3077           0 :                                 return -1;
    3078             :                         }
    3079           0 :                         object->in.access_mask = test_var;
    3080             :                 } else {
    3081           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    3082             :                           PyLong_Type.tp_name);
    3083           0 :                         return -1;
    3084             :                 }
    3085             :         }
    3086           0 :         return 0;
    3087             : }
    3088             : 
    3089           0 : static PyObject *py_winreg_OpenHKPD_out_get_handle(PyObject *obj, void *closure)
    3090             : {
    3091           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(obj);
    3092             :         PyObject *py_handle;
    3093           0 :         if (object->out.handle == NULL) {
    3094           0 :                 Py_RETURN_NONE;
    3095             :         }
    3096           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->out.handle, object->out.handle);
    3097           0 :         return py_handle;
    3098             : }
    3099             : 
    3100           0 : static int py_winreg_OpenHKPD_out_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    3101             : {
    3102           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3103           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.handle));
    3104           0 :         if (value == NULL) {
    3105           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.handle");
    3106           0 :                 return -1;
    3107             :         }
    3108           0 :         object->out.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.handle);
    3109           0 :         if (object->out.handle == NULL) {
    3110           0 :                 PyErr_NoMemory();
    3111           0 :                 return -1;
    3112             :         }
    3113           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    3114           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    3115           0 :                 PyErr_NoMemory();
    3116           0 :                 return -1;
    3117             :         }
    3118           0 :         object->out.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    3119           0 :         return 0;
    3120             : }
    3121             : 
    3122           0 : static PyObject *py_winreg_OpenHKPD_get_result(PyObject *obj, void *closure)
    3123             : {
    3124           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(obj);
    3125             :         PyObject *py_result;
    3126           0 :         py_result = PyErr_FromWERROR(object->out.result);
    3127           0 :         return py_result;
    3128             : }
    3129             : 
    3130           0 : static int py_winreg_OpenHKPD_set_result(PyObject *py_obj, PyObject *value, void *closure)
    3131             : {
    3132           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3133           0 :         if (value == NULL) {
    3134           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    3135           0 :                 return -1;
    3136             :         }
    3137           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    3138           0 :         return 0;
    3139             : }
    3140             : 
    3141             : static PyGetSetDef py_winreg_OpenHKPD_getsetters[] = {
    3142             :         {
    3143             :                 .name = discard_const_p(char, "in_system_name"),
    3144             :                 .get = py_winreg_OpenHKPD_in_get_system_name,
    3145             :                 .set = py_winreg_OpenHKPD_in_set_system_name,
    3146             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    3147             :         },
    3148             :         {
    3149             :                 .name = discard_const_p(char, "in_access_mask"),
    3150             :                 .get = py_winreg_OpenHKPD_in_get_access_mask,
    3151             :                 .set = py_winreg_OpenHKPD_in_set_access_mask,
    3152             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_AccessMask")
    3153             :         },
    3154             :         {
    3155             :                 .name = discard_const_p(char, "out_handle"),
    3156             :                 .get = py_winreg_OpenHKPD_out_get_handle,
    3157             :                 .set = py_winreg_OpenHKPD_out_set_handle,
    3158             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    3159             :         },
    3160             :         {
    3161             :                 .name = discard_const_p(char, "result"),
    3162             :                 .get = py_winreg_OpenHKPD_get_result,
    3163             :                 .set = py_winreg_OpenHKPD_set_result,
    3164             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    3165             :         },
    3166             :         { .name = NULL }
    3167             : };
    3168             : 
    3169           0 : static PyObject *py_winreg_OpenHKPD_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    3170             : {
    3171           0 :         PyObject *self = pytalloc_new(struct winreg_OpenHKPD, type);
    3172           0 :         struct winreg_OpenHKPD *_self = (struct winreg_OpenHKPD *)pytalloc_get_ptr(self);
    3173           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    3174           0 :         _self->out.handle = talloc_zero(mem_ctx, struct policy_handle);
    3175           0 :         return self;
    3176             : }
    3177             : 
    3178           0 : static PyObject *py_winreg_OpenHKPD_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    3179             : {
    3180             : 
    3181             : 
    3182           0 :         return PyLong_FromLong(3);
    3183             : }
    3184             : 
    3185           0 : static PyObject *py_winreg_OpenHKPD_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    3186             : {
    3187           0 :         const struct ndr_interface_call *call = NULL;
    3188           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3189           0 :         PyObject *ret = NULL;
    3190           0 :         struct ndr_push *push = NULL;
    3191             :         DATA_BLOB blob;
    3192             :         enum ndr_err_code err;
    3193             : 
    3194           0 :         if (ndr_table_winreg.num_calls < 4) {
    3195           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKPD_ndr_pack");
    3196           0 :                 return NULL;
    3197             :         }
    3198           0 :         call = &ndr_table_winreg.calls[3];
    3199             : 
    3200           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    3201           0 :         if (push == NULL) {
    3202           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3203           0 :                 return NULL;
    3204             :         }
    3205             : 
    3206           0 :         push->flags |= ndr_push_flags;
    3207             : 
    3208           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    3209           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3210           0 :                 TALLOC_FREE(push);
    3211           0 :                 PyErr_SetNdrError(err);
    3212           0 :                 return NULL;
    3213             :         }
    3214           0 :         blob = ndr_push_blob(push);
    3215           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    3216           0 :         TALLOC_FREE(push);
    3217           0 :         return ret;
    3218             : }
    3219             : 
    3220           0 : static PyObject *py_winreg_OpenHKPD_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3221             : {
    3222           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3223           0 :         PyObject *bigendian_obj = NULL;
    3224           0 :         PyObject *ndr64_obj = NULL;
    3225           0 :         uint32_t ndr_push_flags = 0;
    3226             : 
    3227           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    3228             :                 discard_const_p(char *, kwnames),
    3229             :                 &bigendian_obj,
    3230             :                 &ndr64_obj)) {
    3231           0 :                 return NULL;
    3232             :         }
    3233             : 
    3234           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3235           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3236             :         }
    3237           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3238           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3239             :         }
    3240             : 
    3241           0 :         return py_winreg_OpenHKPD_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    3242             : }
    3243             : 
    3244           0 : static PyObject *py_winreg_OpenHKPD_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3245             : {
    3246           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3247           0 :         PyObject *bigendian_obj = NULL;
    3248           0 :         PyObject *ndr64_obj = NULL;
    3249           0 :         uint32_t ndr_push_flags = 0;
    3250             : 
    3251           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    3252             :                 discard_const_p(char *, kwnames),
    3253             :                 &bigendian_obj,
    3254             :                 &ndr64_obj)) {
    3255           0 :                 return NULL;
    3256             :         }
    3257             : 
    3258           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3259           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3260             :         }
    3261           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3262           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3263             :         }
    3264             : 
    3265           0 :         return py_winreg_OpenHKPD_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    3266             : }
    3267             : 
    3268           0 : static PyObject *py_winreg_OpenHKPD_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    3269             : {
    3270           0 :         const struct ndr_interface_call *call = NULL;
    3271           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3272           0 :         struct ndr_pull *pull = NULL;
    3273             :         enum ndr_err_code err;
    3274             : 
    3275           0 :         if (ndr_table_winreg.num_calls < 4) {
    3276           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKPD_ndr_unpack");
    3277           0 :                 return NULL;
    3278             :         }
    3279           0 :         call = &ndr_table_winreg.calls[3];
    3280             : 
    3281           0 :         pull = ndr_pull_init_blob(blob, object);
    3282           0 :         if (pull == NULL) {
    3283           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3284           0 :                 return NULL;
    3285             :         }
    3286             : 
    3287           0 :         pull->flags |= ndr_pull_flags;
    3288             : 
    3289           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    3290           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3291           0 :                 TALLOC_FREE(pull);
    3292           0 :                 PyErr_SetNdrError(err);
    3293           0 :                 return NULL;
    3294             :         }
    3295           0 :         if (!allow_remaining) {
    3296             :                 uint32_t highest_ofs;
    3297             : 
    3298           0 :                 if (pull->offset > pull->relative_highest_offset) {
    3299           0 :                         highest_ofs = pull->offset;
    3300             :                 } else {
    3301           0 :                         highest_ofs = pull->relative_highest_offset;
    3302             :                 }
    3303           0 :                 if (highest_ofs < pull->data_size) {
    3304           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    3305             :                                 "not all bytes consumed ofs[%u] size[%u]",
    3306             :                                 highest_ofs, pull->data_size);
    3307           0 :                         TALLOC_FREE(pull);
    3308           0 :                         PyErr_SetNdrError(err);
    3309           0 :                         return NULL;
    3310             :                 }
    3311             :         }
    3312             : 
    3313           0 :         TALLOC_FREE(pull);
    3314           0 :         Py_RETURN_NONE;
    3315             : }
    3316             : 
    3317           0 : static PyObject *py_winreg_OpenHKPD_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3318             : {
    3319             :         DATA_BLOB blob;
    3320           0 :         Py_ssize_t blob_length = 0;
    3321           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3322           0 :         PyObject *bigendian_obj = NULL;
    3323           0 :         PyObject *ndr64_obj = NULL;
    3324           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3325           0 :         PyObject *allow_remaining_obj = NULL;
    3326           0 :         bool allow_remaining = false;
    3327             : 
    3328           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    3329             :                 discard_const_p(char *, kwnames),
    3330             :                 &blob.data, &blob_length,
    3331             :                 &bigendian_obj,
    3332             :                 &ndr64_obj,
    3333             :                 &allow_remaining_obj)) {
    3334           0 :                 return NULL;
    3335             :         }
    3336           0 :         blob.length = blob_length;
    3337             : 
    3338           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3339           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3340             :         }
    3341           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3342           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3343             :         }
    3344             : 
    3345           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3346           0 :                 allow_remaining = true;
    3347             :         }
    3348             : 
    3349           0 :         return py_winreg_OpenHKPD_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    3350             : }
    3351             : 
    3352           0 : static PyObject *py_winreg_OpenHKPD_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3353             : {
    3354             :         DATA_BLOB blob;
    3355           0 :         Py_ssize_t blob_length = 0;
    3356           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3357           0 :         PyObject *bigendian_obj = NULL;
    3358           0 :         PyObject *ndr64_obj = NULL;
    3359           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3360           0 :         PyObject *allow_remaining_obj = NULL;
    3361           0 :         bool allow_remaining = false;
    3362             : 
    3363           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    3364             :                 discard_const_p(char *, kwnames),
    3365             :                 &blob.data, &blob_length,
    3366             :                 &bigendian_obj,
    3367             :                 &ndr64_obj,
    3368             :                 &allow_remaining_obj)) {
    3369           0 :                 return NULL;
    3370             :         }
    3371           0 :         blob.length = blob_length;
    3372             : 
    3373           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3374           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3375             :         }
    3376           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3377           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3378             :         }
    3379             : 
    3380           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3381           0 :                 allow_remaining = true;
    3382             :         }
    3383             : 
    3384           0 :         return py_winreg_OpenHKPD_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    3385             : }
    3386             : 
    3387           0 : static PyObject *py_winreg_OpenHKPD_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    3388             : {
    3389           0 :         const struct ndr_interface_call *call = NULL;
    3390           0 :         struct winreg_OpenHKPD *object = (struct winreg_OpenHKPD *)pytalloc_get_ptr(py_obj);
    3391             :         PyObject *ret;
    3392             :         char *retstr;
    3393             : 
    3394           0 :         if (ndr_table_winreg.num_calls < 4) {
    3395           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKPD_ndr_print");
    3396           0 :                 return NULL;
    3397             :         }
    3398           0 :         call = &ndr_table_winreg.calls[3];
    3399             : 
    3400           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    3401           0 :         ret = PyUnicode_FromString(retstr);
    3402           0 :         TALLOC_FREE(retstr);
    3403             : 
    3404           0 :         return ret;
    3405             : }
    3406             : 
    3407           0 : static PyObject *py_winreg_OpenHKPD_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3408             : {
    3409           0 :         return py_winreg_OpenHKPD_ndr_print(py_obj, "winreg_OpenHKPD_in", NDR_IN);
    3410             : }
    3411             : 
    3412           0 : static PyObject *py_winreg_OpenHKPD_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3413             : {
    3414           0 :         return py_winreg_OpenHKPD_ndr_print(py_obj, "winreg_OpenHKPD_out", NDR_OUT);
    3415             : }
    3416             : 
    3417             : static PyMethodDef py_winreg_OpenHKPD_methods[] = {
    3418             :         { "opnum", (PyCFunction)py_winreg_OpenHKPD_ndr_opnum, METH_NOARGS|METH_CLASS,
    3419             :                 "winreg.OpenHKPD.opnum() -> 3 (0x03) " },
    3420             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKPD_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    3421             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    3422             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKPD_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    3423             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    3424             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKPD_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    3425             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    3426             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKPD_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    3427             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    3428             :         { "__ndr_print_in__", (PyCFunction)py_winreg_OpenHKPD_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    3429             :         { "__ndr_print_out__", (PyCFunction)py_winreg_OpenHKPD_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    3430             :         { NULL, NULL, 0, NULL }
    3431             : };
    3432             : 
    3433             : 
    3434             : static PyTypeObject winreg_OpenHKPD_Type = {
    3435             :         PyVarObject_HEAD_INIT(NULL, 0)
    3436             :         .tp_name = "winreg.OpenHKPD",
    3437             :         .tp_getset = py_winreg_OpenHKPD_getsetters,
    3438             :         .tp_methods = py_winreg_OpenHKPD_methods,
    3439             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    3440             :         .tp_new = py_winreg_OpenHKPD_new,
    3441             : };
    3442             : 
    3443           0 : static bool pack_py_winreg_OpenHKPD_args_in(PyObject *args, PyObject *kwargs, struct winreg_OpenHKPD *r)
    3444             : {
    3445             :         PyObject *py_system_name;
    3446             :         PyObject *py_access_mask;
    3447           0 :         const char *kwnames[] = {
    3448             :                 "system_name", "access_mask", NULL
    3449             :         };
    3450             : 
    3451           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_OpenHKPD", discard_const_p(char *, kwnames), &py_system_name, &py_access_mask)) {
    3452           0 :                 return false;
    3453             :         }
    3454             : 
    3455           0 :         if (py_system_name == NULL) {
    3456           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.system_name");
    3457           0 :                 return false;
    3458             :         }
    3459           0 :         if (py_system_name == Py_None) {
    3460           0 :                 r->in.system_name = NULL;
    3461             :         } else {
    3462           0 :                 r->in.system_name = talloc_ptrtype(r, r->in.system_name);
    3463           0 :                 if (r->in.system_name == NULL) {
    3464           0 :                         PyErr_NoMemory();
    3465           0 :                         return false;
    3466             :                 }
    3467             :                 {
    3468           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.system_name));
    3469           0 :                         if (PyLong_Check(py_system_name)) {
    3470             :                                 unsigned long long test_var;
    3471           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_system_name);
    3472           0 :                                 if (PyErr_Occurred() != NULL) {
    3473           0 :                                         return false;
    3474             :                                 }
    3475           0 :                                 if (test_var > uint_max) {
    3476           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    3477             :                                           PyLong_Type.tp_name, uint_max, test_var);
    3478           0 :                                         return false;
    3479             :                                 }
    3480           0 :                                 *r->in.system_name = test_var;
    3481             :                         } else {
    3482           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    3483             :                                   PyLong_Type.tp_name);
    3484           0 :                                 return false;
    3485             :                         }
    3486             :                 }
    3487             :         }
    3488           0 :         if (py_access_mask == NULL) {
    3489           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.access_mask");
    3490           0 :                 return false;
    3491             :         }
    3492             :         {
    3493           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.access_mask));
    3494           0 :                 if (PyLong_Check(py_access_mask)) {
    3495             :                         unsigned long long test_var;
    3496           0 :                         test_var = PyLong_AsUnsignedLongLong(py_access_mask);
    3497           0 :                         if (PyErr_Occurred() != NULL) {
    3498           0 :                                 return false;
    3499             :                         }
    3500           0 :                         if (test_var > uint_max) {
    3501           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    3502             :                                   PyLong_Type.tp_name, uint_max, test_var);
    3503           0 :                                 return false;
    3504             :                         }
    3505           0 :                         r->in.access_mask = test_var;
    3506             :                 } else {
    3507           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    3508             :                           PyLong_Type.tp_name);
    3509           0 :                         return false;
    3510             :                 }
    3511             :         }
    3512           0 :         return true;
    3513             : }
    3514             : 
    3515           0 : static PyObject *unpack_py_winreg_OpenHKPD_args_out(struct winreg_OpenHKPD *r)
    3516             : {
    3517             :         PyObject *result;
    3518             :         PyObject *py_handle;
    3519           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, r->out.handle, r->out.handle);
    3520           0 :         result = py_handle;
    3521           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    3522           0 :                 PyErr_SetWERROR(r->out.result);
    3523           0 :                 return NULL;
    3524             :         }
    3525             : 
    3526           0 :         return result;
    3527             : }
    3528             : 
    3529             : 
    3530           0 : static PyObject *py_winreg_OpenHKU_in_get_system_name(PyObject *obj, void *closure)
    3531             : {
    3532           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(obj);
    3533             :         PyObject *py_system_name;
    3534           0 :         if (object->in.system_name == NULL) {
    3535           0 :                 Py_RETURN_NONE;
    3536             :         }
    3537           0 :         if (object->in.system_name == NULL) {
    3538           0 :                 py_system_name = Py_None;
    3539           0 :                 Py_INCREF(py_system_name);
    3540             :         } else {
    3541           0 :                 py_system_name = PyLong_FromLong((uint16_t)*object->in.system_name);
    3542             :         }
    3543           0 :         return py_system_name;
    3544             : }
    3545             : 
    3546           0 : static int py_winreg_OpenHKU_in_set_system_name(PyObject *py_obj, PyObject *value, void *closure)
    3547             : {
    3548           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3549           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.system_name));
    3550           0 :         if (value == NULL) {
    3551           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.system_name");
    3552           0 :                 return -1;
    3553             :         }
    3554           0 :         if (value == Py_None) {
    3555           0 :                 object->in.system_name = NULL;
    3556             :         } else {
    3557           0 :                 object->in.system_name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.system_name);
    3558           0 :                 if (object->in.system_name == NULL) {
    3559           0 :                         PyErr_NoMemory();
    3560           0 :                         return -1;
    3561             :                 }
    3562             :                 {
    3563           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.system_name));
    3564           0 :                         if (PyLong_Check(value)) {
    3565             :                                 unsigned long long test_var;
    3566           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    3567           0 :                                 if (PyErr_Occurred() != NULL) {
    3568           0 :                                         return -1;
    3569             :                                 }
    3570           0 :                                 if (test_var > uint_max) {
    3571           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    3572             :                                           PyLong_Type.tp_name, uint_max, test_var);
    3573           0 :                                         return -1;
    3574             :                                 }
    3575           0 :                                 *object->in.system_name = test_var;
    3576             :                         } else {
    3577           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    3578             :                                   PyLong_Type.tp_name);
    3579           0 :                                 return -1;
    3580             :                         }
    3581             :                 }
    3582             :         }
    3583           0 :         return 0;
    3584             : }
    3585             : 
    3586           0 : static PyObject *py_winreg_OpenHKU_in_get_access_mask(PyObject *obj, void *closure)
    3587             : {
    3588           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(obj);
    3589             :         PyObject *py_access_mask;
    3590           0 :         py_access_mask = PyLong_FromUnsignedLongLong((uint32_t)object->in.access_mask);
    3591           0 :         return py_access_mask;
    3592             : }
    3593             : 
    3594           0 : static int py_winreg_OpenHKU_in_set_access_mask(PyObject *py_obj, PyObject *value, void *closure)
    3595             : {
    3596           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3597           0 :         if (value == NULL) {
    3598           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.access_mask");
    3599           0 :                 return -1;
    3600             :         }
    3601             :         {
    3602           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.access_mask));
    3603           0 :                 if (PyLong_Check(value)) {
    3604             :                         unsigned long long test_var;
    3605           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    3606           0 :                         if (PyErr_Occurred() != NULL) {
    3607           0 :                                 return -1;
    3608             :                         }
    3609           0 :                         if (test_var > uint_max) {
    3610           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    3611             :                                   PyLong_Type.tp_name, uint_max, test_var);
    3612           0 :                                 return -1;
    3613             :                         }
    3614           0 :                         object->in.access_mask = test_var;
    3615             :                 } else {
    3616           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    3617             :                           PyLong_Type.tp_name);
    3618           0 :                         return -1;
    3619             :                 }
    3620             :         }
    3621           0 :         return 0;
    3622             : }
    3623             : 
    3624           0 : static PyObject *py_winreg_OpenHKU_out_get_handle(PyObject *obj, void *closure)
    3625             : {
    3626           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(obj);
    3627             :         PyObject *py_handle;
    3628           0 :         if (object->out.handle == NULL) {
    3629           0 :                 Py_RETURN_NONE;
    3630             :         }
    3631           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->out.handle, object->out.handle);
    3632           0 :         return py_handle;
    3633             : }
    3634             : 
    3635           0 : static int py_winreg_OpenHKU_out_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    3636             : {
    3637           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3638           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.handle));
    3639           0 :         if (value == NULL) {
    3640           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.handle");
    3641           0 :                 return -1;
    3642             :         }
    3643           0 :         object->out.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.handle);
    3644           0 :         if (object->out.handle == NULL) {
    3645           0 :                 PyErr_NoMemory();
    3646           0 :                 return -1;
    3647             :         }
    3648           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    3649           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    3650           0 :                 PyErr_NoMemory();
    3651           0 :                 return -1;
    3652             :         }
    3653           0 :         object->out.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    3654           0 :         return 0;
    3655             : }
    3656             : 
    3657           0 : static PyObject *py_winreg_OpenHKU_get_result(PyObject *obj, void *closure)
    3658             : {
    3659           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(obj);
    3660             :         PyObject *py_result;
    3661           0 :         py_result = PyErr_FromWERROR(object->out.result);
    3662           0 :         return py_result;
    3663             : }
    3664             : 
    3665           0 : static int py_winreg_OpenHKU_set_result(PyObject *py_obj, PyObject *value, void *closure)
    3666             : {
    3667           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3668           0 :         if (value == NULL) {
    3669           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    3670           0 :                 return -1;
    3671             :         }
    3672           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    3673           0 :         return 0;
    3674             : }
    3675             : 
    3676             : static PyGetSetDef py_winreg_OpenHKU_getsetters[] = {
    3677             :         {
    3678             :                 .name = discard_const_p(char, "in_system_name"),
    3679             :                 .get = py_winreg_OpenHKU_in_get_system_name,
    3680             :                 .set = py_winreg_OpenHKU_in_set_system_name,
    3681             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint16")
    3682             :         },
    3683             :         {
    3684             :                 .name = discard_const_p(char, "in_access_mask"),
    3685             :                 .get = py_winreg_OpenHKU_in_get_access_mask,
    3686             :                 .set = py_winreg_OpenHKU_in_set_access_mask,
    3687             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_AccessMask")
    3688             :         },
    3689             :         {
    3690             :                 .name = discard_const_p(char, "out_handle"),
    3691             :                 .get = py_winreg_OpenHKU_out_get_handle,
    3692             :                 .set = py_winreg_OpenHKU_out_set_handle,
    3693             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    3694             :         },
    3695             :         {
    3696             :                 .name = discard_const_p(char, "result"),
    3697             :                 .get = py_winreg_OpenHKU_get_result,
    3698             :                 .set = py_winreg_OpenHKU_set_result,
    3699             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    3700             :         },
    3701             :         { .name = NULL }
    3702             : };
    3703             : 
    3704           0 : static PyObject *py_winreg_OpenHKU_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    3705             : {
    3706           0 :         PyObject *self = pytalloc_new(struct winreg_OpenHKU, type);
    3707           0 :         struct winreg_OpenHKU *_self = (struct winreg_OpenHKU *)pytalloc_get_ptr(self);
    3708           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    3709           0 :         _self->out.handle = talloc_zero(mem_ctx, struct policy_handle);
    3710           0 :         return self;
    3711             : }
    3712             : 
    3713           0 : static PyObject *py_winreg_OpenHKU_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    3714             : {
    3715             : 
    3716             : 
    3717           0 :         return PyLong_FromLong(4);
    3718             : }
    3719             : 
    3720           0 : static PyObject *py_winreg_OpenHKU_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    3721             : {
    3722           0 :         const struct ndr_interface_call *call = NULL;
    3723           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3724           0 :         PyObject *ret = NULL;
    3725           0 :         struct ndr_push *push = NULL;
    3726             :         DATA_BLOB blob;
    3727             :         enum ndr_err_code err;
    3728             : 
    3729           0 :         if (ndr_table_winreg.num_calls < 5) {
    3730           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKU_ndr_pack");
    3731           0 :                 return NULL;
    3732             :         }
    3733           0 :         call = &ndr_table_winreg.calls[4];
    3734             : 
    3735           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    3736           0 :         if (push == NULL) {
    3737           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3738           0 :                 return NULL;
    3739             :         }
    3740             : 
    3741           0 :         push->flags |= ndr_push_flags;
    3742             : 
    3743           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    3744           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3745           0 :                 TALLOC_FREE(push);
    3746           0 :                 PyErr_SetNdrError(err);
    3747           0 :                 return NULL;
    3748             :         }
    3749           0 :         blob = ndr_push_blob(push);
    3750           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    3751           0 :         TALLOC_FREE(push);
    3752           0 :         return ret;
    3753             : }
    3754             : 
    3755           0 : static PyObject *py_winreg_OpenHKU_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3756             : {
    3757           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3758           0 :         PyObject *bigendian_obj = NULL;
    3759           0 :         PyObject *ndr64_obj = NULL;
    3760           0 :         uint32_t ndr_push_flags = 0;
    3761             : 
    3762           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    3763             :                 discard_const_p(char *, kwnames),
    3764             :                 &bigendian_obj,
    3765             :                 &ndr64_obj)) {
    3766           0 :                 return NULL;
    3767             :         }
    3768             : 
    3769           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3770           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3771             :         }
    3772           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3773           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3774             :         }
    3775             : 
    3776           0 :         return py_winreg_OpenHKU_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    3777             : }
    3778             : 
    3779           0 : static PyObject *py_winreg_OpenHKU_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3780             : {
    3781           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    3782           0 :         PyObject *bigendian_obj = NULL;
    3783           0 :         PyObject *ndr64_obj = NULL;
    3784           0 :         uint32_t ndr_push_flags = 0;
    3785             : 
    3786           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    3787             :                 discard_const_p(char *, kwnames),
    3788             :                 &bigendian_obj,
    3789             :                 &ndr64_obj)) {
    3790           0 :                 return NULL;
    3791             :         }
    3792             : 
    3793           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3794           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    3795             :         }
    3796           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3797           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    3798             :         }
    3799             : 
    3800           0 :         return py_winreg_OpenHKU_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    3801             : }
    3802             : 
    3803           0 : static PyObject *py_winreg_OpenHKU_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    3804             : {
    3805           0 :         const struct ndr_interface_call *call = NULL;
    3806           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3807           0 :         struct ndr_pull *pull = NULL;
    3808             :         enum ndr_err_code err;
    3809             : 
    3810           0 :         if (ndr_table_winreg.num_calls < 5) {
    3811           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKU_ndr_unpack");
    3812           0 :                 return NULL;
    3813             :         }
    3814           0 :         call = &ndr_table_winreg.calls[4];
    3815             : 
    3816           0 :         pull = ndr_pull_init_blob(blob, object);
    3817           0 :         if (pull == NULL) {
    3818           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    3819           0 :                 return NULL;
    3820             :         }
    3821             : 
    3822           0 :         pull->flags |= ndr_pull_flags;
    3823             : 
    3824           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    3825           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    3826           0 :                 TALLOC_FREE(pull);
    3827           0 :                 PyErr_SetNdrError(err);
    3828           0 :                 return NULL;
    3829             :         }
    3830           0 :         if (!allow_remaining) {
    3831             :                 uint32_t highest_ofs;
    3832             : 
    3833           0 :                 if (pull->offset > pull->relative_highest_offset) {
    3834           0 :                         highest_ofs = pull->offset;
    3835             :                 } else {
    3836           0 :                         highest_ofs = pull->relative_highest_offset;
    3837             :                 }
    3838           0 :                 if (highest_ofs < pull->data_size) {
    3839           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    3840             :                                 "not all bytes consumed ofs[%u] size[%u]",
    3841             :                                 highest_ofs, pull->data_size);
    3842           0 :                         TALLOC_FREE(pull);
    3843           0 :                         PyErr_SetNdrError(err);
    3844           0 :                         return NULL;
    3845             :                 }
    3846             :         }
    3847             : 
    3848           0 :         TALLOC_FREE(pull);
    3849           0 :         Py_RETURN_NONE;
    3850             : }
    3851             : 
    3852           0 : static PyObject *py_winreg_OpenHKU_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3853             : {
    3854             :         DATA_BLOB blob;
    3855           0 :         Py_ssize_t blob_length = 0;
    3856           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3857           0 :         PyObject *bigendian_obj = NULL;
    3858           0 :         PyObject *ndr64_obj = NULL;
    3859           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3860           0 :         PyObject *allow_remaining_obj = NULL;
    3861           0 :         bool allow_remaining = false;
    3862             : 
    3863           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    3864             :                 discard_const_p(char *, kwnames),
    3865             :                 &blob.data, &blob_length,
    3866             :                 &bigendian_obj,
    3867             :                 &ndr64_obj,
    3868             :                 &allow_remaining_obj)) {
    3869           0 :                 return NULL;
    3870             :         }
    3871           0 :         blob.length = blob_length;
    3872             : 
    3873           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3874           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3875             :         }
    3876           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3877           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3878             :         }
    3879             : 
    3880           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3881           0 :                 allow_remaining = true;
    3882             :         }
    3883             : 
    3884           0 :         return py_winreg_OpenHKU_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    3885             : }
    3886             : 
    3887           0 : static PyObject *py_winreg_OpenHKU_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    3888             : {
    3889             :         DATA_BLOB blob;
    3890           0 :         Py_ssize_t blob_length = 0;
    3891           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    3892           0 :         PyObject *bigendian_obj = NULL;
    3893           0 :         PyObject *ndr64_obj = NULL;
    3894           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    3895           0 :         PyObject *allow_remaining_obj = NULL;
    3896           0 :         bool allow_remaining = false;
    3897             : 
    3898           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    3899             :                 discard_const_p(char *, kwnames),
    3900             :                 &blob.data, &blob_length,
    3901             :                 &bigendian_obj,
    3902             :                 &ndr64_obj,
    3903             :                 &allow_remaining_obj)) {
    3904           0 :                 return NULL;
    3905             :         }
    3906           0 :         blob.length = blob_length;
    3907             : 
    3908           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    3909           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    3910             :         }
    3911           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    3912           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    3913             :         }
    3914             : 
    3915           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    3916           0 :                 allow_remaining = true;
    3917             :         }
    3918             : 
    3919           0 :         return py_winreg_OpenHKU_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    3920             : }
    3921             : 
    3922           0 : static PyObject *py_winreg_OpenHKU_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    3923             : {
    3924           0 :         const struct ndr_interface_call *call = NULL;
    3925           0 :         struct winreg_OpenHKU *object = (struct winreg_OpenHKU *)pytalloc_get_ptr(py_obj);
    3926             :         PyObject *ret;
    3927             :         char *retstr;
    3928             : 
    3929           0 :         if (ndr_table_winreg.num_calls < 5) {
    3930           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_OpenHKU_ndr_print");
    3931           0 :                 return NULL;
    3932             :         }
    3933           0 :         call = &ndr_table_winreg.calls[4];
    3934             : 
    3935           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    3936           0 :         ret = PyUnicode_FromString(retstr);
    3937           0 :         TALLOC_FREE(retstr);
    3938             : 
    3939           0 :         return ret;
    3940             : }
    3941             : 
    3942           0 : static PyObject *py_winreg_OpenHKU_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3943             : {
    3944           0 :         return py_winreg_OpenHKU_ndr_print(py_obj, "winreg_OpenHKU_in", NDR_IN);
    3945             : }
    3946             : 
    3947           0 : static PyObject *py_winreg_OpenHKU_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    3948             : {
    3949           0 :         return py_winreg_OpenHKU_ndr_print(py_obj, "winreg_OpenHKU_out", NDR_OUT);
    3950             : }
    3951             : 
    3952             : static PyMethodDef py_winreg_OpenHKU_methods[] = {
    3953             :         { "opnum", (PyCFunction)py_winreg_OpenHKU_ndr_opnum, METH_NOARGS|METH_CLASS,
    3954             :                 "winreg.OpenHKU.opnum() -> 4 (0x04) " },
    3955             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKU_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    3956             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    3957             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKU_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    3958             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    3959             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKU_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    3960             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    3961             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_OpenHKU_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    3962             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    3963             :         { "__ndr_print_in__", (PyCFunction)py_winreg_OpenHKU_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    3964             :         { "__ndr_print_out__", (PyCFunction)py_winreg_OpenHKU_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    3965             :         { NULL, NULL, 0, NULL }
    3966             : };
    3967             : 
    3968             : 
    3969             : static PyTypeObject winreg_OpenHKU_Type = {
    3970             :         PyVarObject_HEAD_INIT(NULL, 0)
    3971             :         .tp_name = "winreg.OpenHKU",
    3972             :         .tp_getset = py_winreg_OpenHKU_getsetters,
    3973             :         .tp_methods = py_winreg_OpenHKU_methods,
    3974             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    3975             :         .tp_new = py_winreg_OpenHKU_new,
    3976             : };
    3977             : 
    3978           0 : static bool pack_py_winreg_OpenHKU_args_in(PyObject *args, PyObject *kwargs, struct winreg_OpenHKU *r)
    3979             : {
    3980             :         PyObject *py_system_name;
    3981             :         PyObject *py_access_mask;
    3982           0 :         const char *kwnames[] = {
    3983             :                 "system_name", "access_mask", NULL
    3984             :         };
    3985             : 
    3986           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_OpenHKU", discard_const_p(char *, kwnames), &py_system_name, &py_access_mask)) {
    3987           0 :                 return false;
    3988             :         }
    3989             : 
    3990           0 :         if (py_system_name == NULL) {
    3991           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.system_name");
    3992           0 :                 return false;
    3993             :         }
    3994           0 :         if (py_system_name == Py_None) {
    3995           0 :                 r->in.system_name = NULL;
    3996             :         } else {
    3997           0 :                 r->in.system_name = talloc_ptrtype(r, r->in.system_name);
    3998           0 :                 if (r->in.system_name == NULL) {
    3999           0 :                         PyErr_NoMemory();
    4000           0 :                         return false;
    4001             :                 }
    4002             :                 {
    4003           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.system_name));
    4004           0 :                         if (PyLong_Check(py_system_name)) {
    4005             :                                 unsigned long long test_var;
    4006           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_system_name);
    4007           0 :                                 if (PyErr_Occurred() != NULL) {
    4008           0 :                                         return false;
    4009             :                                 }
    4010           0 :                                 if (test_var > uint_max) {
    4011           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    4012             :                                           PyLong_Type.tp_name, uint_max, test_var);
    4013           0 :                                         return false;
    4014             :                                 }
    4015           0 :                                 *r->in.system_name = test_var;
    4016             :                         } else {
    4017           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    4018             :                                   PyLong_Type.tp_name);
    4019           0 :                                 return false;
    4020             :                         }
    4021             :                 }
    4022             :         }
    4023           0 :         if (py_access_mask == NULL) {
    4024           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.access_mask");
    4025           0 :                 return false;
    4026             :         }
    4027             :         {
    4028           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.access_mask));
    4029           0 :                 if (PyLong_Check(py_access_mask)) {
    4030             :                         unsigned long long test_var;
    4031           0 :                         test_var = PyLong_AsUnsignedLongLong(py_access_mask);
    4032           0 :                         if (PyErr_Occurred() != NULL) {
    4033           0 :                                 return false;
    4034             :                         }
    4035           0 :                         if (test_var > uint_max) {
    4036           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    4037             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4038           0 :                                 return false;
    4039             :                         }
    4040           0 :                         r->in.access_mask = test_var;
    4041             :                 } else {
    4042           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    4043             :                           PyLong_Type.tp_name);
    4044           0 :                         return false;
    4045             :                 }
    4046             :         }
    4047           0 :         return true;
    4048             : }
    4049             : 
    4050           0 : static PyObject *unpack_py_winreg_OpenHKU_args_out(struct winreg_OpenHKU *r)
    4051             : {
    4052             :         PyObject *result;
    4053             :         PyObject *py_handle;
    4054           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, r->out.handle, r->out.handle);
    4055           0 :         result = py_handle;
    4056           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    4057           0 :                 PyErr_SetWERROR(r->out.result);
    4058           0 :                 return NULL;
    4059             :         }
    4060             : 
    4061           0 :         return result;
    4062             : }
    4063             : 
    4064             : 
    4065           0 : static PyObject *py_winreg_CloseKey_in_get_handle(PyObject *obj, void *closure)
    4066             : {
    4067           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(obj);
    4068             :         PyObject *py_handle;
    4069           0 :         if (object->in.handle == NULL) {
    4070           0 :                 Py_RETURN_NONE;
    4071             :         }
    4072           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    4073           0 :         return py_handle;
    4074             : }
    4075             : 
    4076           0 : static int py_winreg_CloseKey_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    4077             : {
    4078           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(py_obj);
    4079           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    4080           0 :         if (value == NULL) {
    4081           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    4082           0 :                 return -1;
    4083             :         }
    4084           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    4085           0 :         if (object->in.handle == NULL) {
    4086           0 :                 PyErr_NoMemory();
    4087           0 :                 return -1;
    4088             :         }
    4089           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    4090           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4091           0 :                 PyErr_NoMemory();
    4092           0 :                 return -1;
    4093             :         }
    4094           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    4095           0 :         return 0;
    4096             : }
    4097             : 
    4098           0 : static PyObject *py_winreg_CloseKey_out_get_handle(PyObject *obj, void *closure)
    4099             : {
    4100           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(obj);
    4101             :         PyObject *py_handle;
    4102           0 :         if (object->out.handle == NULL) {
    4103           0 :                 Py_RETURN_NONE;
    4104             :         }
    4105           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->out.handle, object->out.handle);
    4106           0 :         return py_handle;
    4107             : }
    4108             : 
    4109           0 : static int py_winreg_CloseKey_out_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    4110             : {
    4111           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(py_obj);
    4112           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.handle));
    4113           0 :         if (value == NULL) {
    4114           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.handle");
    4115           0 :                 return -1;
    4116             :         }
    4117           0 :         object->out.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.handle);
    4118           0 :         if (object->out.handle == NULL) {
    4119           0 :                 PyErr_NoMemory();
    4120           0 :                 return -1;
    4121             :         }
    4122           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    4123           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4124           0 :                 PyErr_NoMemory();
    4125           0 :                 return -1;
    4126             :         }
    4127           0 :         object->out.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    4128           0 :         return 0;
    4129             : }
    4130             : 
    4131           0 : static PyObject *py_winreg_CloseKey_get_result(PyObject *obj, void *closure)
    4132             : {
    4133           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(obj);
    4134             :         PyObject *py_result;
    4135           0 :         py_result = PyErr_FromWERROR(object->out.result);
    4136           0 :         return py_result;
    4137             : }
    4138             : 
    4139           0 : static int py_winreg_CloseKey_set_result(PyObject *py_obj, PyObject *value, void *closure)
    4140             : {
    4141           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(py_obj);
    4142           0 :         if (value == NULL) {
    4143           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    4144           0 :                 return -1;
    4145             :         }
    4146           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    4147           0 :         return 0;
    4148             : }
    4149             : 
    4150             : static PyGetSetDef py_winreg_CloseKey_getsetters[] = {
    4151             :         {
    4152             :                 .name = discard_const_p(char, "in_handle"),
    4153             :                 .get = py_winreg_CloseKey_in_get_handle,
    4154             :                 .set = py_winreg_CloseKey_in_set_handle,
    4155             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    4156             :         },
    4157             :         {
    4158             :                 .name = discard_const_p(char, "out_handle"),
    4159             :                 .get = py_winreg_CloseKey_out_get_handle,
    4160             :                 .set = py_winreg_CloseKey_out_set_handle,
    4161             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    4162             :         },
    4163             :         {
    4164             :                 .name = discard_const_p(char, "result"),
    4165             :                 .get = py_winreg_CloseKey_get_result,
    4166             :                 .set = py_winreg_CloseKey_set_result,
    4167             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    4168             :         },
    4169             :         { .name = NULL }
    4170             : };
    4171             : 
    4172           0 : static PyObject *py_winreg_CloseKey_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    4173             : {
    4174           0 :         PyObject *self = pytalloc_new(struct winreg_CloseKey, type);
    4175           0 :         struct winreg_CloseKey *_self = (struct winreg_CloseKey *)pytalloc_get_ptr(self);
    4176           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    4177           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    4178           0 :         _self->out.handle = talloc_zero(mem_ctx, struct policy_handle);
    4179           0 :         return self;
    4180             : }
    4181             : 
    4182           0 : static PyObject *py_winreg_CloseKey_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    4183             : {
    4184             : 
    4185             : 
    4186           0 :         return PyLong_FromLong(5);
    4187             : }
    4188             : 
    4189           0 : static PyObject *py_winreg_CloseKey_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    4190             : {
    4191           0 :         const struct ndr_interface_call *call = NULL;
    4192           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(py_obj);
    4193           0 :         PyObject *ret = NULL;
    4194           0 :         struct ndr_push *push = NULL;
    4195             :         DATA_BLOB blob;
    4196             :         enum ndr_err_code err;
    4197             : 
    4198           0 :         if (ndr_table_winreg.num_calls < 6) {
    4199           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_CloseKey_ndr_pack");
    4200           0 :                 return NULL;
    4201             :         }
    4202           0 :         call = &ndr_table_winreg.calls[5];
    4203             : 
    4204           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    4205           0 :         if (push == NULL) {
    4206           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4207           0 :                 return NULL;
    4208             :         }
    4209             : 
    4210           0 :         push->flags |= ndr_push_flags;
    4211             : 
    4212           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    4213           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4214           0 :                 TALLOC_FREE(push);
    4215           0 :                 PyErr_SetNdrError(err);
    4216           0 :                 return NULL;
    4217             :         }
    4218           0 :         blob = ndr_push_blob(push);
    4219           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    4220           0 :         TALLOC_FREE(push);
    4221           0 :         return ret;
    4222             : }
    4223             : 
    4224           0 : static PyObject *py_winreg_CloseKey_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4225             : {
    4226           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4227           0 :         PyObject *bigendian_obj = NULL;
    4228           0 :         PyObject *ndr64_obj = NULL;
    4229           0 :         uint32_t ndr_push_flags = 0;
    4230             : 
    4231           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    4232             :                 discard_const_p(char *, kwnames),
    4233             :                 &bigendian_obj,
    4234             :                 &ndr64_obj)) {
    4235           0 :                 return NULL;
    4236             :         }
    4237             : 
    4238           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4239           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4240             :         }
    4241           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4242           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4243             :         }
    4244             : 
    4245           0 :         return py_winreg_CloseKey_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    4246             : }
    4247             : 
    4248           0 : static PyObject *py_winreg_CloseKey_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4249             : {
    4250           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4251           0 :         PyObject *bigendian_obj = NULL;
    4252           0 :         PyObject *ndr64_obj = NULL;
    4253           0 :         uint32_t ndr_push_flags = 0;
    4254             : 
    4255           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    4256             :                 discard_const_p(char *, kwnames),
    4257             :                 &bigendian_obj,
    4258             :                 &ndr64_obj)) {
    4259           0 :                 return NULL;
    4260             :         }
    4261             : 
    4262           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4263           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4264             :         }
    4265           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4266           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4267             :         }
    4268             : 
    4269           0 :         return py_winreg_CloseKey_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    4270             : }
    4271             : 
    4272           0 : static PyObject *py_winreg_CloseKey_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    4273             : {
    4274           0 :         const struct ndr_interface_call *call = NULL;
    4275           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(py_obj);
    4276           0 :         struct ndr_pull *pull = NULL;
    4277             :         enum ndr_err_code err;
    4278             : 
    4279           0 :         if (ndr_table_winreg.num_calls < 6) {
    4280           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_CloseKey_ndr_unpack");
    4281           0 :                 return NULL;
    4282             :         }
    4283           0 :         call = &ndr_table_winreg.calls[5];
    4284             : 
    4285           0 :         pull = ndr_pull_init_blob(blob, object);
    4286           0 :         if (pull == NULL) {
    4287           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4288           0 :                 return NULL;
    4289             :         }
    4290             : 
    4291           0 :         pull->flags |= ndr_pull_flags;
    4292             : 
    4293           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    4294           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4295           0 :                 TALLOC_FREE(pull);
    4296           0 :                 PyErr_SetNdrError(err);
    4297           0 :                 return NULL;
    4298             :         }
    4299           0 :         if (!allow_remaining) {
    4300             :                 uint32_t highest_ofs;
    4301             : 
    4302           0 :                 if (pull->offset > pull->relative_highest_offset) {
    4303           0 :                         highest_ofs = pull->offset;
    4304             :                 } else {
    4305           0 :                         highest_ofs = pull->relative_highest_offset;
    4306             :                 }
    4307           0 :                 if (highest_ofs < pull->data_size) {
    4308           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    4309             :                                 "not all bytes consumed ofs[%u] size[%u]",
    4310             :                                 highest_ofs, pull->data_size);
    4311           0 :                         TALLOC_FREE(pull);
    4312           0 :                         PyErr_SetNdrError(err);
    4313           0 :                         return NULL;
    4314             :                 }
    4315             :         }
    4316             : 
    4317           0 :         TALLOC_FREE(pull);
    4318           0 :         Py_RETURN_NONE;
    4319             : }
    4320             : 
    4321           0 : static PyObject *py_winreg_CloseKey_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4322             : {
    4323             :         DATA_BLOB blob;
    4324           0 :         Py_ssize_t blob_length = 0;
    4325           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    4326           0 :         PyObject *bigendian_obj = NULL;
    4327           0 :         PyObject *ndr64_obj = NULL;
    4328           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    4329           0 :         PyObject *allow_remaining_obj = NULL;
    4330           0 :         bool allow_remaining = false;
    4331             : 
    4332           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    4333             :                 discard_const_p(char *, kwnames),
    4334             :                 &blob.data, &blob_length,
    4335             :                 &bigendian_obj,
    4336             :                 &ndr64_obj,
    4337             :                 &allow_remaining_obj)) {
    4338           0 :                 return NULL;
    4339             :         }
    4340           0 :         blob.length = blob_length;
    4341             : 
    4342           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4343           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    4344             :         }
    4345           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4346           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    4347             :         }
    4348             : 
    4349           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    4350           0 :                 allow_remaining = true;
    4351             :         }
    4352             : 
    4353           0 :         return py_winreg_CloseKey_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    4354             : }
    4355             : 
    4356           0 : static PyObject *py_winreg_CloseKey_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4357             : {
    4358             :         DATA_BLOB blob;
    4359           0 :         Py_ssize_t blob_length = 0;
    4360           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    4361           0 :         PyObject *bigendian_obj = NULL;
    4362           0 :         PyObject *ndr64_obj = NULL;
    4363           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    4364           0 :         PyObject *allow_remaining_obj = NULL;
    4365           0 :         bool allow_remaining = false;
    4366             : 
    4367           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    4368             :                 discard_const_p(char *, kwnames),
    4369             :                 &blob.data, &blob_length,
    4370             :                 &bigendian_obj,
    4371             :                 &ndr64_obj,
    4372             :                 &allow_remaining_obj)) {
    4373           0 :                 return NULL;
    4374             :         }
    4375           0 :         blob.length = blob_length;
    4376             : 
    4377           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4378           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    4379             :         }
    4380           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4381           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    4382             :         }
    4383             : 
    4384           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    4385           0 :                 allow_remaining = true;
    4386             :         }
    4387             : 
    4388           0 :         return py_winreg_CloseKey_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    4389             : }
    4390             : 
    4391           0 : static PyObject *py_winreg_CloseKey_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    4392             : {
    4393           0 :         const struct ndr_interface_call *call = NULL;
    4394           0 :         struct winreg_CloseKey *object = (struct winreg_CloseKey *)pytalloc_get_ptr(py_obj);
    4395             :         PyObject *ret;
    4396             :         char *retstr;
    4397             : 
    4398           0 :         if (ndr_table_winreg.num_calls < 6) {
    4399           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_CloseKey_ndr_print");
    4400           0 :                 return NULL;
    4401             :         }
    4402           0 :         call = &ndr_table_winreg.calls[5];
    4403             : 
    4404           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    4405           0 :         ret = PyUnicode_FromString(retstr);
    4406           0 :         TALLOC_FREE(retstr);
    4407             : 
    4408           0 :         return ret;
    4409             : }
    4410             : 
    4411           0 : static PyObject *py_winreg_CloseKey_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    4412             : {
    4413           0 :         return py_winreg_CloseKey_ndr_print(py_obj, "winreg_CloseKey_in", NDR_IN);
    4414             : }
    4415             : 
    4416           0 : static PyObject *py_winreg_CloseKey_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    4417             : {
    4418           0 :         return py_winreg_CloseKey_ndr_print(py_obj, "winreg_CloseKey_out", NDR_OUT);
    4419             : }
    4420             : 
    4421             : static PyMethodDef py_winreg_CloseKey_methods[] = {
    4422             :         { "opnum", (PyCFunction)py_winreg_CloseKey_ndr_opnum, METH_NOARGS|METH_CLASS,
    4423             :                 "winreg.CloseKey.opnum() -> 5 (0x05) " },
    4424             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CloseKey_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    4425             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    4426             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CloseKey_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    4427             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    4428             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CloseKey_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    4429             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    4430             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CloseKey_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    4431             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    4432             :         { "__ndr_print_in__", (PyCFunction)py_winreg_CloseKey_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    4433             :         { "__ndr_print_out__", (PyCFunction)py_winreg_CloseKey_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    4434             :         { NULL, NULL, 0, NULL }
    4435             : };
    4436             : 
    4437             : 
    4438             : static PyTypeObject winreg_CloseKey_Type = {
    4439             :         PyVarObject_HEAD_INIT(NULL, 0)
    4440             :         .tp_name = "winreg.CloseKey",
    4441             :         .tp_getset = py_winreg_CloseKey_getsetters,
    4442             :         .tp_methods = py_winreg_CloseKey_methods,
    4443             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    4444             :         .tp_new = py_winreg_CloseKey_new,
    4445             : };
    4446             : 
    4447           3 : static bool pack_py_winreg_CloseKey_args_in(PyObject *args, PyObject *kwargs, struct winreg_CloseKey *r)
    4448             : {
    4449             :         PyObject *py_handle;
    4450           3 :         const char *kwnames[] = {
    4451             :                 "handle", NULL
    4452             :         };
    4453             : 
    4454           3 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:winreg_CloseKey", discard_const_p(char *, kwnames), &py_handle)) {
    4455           0 :                 return false;
    4456             :         }
    4457             : 
    4458           3 :         if (py_handle == NULL) {
    4459           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    4460           0 :                 return false;
    4461             :         }
    4462           3 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    4463           3 :         if (r->in.handle == NULL) {
    4464           0 :                 PyErr_NoMemory();
    4465           0 :                 return false;
    4466             :         }
    4467           3 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    4468           3 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    4469           0 :                 PyErr_NoMemory();
    4470           0 :                 return false;
    4471             :         }
    4472           3 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    4473           3 :         return true;
    4474             : }
    4475             : 
    4476           3 : static PyObject *unpack_py_winreg_CloseKey_args_out(struct winreg_CloseKey *r)
    4477             : {
    4478             :         PyObject *result;
    4479             :         PyObject *py_handle;
    4480           3 :         py_handle = pytalloc_reference_ex(policy_handle_Type, r->out.handle, r->out.handle);
    4481           3 :         result = py_handle;
    4482           3 :         if (!W_ERROR_IS_OK(r->out.result)) {
    4483           0 :                 PyErr_SetWERROR(r->out.result);
    4484           0 :                 return NULL;
    4485             :         }
    4486             : 
    4487           3 :         return result;
    4488             : }
    4489             : 
    4490             : 
    4491           0 : static PyObject *py_winreg_CreateKey_in_get_handle(PyObject *obj, void *closure)
    4492             : {
    4493           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4494             :         PyObject *py_handle;
    4495           0 :         if (object->in.handle == NULL) {
    4496           0 :                 Py_RETURN_NONE;
    4497             :         }
    4498           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    4499           0 :         return py_handle;
    4500             : }
    4501             : 
    4502           0 : static int py_winreg_CreateKey_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    4503             : {
    4504           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4505           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    4506           0 :         if (value == NULL) {
    4507           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    4508           0 :                 return -1;
    4509             :         }
    4510           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    4511           0 :         if (object->in.handle == NULL) {
    4512           0 :                 PyErr_NoMemory();
    4513           0 :                 return -1;
    4514             :         }
    4515           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    4516           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4517           0 :                 PyErr_NoMemory();
    4518           0 :                 return -1;
    4519             :         }
    4520           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    4521           0 :         return 0;
    4522             : }
    4523             : 
    4524           0 : static PyObject *py_winreg_CreateKey_in_get_name(PyObject *obj, void *closure)
    4525             : {
    4526           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4527             :         PyObject *py_name;
    4528           0 :         py_name = pytalloc_reference_ex(&winreg_String_Type, pytalloc_get_mem_ctx(obj), &object->in.name);
    4529           0 :         return py_name;
    4530             : }
    4531             : 
    4532           0 : static int py_winreg_CreateKey_in_set_name(PyObject *py_obj, PyObject *value, void *closure)
    4533             : {
    4534           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4535           0 :         if (value == NULL) {
    4536           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.name");
    4537           0 :                 return -1;
    4538             :         }
    4539           0 :         PY_CHECK_TYPE(&winreg_String_Type, value, return -1;);
    4540           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4541           0 :                 PyErr_NoMemory();
    4542           0 :                 return -1;
    4543             :         }
    4544           0 :         object->in.name = *(struct winreg_String *)pytalloc_get_ptr(value);
    4545           0 :         return 0;
    4546             : }
    4547             : 
    4548           0 : static PyObject *py_winreg_CreateKey_in_get_keyclass(PyObject *obj, void *closure)
    4549             : {
    4550           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4551             :         PyObject *py_keyclass;
    4552           0 :         py_keyclass = pytalloc_reference_ex(&winreg_String_Type, pytalloc_get_mem_ctx(obj), &object->in.keyclass);
    4553           0 :         return py_keyclass;
    4554             : }
    4555             : 
    4556           0 : static int py_winreg_CreateKey_in_set_keyclass(PyObject *py_obj, PyObject *value, void *closure)
    4557             : {
    4558           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4559           0 :         if (value == NULL) {
    4560           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.keyclass");
    4561           0 :                 return -1;
    4562             :         }
    4563           0 :         PY_CHECK_TYPE(&winreg_String_Type, value, return -1;);
    4564           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4565           0 :                 PyErr_NoMemory();
    4566           0 :                 return -1;
    4567             :         }
    4568           0 :         object->in.keyclass = *(struct winreg_String *)pytalloc_get_ptr(value);
    4569           0 :         return 0;
    4570             : }
    4571             : 
    4572           0 : static PyObject *py_winreg_CreateKey_in_get_options(PyObject *obj, void *closure)
    4573             : {
    4574           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4575             :         PyObject *py_options;
    4576           0 :         py_options = PyLong_FromUnsignedLongLong((uint32_t)object->in.options);
    4577           0 :         return py_options;
    4578             : }
    4579             : 
    4580           0 : static int py_winreg_CreateKey_in_set_options(PyObject *py_obj, PyObject *value, void *closure)
    4581             : {
    4582           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4583           0 :         if (value == NULL) {
    4584           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.options");
    4585           0 :                 return -1;
    4586             :         }
    4587             :         {
    4588           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.options));
    4589           0 :                 if (PyLong_Check(value)) {
    4590             :                         unsigned long long test_var;
    4591           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    4592           0 :                         if (PyErr_Occurred() != NULL) {
    4593           0 :                                 return -1;
    4594             :                         }
    4595           0 :                         if (test_var > uint_max) {
    4596           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    4597             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4598           0 :                                 return -1;
    4599             :                         }
    4600           0 :                         object->in.options = test_var;
    4601             :                 } else {
    4602           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    4603             :                           PyLong_Type.tp_name);
    4604           0 :                         return -1;
    4605             :                 }
    4606             :         }
    4607           0 :         return 0;
    4608             : }
    4609             : 
    4610           0 : static PyObject *py_winreg_CreateKey_in_get_access_mask(PyObject *obj, void *closure)
    4611             : {
    4612           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4613             :         PyObject *py_access_mask;
    4614           0 :         py_access_mask = PyLong_FromUnsignedLongLong((uint32_t)object->in.access_mask);
    4615           0 :         return py_access_mask;
    4616             : }
    4617             : 
    4618           0 : static int py_winreg_CreateKey_in_set_access_mask(PyObject *py_obj, PyObject *value, void *closure)
    4619             : {
    4620           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4621           0 :         if (value == NULL) {
    4622           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.access_mask");
    4623           0 :                 return -1;
    4624             :         }
    4625             :         {
    4626           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.access_mask));
    4627           0 :                 if (PyLong_Check(value)) {
    4628             :                         unsigned long long test_var;
    4629           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    4630           0 :                         if (PyErr_Occurred() != NULL) {
    4631           0 :                                 return -1;
    4632             :                         }
    4633           0 :                         if (test_var > uint_max) {
    4634           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    4635             :                                   PyLong_Type.tp_name, uint_max, test_var);
    4636           0 :                                 return -1;
    4637             :                         }
    4638           0 :                         object->in.access_mask = test_var;
    4639             :                 } else {
    4640           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    4641             :                           PyLong_Type.tp_name);
    4642           0 :                         return -1;
    4643             :                 }
    4644             :         }
    4645           0 :         return 0;
    4646             : }
    4647             : 
    4648           0 : static PyObject *py_winreg_CreateKey_in_get_secdesc(PyObject *obj, void *closure)
    4649             : {
    4650           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4651             :         PyObject *py_secdesc;
    4652           0 :         if (object->in.secdesc == NULL) {
    4653           0 :                 Py_RETURN_NONE;
    4654             :         }
    4655           0 :         if (object->in.secdesc == NULL) {
    4656           0 :                 py_secdesc = Py_None;
    4657           0 :                 Py_INCREF(py_secdesc);
    4658             :         } else {
    4659           0 :                 py_secdesc = pytalloc_reference_ex(&winreg_SecBuf_Type, object->in.secdesc, object->in.secdesc);
    4660             :         }
    4661           0 :         return py_secdesc;
    4662             : }
    4663             : 
    4664           0 : static int py_winreg_CreateKey_in_set_secdesc(PyObject *py_obj, PyObject *value, void *closure)
    4665             : {
    4666           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4667           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.secdesc));
    4668           0 :         if (value == NULL) {
    4669           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.secdesc");
    4670           0 :                 return -1;
    4671             :         }
    4672           0 :         if (value == Py_None) {
    4673           0 :                 object->in.secdesc = NULL;
    4674             :         } else {
    4675           0 :                 object->in.secdesc = NULL;
    4676           0 :                 PY_CHECK_TYPE(&winreg_SecBuf_Type, value, return -1;);
    4677           0 :                 if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4678           0 :                         PyErr_NoMemory();
    4679           0 :                         return -1;
    4680             :                 }
    4681           0 :                 object->in.secdesc = (struct winreg_SecBuf *)pytalloc_get_ptr(value);
    4682             :         }
    4683           0 :         return 0;
    4684             : }
    4685             : 
    4686           0 : static PyObject *py_winreg_CreateKey_out_get_new_handle(PyObject *obj, void *closure)
    4687             : {
    4688           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4689             :         PyObject *py_new_handle;
    4690           0 :         if (object->out.new_handle == NULL) {
    4691           0 :                 Py_RETURN_NONE;
    4692             :         }
    4693           0 :         py_new_handle = pytalloc_reference_ex(policy_handle_Type, object->out.new_handle, object->out.new_handle);
    4694           0 :         return py_new_handle;
    4695             : }
    4696             : 
    4697           0 : static int py_winreg_CreateKey_out_set_new_handle(PyObject *py_obj, PyObject *value, void *closure)
    4698             : {
    4699           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4700           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.new_handle));
    4701           0 :         if (value == NULL) {
    4702           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.new_handle");
    4703           0 :                 return -1;
    4704             :         }
    4705           0 :         object->out.new_handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.new_handle);
    4706           0 :         if (object->out.new_handle == NULL) {
    4707           0 :                 PyErr_NoMemory();
    4708           0 :                 return -1;
    4709             :         }
    4710           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    4711           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    4712           0 :                 PyErr_NoMemory();
    4713           0 :                 return -1;
    4714             :         }
    4715           0 :         object->out.new_handle = (struct policy_handle *)pytalloc_get_ptr(value);
    4716           0 :         return 0;
    4717             : }
    4718             : 
    4719           0 : static PyObject *py_winreg_CreateKey_in_get_action_taken(PyObject *obj, void *closure)
    4720             : {
    4721           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4722             :         PyObject *py_action_taken;
    4723           0 :         if (object->in.action_taken == NULL) {
    4724           0 :                 Py_RETURN_NONE;
    4725             :         }
    4726           0 :         if (object->in.action_taken == NULL) {
    4727           0 :                 py_action_taken = Py_None;
    4728           0 :                 Py_INCREF(py_action_taken);
    4729             :         } else {
    4730           0 :                 py_action_taken = PyLong_FromUnsignedLongLong((uint32_t)*object->in.action_taken);
    4731             :         }
    4732           0 :         return py_action_taken;
    4733             : }
    4734             : 
    4735           0 : static int py_winreg_CreateKey_in_set_action_taken(PyObject *py_obj, PyObject *value, void *closure)
    4736             : {
    4737           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4738           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.action_taken));
    4739           0 :         if (value == NULL) {
    4740           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.action_taken");
    4741           0 :                 return -1;
    4742             :         }
    4743           0 :         if (value == Py_None) {
    4744           0 :                 object->in.action_taken = NULL;
    4745             :         } else {
    4746           0 :                 object->in.action_taken = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.action_taken);
    4747           0 :                 if (object->in.action_taken == NULL) {
    4748           0 :                         PyErr_NoMemory();
    4749           0 :                         return -1;
    4750             :                 }
    4751             :                 {
    4752           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.action_taken));
    4753           0 :                         if (PyLong_Check(value)) {
    4754             :                                 unsigned long long test_var;
    4755           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    4756           0 :                                 if (PyErr_Occurred() != NULL) {
    4757           0 :                                         return -1;
    4758             :                                 }
    4759           0 :                                 if (test_var > uint_max) {
    4760           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    4761             :                                           PyLong_Type.tp_name, uint_max, test_var);
    4762           0 :                                         return -1;
    4763             :                                 }
    4764           0 :                                 *object->in.action_taken = test_var;
    4765             :                         } else {
    4766           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    4767             :                                   PyLong_Type.tp_name);
    4768           0 :                                 return -1;
    4769             :                         }
    4770             :                 }
    4771             :         }
    4772           0 :         return 0;
    4773             : }
    4774             : 
    4775           0 : static PyObject *py_winreg_CreateKey_out_get_action_taken(PyObject *obj, void *closure)
    4776             : {
    4777           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4778             :         PyObject *py_action_taken;
    4779           0 :         if (object->out.action_taken == NULL) {
    4780           0 :                 Py_RETURN_NONE;
    4781             :         }
    4782           0 :         if (object->out.action_taken == NULL) {
    4783           0 :                 py_action_taken = Py_None;
    4784           0 :                 Py_INCREF(py_action_taken);
    4785             :         } else {
    4786           0 :                 py_action_taken = PyLong_FromUnsignedLongLong((uint32_t)*object->out.action_taken);
    4787             :         }
    4788           0 :         return py_action_taken;
    4789             : }
    4790             : 
    4791           0 : static int py_winreg_CreateKey_out_set_action_taken(PyObject *py_obj, PyObject *value, void *closure)
    4792             : {
    4793           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4794           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.action_taken));
    4795           0 :         if (value == NULL) {
    4796           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.action_taken");
    4797           0 :                 return -1;
    4798             :         }
    4799           0 :         if (value == Py_None) {
    4800           0 :                 object->out.action_taken = NULL;
    4801             :         } else {
    4802           0 :                 object->out.action_taken = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.action_taken);
    4803           0 :                 if (object->out.action_taken == NULL) {
    4804           0 :                         PyErr_NoMemory();
    4805           0 :                         return -1;
    4806             :                 }
    4807             :                 {
    4808           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.action_taken));
    4809           0 :                         if (PyLong_Check(value)) {
    4810             :                                 unsigned long long test_var;
    4811           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    4812           0 :                                 if (PyErr_Occurred() != NULL) {
    4813           0 :                                         return -1;
    4814             :                                 }
    4815           0 :                                 if (test_var > uint_max) {
    4816           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    4817             :                                           PyLong_Type.tp_name, uint_max, test_var);
    4818           0 :                                         return -1;
    4819             :                                 }
    4820           0 :                                 *object->out.action_taken = test_var;
    4821             :                         } else {
    4822           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    4823             :                                   PyLong_Type.tp_name);
    4824           0 :                                 return -1;
    4825             :                         }
    4826             :                 }
    4827             :         }
    4828           0 :         return 0;
    4829             : }
    4830             : 
    4831           0 : static PyObject *py_winreg_CreateKey_get_result(PyObject *obj, void *closure)
    4832             : {
    4833           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(obj);
    4834             :         PyObject *py_result;
    4835           0 :         py_result = PyErr_FromWERROR(object->out.result);
    4836           0 :         return py_result;
    4837             : }
    4838             : 
    4839           0 : static int py_winreg_CreateKey_set_result(PyObject *py_obj, PyObject *value, void *closure)
    4840             : {
    4841           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4842           0 :         if (value == NULL) {
    4843           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    4844           0 :                 return -1;
    4845             :         }
    4846           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    4847           0 :         return 0;
    4848             : }
    4849             : 
    4850             : static PyGetSetDef py_winreg_CreateKey_getsetters[] = {
    4851             :         {
    4852             :                 .name = discard_const_p(char, "in_handle"),
    4853             :                 .get = py_winreg_CreateKey_in_get_handle,
    4854             :                 .set = py_winreg_CreateKey_in_set_handle,
    4855             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    4856             :         },
    4857             :         {
    4858             :                 .name = discard_const_p(char, "in_name"),
    4859             :                 .get = py_winreg_CreateKey_in_get_name,
    4860             :                 .set = py_winreg_CreateKey_in_set_name,
    4861             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_String")
    4862             :         },
    4863             :         {
    4864             :                 .name = discard_const_p(char, "in_keyclass"),
    4865             :                 .get = py_winreg_CreateKey_in_get_keyclass,
    4866             :                 .set = py_winreg_CreateKey_in_set_keyclass,
    4867             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_String")
    4868             :         },
    4869             :         {
    4870             :                 .name = discard_const_p(char, "in_options"),
    4871             :                 .get = py_winreg_CreateKey_in_get_options,
    4872             :                 .set = py_winreg_CreateKey_in_set_options,
    4873             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_KeyOptions")
    4874             :         },
    4875             :         {
    4876             :                 .name = discard_const_p(char, "in_access_mask"),
    4877             :                 .get = py_winreg_CreateKey_in_get_access_mask,
    4878             :                 .set = py_winreg_CreateKey_in_set_access_mask,
    4879             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_AccessMask")
    4880             :         },
    4881             :         {
    4882             :                 .name = discard_const_p(char, "in_secdesc"),
    4883             :                 .get = py_winreg_CreateKey_in_get_secdesc,
    4884             :                 .set = py_winreg_CreateKey_in_set_secdesc,
    4885             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_SecBuf")
    4886             :         },
    4887             :         {
    4888             :                 .name = discard_const_p(char, "out_new_handle"),
    4889             :                 .get = py_winreg_CreateKey_out_get_new_handle,
    4890             :                 .set = py_winreg_CreateKey_out_set_new_handle,
    4891             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    4892             :         },
    4893             :         {
    4894             :                 .name = discard_const_p(char, "in_action_taken"),
    4895             :                 .get = py_winreg_CreateKey_in_get_action_taken,
    4896             :                 .set = py_winreg_CreateKey_in_set_action_taken,
    4897             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_CreateAction")
    4898             :         },
    4899             :         {
    4900             :                 .name = discard_const_p(char, "out_action_taken"),
    4901             :                 .get = py_winreg_CreateKey_out_get_action_taken,
    4902             :                 .set = py_winreg_CreateKey_out_set_action_taken,
    4903             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_CreateAction")
    4904             :         },
    4905             :         {
    4906             :                 .name = discard_const_p(char, "result"),
    4907             :                 .get = py_winreg_CreateKey_get_result,
    4908             :                 .set = py_winreg_CreateKey_set_result,
    4909             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    4910             :         },
    4911             :         { .name = NULL }
    4912             : };
    4913             : 
    4914           0 : static PyObject *py_winreg_CreateKey_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    4915             : {
    4916           0 :         PyObject *self = pytalloc_new(struct winreg_CreateKey, type);
    4917           0 :         struct winreg_CreateKey *_self = (struct winreg_CreateKey *)pytalloc_get_ptr(self);
    4918           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    4919           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    4920           0 :         _self->out.new_handle = talloc_zero(mem_ctx, struct policy_handle);
    4921           0 :         return self;
    4922             : }
    4923             : 
    4924           0 : static PyObject *py_winreg_CreateKey_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    4925             : {
    4926             : 
    4927             : 
    4928           0 :         return PyLong_FromLong(6);
    4929             : }
    4930             : 
    4931           0 : static PyObject *py_winreg_CreateKey_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    4932             : {
    4933           0 :         const struct ndr_interface_call *call = NULL;
    4934           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    4935           0 :         PyObject *ret = NULL;
    4936           0 :         struct ndr_push *push = NULL;
    4937             :         DATA_BLOB blob;
    4938             :         enum ndr_err_code err;
    4939             : 
    4940           0 :         if (ndr_table_winreg.num_calls < 7) {
    4941           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_CreateKey_ndr_pack");
    4942           0 :                 return NULL;
    4943             :         }
    4944           0 :         call = &ndr_table_winreg.calls[6];
    4945             : 
    4946           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    4947           0 :         if (push == NULL) {
    4948           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    4949           0 :                 return NULL;
    4950             :         }
    4951             : 
    4952           0 :         push->flags |= ndr_push_flags;
    4953             : 
    4954           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    4955           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    4956           0 :                 TALLOC_FREE(push);
    4957           0 :                 PyErr_SetNdrError(err);
    4958           0 :                 return NULL;
    4959             :         }
    4960           0 :         blob = ndr_push_blob(push);
    4961           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    4962           0 :         TALLOC_FREE(push);
    4963           0 :         return ret;
    4964             : }
    4965             : 
    4966           0 : static PyObject *py_winreg_CreateKey_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4967             : {
    4968           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4969           0 :         PyObject *bigendian_obj = NULL;
    4970           0 :         PyObject *ndr64_obj = NULL;
    4971           0 :         uint32_t ndr_push_flags = 0;
    4972             : 
    4973           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    4974             :                 discard_const_p(char *, kwnames),
    4975             :                 &bigendian_obj,
    4976             :                 &ndr64_obj)) {
    4977           0 :                 return NULL;
    4978             :         }
    4979             : 
    4980           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    4981           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    4982             :         }
    4983           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    4984           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    4985             :         }
    4986             : 
    4987           0 :         return py_winreg_CreateKey_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    4988             : }
    4989             : 
    4990           0 : static PyObject *py_winreg_CreateKey_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    4991             : {
    4992           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    4993           0 :         PyObject *bigendian_obj = NULL;
    4994           0 :         PyObject *ndr64_obj = NULL;
    4995           0 :         uint32_t ndr_push_flags = 0;
    4996             : 
    4997           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    4998             :                 discard_const_p(char *, kwnames),
    4999             :                 &bigendian_obj,
    5000             :                 &ndr64_obj)) {
    5001           0 :                 return NULL;
    5002             :         }
    5003             : 
    5004           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5005           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5006             :         }
    5007           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5008           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5009             :         }
    5010             : 
    5011           0 :         return py_winreg_CreateKey_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    5012             : }
    5013             : 
    5014           0 : static PyObject *py_winreg_CreateKey_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    5015             : {
    5016           0 :         const struct ndr_interface_call *call = NULL;
    5017           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    5018           0 :         struct ndr_pull *pull = NULL;
    5019             :         enum ndr_err_code err;
    5020             : 
    5021           0 :         if (ndr_table_winreg.num_calls < 7) {
    5022           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_CreateKey_ndr_unpack");
    5023           0 :                 return NULL;
    5024             :         }
    5025           0 :         call = &ndr_table_winreg.calls[6];
    5026             : 
    5027           0 :         pull = ndr_pull_init_blob(blob, object);
    5028           0 :         if (pull == NULL) {
    5029           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5030           0 :                 return NULL;
    5031             :         }
    5032             : 
    5033           0 :         pull->flags |= ndr_pull_flags;
    5034             : 
    5035           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    5036           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5037           0 :                 TALLOC_FREE(pull);
    5038           0 :                 PyErr_SetNdrError(err);
    5039           0 :                 return NULL;
    5040             :         }
    5041           0 :         if (!allow_remaining) {
    5042             :                 uint32_t highest_ofs;
    5043             : 
    5044           0 :                 if (pull->offset > pull->relative_highest_offset) {
    5045           0 :                         highest_ofs = pull->offset;
    5046             :                 } else {
    5047           0 :                         highest_ofs = pull->relative_highest_offset;
    5048             :                 }
    5049           0 :                 if (highest_ofs < pull->data_size) {
    5050           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    5051             :                                 "not all bytes consumed ofs[%u] size[%u]",
    5052             :                                 highest_ofs, pull->data_size);
    5053           0 :                         TALLOC_FREE(pull);
    5054           0 :                         PyErr_SetNdrError(err);
    5055           0 :                         return NULL;
    5056             :                 }
    5057             :         }
    5058             : 
    5059           0 :         TALLOC_FREE(pull);
    5060           0 :         Py_RETURN_NONE;
    5061             : }
    5062             : 
    5063           0 : static PyObject *py_winreg_CreateKey_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5064             : {
    5065             :         DATA_BLOB blob;
    5066           0 :         Py_ssize_t blob_length = 0;
    5067           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5068           0 :         PyObject *bigendian_obj = NULL;
    5069           0 :         PyObject *ndr64_obj = NULL;
    5070           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5071           0 :         PyObject *allow_remaining_obj = NULL;
    5072           0 :         bool allow_remaining = false;
    5073             : 
    5074           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    5075             :                 discard_const_p(char *, kwnames),
    5076             :                 &blob.data, &blob_length,
    5077             :                 &bigendian_obj,
    5078             :                 &ndr64_obj,
    5079             :                 &allow_remaining_obj)) {
    5080           0 :                 return NULL;
    5081             :         }
    5082           0 :         blob.length = blob_length;
    5083             : 
    5084           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5085           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5086             :         }
    5087           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5088           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5089             :         }
    5090             : 
    5091           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5092           0 :                 allow_remaining = true;
    5093             :         }
    5094             : 
    5095           0 :         return py_winreg_CreateKey_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    5096             : }
    5097             : 
    5098           0 : static PyObject *py_winreg_CreateKey_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5099             : {
    5100             :         DATA_BLOB blob;
    5101           0 :         Py_ssize_t blob_length = 0;
    5102           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5103           0 :         PyObject *bigendian_obj = NULL;
    5104           0 :         PyObject *ndr64_obj = NULL;
    5105           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5106           0 :         PyObject *allow_remaining_obj = NULL;
    5107           0 :         bool allow_remaining = false;
    5108             : 
    5109           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    5110             :                 discard_const_p(char *, kwnames),
    5111             :                 &blob.data, &blob_length,
    5112             :                 &bigendian_obj,
    5113             :                 &ndr64_obj,
    5114             :                 &allow_remaining_obj)) {
    5115           0 :                 return NULL;
    5116             :         }
    5117           0 :         blob.length = blob_length;
    5118             : 
    5119           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5120           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5121             :         }
    5122           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5123           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5124             :         }
    5125             : 
    5126           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5127           0 :                 allow_remaining = true;
    5128             :         }
    5129             : 
    5130           0 :         return py_winreg_CreateKey_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    5131             : }
    5132             : 
    5133           0 : static PyObject *py_winreg_CreateKey_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    5134             : {
    5135           0 :         const struct ndr_interface_call *call = NULL;
    5136           0 :         struct winreg_CreateKey *object = (struct winreg_CreateKey *)pytalloc_get_ptr(py_obj);
    5137             :         PyObject *ret;
    5138             :         char *retstr;
    5139             : 
    5140           0 :         if (ndr_table_winreg.num_calls < 7) {
    5141           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_CreateKey_ndr_print");
    5142           0 :                 return NULL;
    5143             :         }
    5144           0 :         call = &ndr_table_winreg.calls[6];
    5145             : 
    5146           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    5147           0 :         ret = PyUnicode_FromString(retstr);
    5148           0 :         TALLOC_FREE(retstr);
    5149             : 
    5150           0 :         return ret;
    5151             : }
    5152             : 
    5153           0 : static PyObject *py_winreg_CreateKey_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5154             : {
    5155           0 :         return py_winreg_CreateKey_ndr_print(py_obj, "winreg_CreateKey_in", NDR_IN);
    5156             : }
    5157             : 
    5158           0 : static PyObject *py_winreg_CreateKey_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5159             : {
    5160           0 :         return py_winreg_CreateKey_ndr_print(py_obj, "winreg_CreateKey_out", NDR_OUT);
    5161             : }
    5162             : 
    5163             : static PyMethodDef py_winreg_CreateKey_methods[] = {
    5164             :         { "opnum", (PyCFunction)py_winreg_CreateKey_ndr_opnum, METH_NOARGS|METH_CLASS,
    5165             :                 "winreg.CreateKey.opnum() -> 6 (0x06) " },
    5166             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CreateKey_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    5167             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    5168             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CreateKey_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    5169             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    5170             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CreateKey_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    5171             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    5172             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_CreateKey_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    5173             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    5174             :         { "__ndr_print_in__", (PyCFunction)py_winreg_CreateKey_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    5175             :         { "__ndr_print_out__", (PyCFunction)py_winreg_CreateKey_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    5176             :         { NULL, NULL, 0, NULL }
    5177             : };
    5178             : 
    5179             : 
    5180             : static PyTypeObject winreg_CreateKey_Type = {
    5181             :         PyVarObject_HEAD_INIT(NULL, 0)
    5182             :         .tp_name = "winreg.CreateKey",
    5183             :         .tp_getset = py_winreg_CreateKey_getsetters,
    5184             :         .tp_methods = py_winreg_CreateKey_methods,
    5185             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    5186             :         .tp_new = py_winreg_CreateKey_new,
    5187             : };
    5188             : 
    5189           0 : static bool pack_py_winreg_CreateKey_args_in(PyObject *args, PyObject *kwargs, struct winreg_CreateKey *r)
    5190             : {
    5191             :         PyObject *py_handle;
    5192             :         PyObject *py_name;
    5193             :         PyObject *py_keyclass;
    5194             :         PyObject *py_options;
    5195             :         PyObject *py_access_mask;
    5196             :         PyObject *py_secdesc;
    5197             :         PyObject *py_action_taken;
    5198           0 :         const char *kwnames[] = {
    5199             :                 "handle", "name", "keyclass", "options", "access_mask", "secdesc", "action_taken", NULL
    5200             :         };
    5201             : 
    5202           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOO:winreg_CreateKey", discard_const_p(char *, kwnames), &py_handle, &py_name, &py_keyclass, &py_options, &py_access_mask, &py_secdesc, &py_action_taken)) {
    5203           0 :                 return false;
    5204             :         }
    5205             : 
    5206           0 :         if (py_handle == NULL) {
    5207           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    5208           0 :                 return false;
    5209             :         }
    5210           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    5211           0 :         if (r->in.handle == NULL) {
    5212           0 :                 PyErr_NoMemory();
    5213           0 :                 return false;
    5214             :         }
    5215           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    5216           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    5217           0 :                 PyErr_NoMemory();
    5218           0 :                 return false;
    5219             :         }
    5220           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    5221           0 :         if (py_name == NULL) {
    5222           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.name");
    5223           0 :                 return false;
    5224             :         }
    5225           0 :         PY_CHECK_TYPE(&winreg_String_Type, py_name, return false;);
    5226           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_name)) == NULL) {
    5227           0 :                 PyErr_NoMemory();
    5228           0 :                 return false;
    5229             :         }
    5230           0 :         r->in.name = *(struct winreg_String *)pytalloc_get_ptr(py_name);
    5231           0 :         if (py_keyclass == NULL) {
    5232           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.keyclass");
    5233           0 :                 return false;
    5234             :         }
    5235           0 :         PY_CHECK_TYPE(&winreg_String_Type, py_keyclass, return false;);
    5236           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_keyclass)) == NULL) {
    5237           0 :                 PyErr_NoMemory();
    5238           0 :                 return false;
    5239             :         }
    5240           0 :         r->in.keyclass = *(struct winreg_String *)pytalloc_get_ptr(py_keyclass);
    5241           0 :         if (py_options == NULL) {
    5242           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.options");
    5243           0 :                 return false;
    5244             :         }
    5245             :         {
    5246           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.options));
    5247           0 :                 if (PyLong_Check(py_options)) {
    5248             :                         unsigned long long test_var;
    5249           0 :                         test_var = PyLong_AsUnsignedLongLong(py_options);
    5250           0 :                         if (PyErr_Occurred() != NULL) {
    5251           0 :                                 return false;
    5252             :                         }
    5253           0 :                         if (test_var > uint_max) {
    5254           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    5255             :                                   PyLong_Type.tp_name, uint_max, test_var);
    5256           0 :                                 return false;
    5257             :                         }
    5258           0 :                         r->in.options = test_var;
    5259             :                 } else {
    5260           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    5261             :                           PyLong_Type.tp_name);
    5262           0 :                         return false;
    5263             :                 }
    5264             :         }
    5265           0 :         if (py_access_mask == NULL) {
    5266           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.access_mask");
    5267           0 :                 return false;
    5268             :         }
    5269             :         {
    5270           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.access_mask));
    5271           0 :                 if (PyLong_Check(py_access_mask)) {
    5272             :                         unsigned long long test_var;
    5273           0 :                         test_var = PyLong_AsUnsignedLongLong(py_access_mask);
    5274           0 :                         if (PyErr_Occurred() != NULL) {
    5275           0 :                                 return false;
    5276             :                         }
    5277           0 :                         if (test_var > uint_max) {
    5278           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    5279             :                                   PyLong_Type.tp_name, uint_max, test_var);
    5280           0 :                                 return false;
    5281             :                         }
    5282           0 :                         r->in.access_mask = test_var;
    5283             :                 } else {
    5284           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    5285             :                           PyLong_Type.tp_name);
    5286           0 :                         return false;
    5287             :                 }
    5288             :         }
    5289           0 :         if (py_secdesc == NULL) {
    5290           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.secdesc");
    5291           0 :                 return false;
    5292             :         }
    5293           0 :         if (py_secdesc == Py_None) {
    5294           0 :                 r->in.secdesc = NULL;
    5295             :         } else {
    5296           0 :                 r->in.secdesc = NULL;
    5297           0 :                 PY_CHECK_TYPE(&winreg_SecBuf_Type, py_secdesc, return false;);
    5298           0 :                 if (talloc_reference(r, pytalloc_get_mem_ctx(py_secdesc)) == NULL) {
    5299           0 :                         PyErr_NoMemory();
    5300           0 :                         return false;
    5301             :                 }
    5302           0 :                 r->in.secdesc = (struct winreg_SecBuf *)pytalloc_get_ptr(py_secdesc);
    5303             :         }
    5304           0 :         if (py_action_taken == NULL) {
    5305           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.action_taken");
    5306           0 :                 return false;
    5307             :         }
    5308           0 :         if (py_action_taken == Py_None) {
    5309           0 :                 r->in.action_taken = NULL;
    5310             :         } else {
    5311           0 :                 r->in.action_taken = talloc_ptrtype(r, r->in.action_taken);
    5312           0 :                 if (r->in.action_taken == NULL) {
    5313           0 :                         PyErr_NoMemory();
    5314           0 :                         return false;
    5315             :                 }
    5316             :                 {
    5317           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.action_taken));
    5318           0 :                         if (PyLong_Check(py_action_taken)) {
    5319             :                                 unsigned long long test_var;
    5320           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_action_taken);
    5321           0 :                                 if (PyErr_Occurred() != NULL) {
    5322           0 :                                         return false;
    5323             :                                 }
    5324           0 :                                 if (test_var > uint_max) {
    5325           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    5326             :                                           PyLong_Type.tp_name, uint_max, test_var);
    5327           0 :                                         return false;
    5328             :                                 }
    5329           0 :                                 *r->in.action_taken = test_var;
    5330             :                         } else {
    5331           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    5332             :                                   PyLong_Type.tp_name);
    5333           0 :                                 return false;
    5334             :                         }
    5335             :                 }
    5336             :         }
    5337           0 :         return true;
    5338             : }
    5339             : 
    5340           0 : static PyObject *unpack_py_winreg_CreateKey_args_out(struct winreg_CreateKey *r)
    5341             : {
    5342             :         PyObject *result;
    5343             :         PyObject *py_new_handle;
    5344             :         PyObject *py_action_taken;
    5345           0 :         result = PyTuple_New(2);
    5346           0 :         py_new_handle = pytalloc_reference_ex(policy_handle_Type, r->out.new_handle, r->out.new_handle);
    5347           0 :         PyTuple_SetItem(result, 0, py_new_handle);
    5348           0 :         if (r->out.action_taken == NULL) {
    5349           0 :                 py_action_taken = Py_None;
    5350           0 :                 Py_INCREF(py_action_taken);
    5351             :         } else {
    5352           0 :                 py_action_taken = PyLong_FromUnsignedLongLong((uint32_t)*r->out.action_taken);
    5353             :         }
    5354           0 :         PyTuple_SetItem(result, 1, py_action_taken);
    5355           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    5356           0 :                 PyErr_SetWERROR(r->out.result);
    5357           0 :                 return NULL;
    5358             :         }
    5359             : 
    5360           0 :         return result;
    5361             : }
    5362             : 
    5363             : 
    5364           0 : static PyObject *py_winreg_DeleteKey_in_get_handle(PyObject *obj, void *closure)
    5365             : {
    5366           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(obj);
    5367             :         PyObject *py_handle;
    5368           0 :         if (object->in.handle == NULL) {
    5369           0 :                 Py_RETURN_NONE;
    5370             :         }
    5371           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    5372           0 :         return py_handle;
    5373             : }
    5374             : 
    5375           0 : static int py_winreg_DeleteKey_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    5376             : {
    5377           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(py_obj);
    5378           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    5379           0 :         if (value == NULL) {
    5380           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    5381           0 :                 return -1;
    5382             :         }
    5383           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    5384           0 :         if (object->in.handle == NULL) {
    5385           0 :                 PyErr_NoMemory();
    5386           0 :                 return -1;
    5387             :         }
    5388           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    5389           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    5390           0 :                 PyErr_NoMemory();
    5391           0 :                 return -1;
    5392             :         }
    5393           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    5394           0 :         return 0;
    5395             : }
    5396             : 
    5397           0 : static PyObject *py_winreg_DeleteKey_in_get_key(PyObject *obj, void *closure)
    5398             : {
    5399           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(obj);
    5400             :         PyObject *py_key;
    5401           0 :         py_key = pytalloc_reference_ex(&winreg_String_Type, pytalloc_get_mem_ctx(obj), &object->in.key);
    5402           0 :         return py_key;
    5403             : }
    5404             : 
    5405           0 : static int py_winreg_DeleteKey_in_set_key(PyObject *py_obj, PyObject *value, void *closure)
    5406             : {
    5407           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(py_obj);
    5408           0 :         if (value == NULL) {
    5409           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.key");
    5410           0 :                 return -1;
    5411             :         }
    5412           0 :         PY_CHECK_TYPE(&winreg_String_Type, value, return -1;);
    5413           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    5414           0 :                 PyErr_NoMemory();
    5415           0 :                 return -1;
    5416             :         }
    5417           0 :         object->in.key = *(struct winreg_String *)pytalloc_get_ptr(value);
    5418           0 :         return 0;
    5419             : }
    5420             : 
    5421           0 : static PyObject *py_winreg_DeleteKey_get_result(PyObject *obj, void *closure)
    5422             : {
    5423           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(obj);
    5424             :         PyObject *py_result;
    5425           0 :         py_result = PyErr_FromWERROR(object->out.result);
    5426           0 :         return py_result;
    5427             : }
    5428             : 
    5429           0 : static int py_winreg_DeleteKey_set_result(PyObject *py_obj, PyObject *value, void *closure)
    5430             : {
    5431           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(py_obj);
    5432           0 :         if (value == NULL) {
    5433           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    5434           0 :                 return -1;
    5435             :         }
    5436           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    5437           0 :         return 0;
    5438             : }
    5439             : 
    5440             : static PyGetSetDef py_winreg_DeleteKey_getsetters[] = {
    5441             :         {
    5442             :                 .name = discard_const_p(char, "in_handle"),
    5443             :                 .get = py_winreg_DeleteKey_in_get_handle,
    5444             :                 .set = py_winreg_DeleteKey_in_set_handle,
    5445             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    5446             :         },
    5447             :         {
    5448             :                 .name = discard_const_p(char, "in_key"),
    5449             :                 .get = py_winreg_DeleteKey_in_get_key,
    5450             :                 .set = py_winreg_DeleteKey_in_set_key,
    5451             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_String")
    5452             :         },
    5453             :         {
    5454             :                 .name = discard_const_p(char, "result"),
    5455             :                 .get = py_winreg_DeleteKey_get_result,
    5456             :                 .set = py_winreg_DeleteKey_set_result,
    5457             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    5458             :         },
    5459             :         { .name = NULL }
    5460             : };
    5461             : 
    5462           0 : static PyObject *py_winreg_DeleteKey_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    5463             : {
    5464           0 :         PyObject *self = pytalloc_new(struct winreg_DeleteKey, type);
    5465           0 :         struct winreg_DeleteKey *_self = (struct winreg_DeleteKey *)pytalloc_get_ptr(self);
    5466           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    5467           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    5468           0 :         return self;
    5469             : }
    5470             : 
    5471           0 : static PyObject *py_winreg_DeleteKey_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    5472             : {
    5473             : 
    5474             : 
    5475           0 :         return PyLong_FromLong(7);
    5476             : }
    5477             : 
    5478           0 : static PyObject *py_winreg_DeleteKey_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    5479             : {
    5480           0 :         const struct ndr_interface_call *call = NULL;
    5481           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(py_obj);
    5482           0 :         PyObject *ret = NULL;
    5483           0 :         struct ndr_push *push = NULL;
    5484             :         DATA_BLOB blob;
    5485             :         enum ndr_err_code err;
    5486             : 
    5487           0 :         if (ndr_table_winreg.num_calls < 8) {
    5488           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_DeleteKey_ndr_pack");
    5489           0 :                 return NULL;
    5490             :         }
    5491           0 :         call = &ndr_table_winreg.calls[7];
    5492             : 
    5493           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    5494           0 :         if (push == NULL) {
    5495           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5496           0 :                 return NULL;
    5497             :         }
    5498             : 
    5499           0 :         push->flags |= ndr_push_flags;
    5500             : 
    5501           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    5502           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5503           0 :                 TALLOC_FREE(push);
    5504           0 :                 PyErr_SetNdrError(err);
    5505           0 :                 return NULL;
    5506             :         }
    5507           0 :         blob = ndr_push_blob(push);
    5508           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    5509           0 :         TALLOC_FREE(push);
    5510           0 :         return ret;
    5511             : }
    5512             : 
    5513           0 : static PyObject *py_winreg_DeleteKey_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5514             : {
    5515           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5516           0 :         PyObject *bigendian_obj = NULL;
    5517           0 :         PyObject *ndr64_obj = NULL;
    5518           0 :         uint32_t ndr_push_flags = 0;
    5519             : 
    5520           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    5521             :                 discard_const_p(char *, kwnames),
    5522             :                 &bigendian_obj,
    5523             :                 &ndr64_obj)) {
    5524           0 :                 return NULL;
    5525             :         }
    5526             : 
    5527           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5528           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5529             :         }
    5530           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5531           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5532             :         }
    5533             : 
    5534           0 :         return py_winreg_DeleteKey_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    5535             : }
    5536             : 
    5537           0 : static PyObject *py_winreg_DeleteKey_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5538             : {
    5539           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5540           0 :         PyObject *bigendian_obj = NULL;
    5541           0 :         PyObject *ndr64_obj = NULL;
    5542           0 :         uint32_t ndr_push_flags = 0;
    5543             : 
    5544           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    5545             :                 discard_const_p(char *, kwnames),
    5546             :                 &bigendian_obj,
    5547             :                 &ndr64_obj)) {
    5548           0 :                 return NULL;
    5549             :         }
    5550             : 
    5551           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5552           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5553             :         }
    5554           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5555           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5556             :         }
    5557             : 
    5558           0 :         return py_winreg_DeleteKey_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    5559             : }
    5560             : 
    5561           0 : static PyObject *py_winreg_DeleteKey_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    5562             : {
    5563           0 :         const struct ndr_interface_call *call = NULL;
    5564           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(py_obj);
    5565           0 :         struct ndr_pull *pull = NULL;
    5566             :         enum ndr_err_code err;
    5567             : 
    5568           0 :         if (ndr_table_winreg.num_calls < 8) {
    5569           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_DeleteKey_ndr_unpack");
    5570           0 :                 return NULL;
    5571             :         }
    5572           0 :         call = &ndr_table_winreg.calls[7];
    5573             : 
    5574           0 :         pull = ndr_pull_init_blob(blob, object);
    5575           0 :         if (pull == NULL) {
    5576           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5577           0 :                 return NULL;
    5578             :         }
    5579             : 
    5580           0 :         pull->flags |= ndr_pull_flags;
    5581             : 
    5582           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    5583           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5584           0 :                 TALLOC_FREE(pull);
    5585           0 :                 PyErr_SetNdrError(err);
    5586           0 :                 return NULL;
    5587             :         }
    5588           0 :         if (!allow_remaining) {
    5589             :                 uint32_t highest_ofs;
    5590             : 
    5591           0 :                 if (pull->offset > pull->relative_highest_offset) {
    5592           0 :                         highest_ofs = pull->offset;
    5593             :                 } else {
    5594           0 :                         highest_ofs = pull->relative_highest_offset;
    5595             :                 }
    5596           0 :                 if (highest_ofs < pull->data_size) {
    5597           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    5598             :                                 "not all bytes consumed ofs[%u] size[%u]",
    5599             :                                 highest_ofs, pull->data_size);
    5600           0 :                         TALLOC_FREE(pull);
    5601           0 :                         PyErr_SetNdrError(err);
    5602           0 :                         return NULL;
    5603             :                 }
    5604             :         }
    5605             : 
    5606           0 :         TALLOC_FREE(pull);
    5607           0 :         Py_RETURN_NONE;
    5608             : }
    5609             : 
    5610           0 : static PyObject *py_winreg_DeleteKey_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5611             : {
    5612             :         DATA_BLOB blob;
    5613           0 :         Py_ssize_t blob_length = 0;
    5614           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5615           0 :         PyObject *bigendian_obj = NULL;
    5616           0 :         PyObject *ndr64_obj = NULL;
    5617           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5618           0 :         PyObject *allow_remaining_obj = NULL;
    5619           0 :         bool allow_remaining = false;
    5620             : 
    5621           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    5622             :                 discard_const_p(char *, kwnames),
    5623             :                 &blob.data, &blob_length,
    5624             :                 &bigendian_obj,
    5625             :                 &ndr64_obj,
    5626             :                 &allow_remaining_obj)) {
    5627           0 :                 return NULL;
    5628             :         }
    5629           0 :         blob.length = blob_length;
    5630             : 
    5631           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5632           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5633             :         }
    5634           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5635           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5636             :         }
    5637             : 
    5638           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5639           0 :                 allow_remaining = true;
    5640             :         }
    5641             : 
    5642           0 :         return py_winreg_DeleteKey_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    5643             : }
    5644             : 
    5645           0 : static PyObject *py_winreg_DeleteKey_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5646             : {
    5647             :         DATA_BLOB blob;
    5648           0 :         Py_ssize_t blob_length = 0;
    5649           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    5650           0 :         PyObject *bigendian_obj = NULL;
    5651           0 :         PyObject *ndr64_obj = NULL;
    5652           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    5653           0 :         PyObject *allow_remaining_obj = NULL;
    5654           0 :         bool allow_remaining = false;
    5655             : 
    5656           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    5657             :                 discard_const_p(char *, kwnames),
    5658             :                 &blob.data, &blob_length,
    5659             :                 &bigendian_obj,
    5660             :                 &ndr64_obj,
    5661             :                 &allow_remaining_obj)) {
    5662           0 :                 return NULL;
    5663             :         }
    5664           0 :         blob.length = blob_length;
    5665             : 
    5666           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5667           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    5668             :         }
    5669           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5670           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    5671             :         }
    5672             : 
    5673           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    5674           0 :                 allow_remaining = true;
    5675             :         }
    5676             : 
    5677           0 :         return py_winreg_DeleteKey_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    5678             : }
    5679             : 
    5680           0 : static PyObject *py_winreg_DeleteKey_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    5681             : {
    5682           0 :         const struct ndr_interface_call *call = NULL;
    5683           0 :         struct winreg_DeleteKey *object = (struct winreg_DeleteKey *)pytalloc_get_ptr(py_obj);
    5684             :         PyObject *ret;
    5685             :         char *retstr;
    5686             : 
    5687           0 :         if (ndr_table_winreg.num_calls < 8) {
    5688           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_DeleteKey_ndr_print");
    5689           0 :                 return NULL;
    5690             :         }
    5691           0 :         call = &ndr_table_winreg.calls[7];
    5692             : 
    5693           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    5694           0 :         ret = PyUnicode_FromString(retstr);
    5695           0 :         TALLOC_FREE(retstr);
    5696             : 
    5697           0 :         return ret;
    5698             : }
    5699             : 
    5700           0 : static PyObject *py_winreg_DeleteKey_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5701             : {
    5702           0 :         return py_winreg_DeleteKey_ndr_print(py_obj, "winreg_DeleteKey_in", NDR_IN);
    5703             : }
    5704             : 
    5705           0 : static PyObject *py_winreg_DeleteKey_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    5706             : {
    5707           0 :         return py_winreg_DeleteKey_ndr_print(py_obj, "winreg_DeleteKey_out", NDR_OUT);
    5708             : }
    5709             : 
    5710             : static PyMethodDef py_winreg_DeleteKey_methods[] = {
    5711             :         { "opnum", (PyCFunction)py_winreg_DeleteKey_ndr_opnum, METH_NOARGS|METH_CLASS,
    5712             :                 "winreg.DeleteKey.opnum() -> 7 (0x07) " },
    5713             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteKey_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    5714             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    5715             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteKey_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    5716             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    5717             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteKey_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    5718             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    5719             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteKey_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    5720             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    5721             :         { "__ndr_print_in__", (PyCFunction)py_winreg_DeleteKey_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    5722             :         { "__ndr_print_out__", (PyCFunction)py_winreg_DeleteKey_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    5723             :         { NULL, NULL, 0, NULL }
    5724             : };
    5725             : 
    5726             : 
    5727             : static PyTypeObject winreg_DeleteKey_Type = {
    5728             :         PyVarObject_HEAD_INIT(NULL, 0)
    5729             :         .tp_name = "winreg.DeleteKey",
    5730             :         .tp_getset = py_winreg_DeleteKey_getsetters,
    5731             :         .tp_methods = py_winreg_DeleteKey_methods,
    5732             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    5733             :         .tp_new = py_winreg_DeleteKey_new,
    5734             : };
    5735             : 
    5736           0 : static bool pack_py_winreg_DeleteKey_args_in(PyObject *args, PyObject *kwargs, struct winreg_DeleteKey *r)
    5737             : {
    5738             :         PyObject *py_handle;
    5739             :         PyObject *py_key;
    5740           0 :         const char *kwnames[] = {
    5741             :                 "handle", "key", NULL
    5742             :         };
    5743             : 
    5744           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_DeleteKey", discard_const_p(char *, kwnames), &py_handle, &py_key)) {
    5745           0 :                 return false;
    5746             :         }
    5747             : 
    5748           0 :         if (py_handle == NULL) {
    5749           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    5750           0 :                 return false;
    5751             :         }
    5752           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    5753           0 :         if (r->in.handle == NULL) {
    5754           0 :                 PyErr_NoMemory();
    5755           0 :                 return false;
    5756             :         }
    5757           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    5758           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    5759           0 :                 PyErr_NoMemory();
    5760           0 :                 return false;
    5761             :         }
    5762           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    5763           0 :         if (py_key == NULL) {
    5764           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.key");
    5765           0 :                 return false;
    5766             :         }
    5767           0 :         PY_CHECK_TYPE(&winreg_String_Type, py_key, return false;);
    5768           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_key)) == NULL) {
    5769           0 :                 PyErr_NoMemory();
    5770           0 :                 return false;
    5771             :         }
    5772           0 :         r->in.key = *(struct winreg_String *)pytalloc_get_ptr(py_key);
    5773           0 :         return true;
    5774             : }
    5775             : 
    5776           0 : static PyObject *unpack_py_winreg_DeleteKey_args_out(struct winreg_DeleteKey *r)
    5777             : {
    5778             :         PyObject *result;
    5779           0 :         result = Py_None;
    5780           0 :         Py_INCREF(result);
    5781           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    5782           0 :                 PyErr_SetWERROR(r->out.result);
    5783           0 :                 return NULL;
    5784             :         }
    5785             : 
    5786           0 :         return result;
    5787             : }
    5788             : 
    5789             : 
    5790           0 : static PyObject *py_winreg_DeleteValue_in_get_handle(PyObject *obj, void *closure)
    5791             : {
    5792           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(obj);
    5793             :         PyObject *py_handle;
    5794           0 :         if (object->in.handle == NULL) {
    5795           0 :                 Py_RETURN_NONE;
    5796             :         }
    5797           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    5798           0 :         return py_handle;
    5799             : }
    5800             : 
    5801           0 : static int py_winreg_DeleteValue_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    5802             : {
    5803           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(py_obj);
    5804           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    5805           0 :         if (value == NULL) {
    5806           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    5807           0 :                 return -1;
    5808             :         }
    5809           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    5810           0 :         if (object->in.handle == NULL) {
    5811           0 :                 PyErr_NoMemory();
    5812           0 :                 return -1;
    5813             :         }
    5814           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    5815           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    5816           0 :                 PyErr_NoMemory();
    5817           0 :                 return -1;
    5818             :         }
    5819           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    5820           0 :         return 0;
    5821             : }
    5822             : 
    5823           0 : static PyObject *py_winreg_DeleteValue_in_get_value(PyObject *obj, void *closure)
    5824             : {
    5825           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(obj);
    5826             :         PyObject *py_value;
    5827           0 :         py_value = pytalloc_reference_ex(&winreg_String_Type, pytalloc_get_mem_ctx(obj), &object->in.value);
    5828           0 :         return py_value;
    5829             : }
    5830             : 
    5831           0 : static int py_winreg_DeleteValue_in_set_value(PyObject *py_obj, PyObject *value, void *closure)
    5832             : {
    5833           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(py_obj);
    5834           0 :         if (value == NULL) {
    5835           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.value");
    5836           0 :                 return -1;
    5837             :         }
    5838           0 :         PY_CHECK_TYPE(&winreg_String_Type, value, return -1;);
    5839           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    5840           0 :                 PyErr_NoMemory();
    5841           0 :                 return -1;
    5842             :         }
    5843           0 :         object->in.value = *(struct winreg_String *)pytalloc_get_ptr(value);
    5844           0 :         return 0;
    5845             : }
    5846             : 
    5847           0 : static PyObject *py_winreg_DeleteValue_get_result(PyObject *obj, void *closure)
    5848             : {
    5849           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(obj);
    5850             :         PyObject *py_result;
    5851           0 :         py_result = PyErr_FromWERROR(object->out.result);
    5852           0 :         return py_result;
    5853             : }
    5854             : 
    5855           0 : static int py_winreg_DeleteValue_set_result(PyObject *py_obj, PyObject *value, void *closure)
    5856             : {
    5857           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(py_obj);
    5858           0 :         if (value == NULL) {
    5859           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    5860           0 :                 return -1;
    5861             :         }
    5862           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    5863           0 :         return 0;
    5864             : }
    5865             : 
    5866             : static PyGetSetDef py_winreg_DeleteValue_getsetters[] = {
    5867             :         {
    5868             :                 .name = discard_const_p(char, "in_handle"),
    5869             :                 .get = py_winreg_DeleteValue_in_get_handle,
    5870             :                 .set = py_winreg_DeleteValue_in_set_handle,
    5871             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    5872             :         },
    5873             :         {
    5874             :                 .name = discard_const_p(char, "in_value"),
    5875             :                 .get = py_winreg_DeleteValue_in_get_value,
    5876             :                 .set = py_winreg_DeleteValue_in_set_value,
    5877             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_String")
    5878             :         },
    5879             :         {
    5880             :                 .name = discard_const_p(char, "result"),
    5881             :                 .get = py_winreg_DeleteValue_get_result,
    5882             :                 .set = py_winreg_DeleteValue_set_result,
    5883             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    5884             :         },
    5885             :         { .name = NULL }
    5886             : };
    5887             : 
    5888           0 : static PyObject *py_winreg_DeleteValue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    5889             : {
    5890           0 :         PyObject *self = pytalloc_new(struct winreg_DeleteValue, type);
    5891           0 :         struct winreg_DeleteValue *_self = (struct winreg_DeleteValue *)pytalloc_get_ptr(self);
    5892           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    5893           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    5894           0 :         return self;
    5895             : }
    5896             : 
    5897           0 : static PyObject *py_winreg_DeleteValue_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    5898             : {
    5899             : 
    5900             : 
    5901           0 :         return PyLong_FromLong(8);
    5902             : }
    5903             : 
    5904           0 : static PyObject *py_winreg_DeleteValue_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    5905             : {
    5906           0 :         const struct ndr_interface_call *call = NULL;
    5907           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(py_obj);
    5908           0 :         PyObject *ret = NULL;
    5909           0 :         struct ndr_push *push = NULL;
    5910             :         DATA_BLOB blob;
    5911             :         enum ndr_err_code err;
    5912             : 
    5913           0 :         if (ndr_table_winreg.num_calls < 9) {
    5914           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_DeleteValue_ndr_pack");
    5915           0 :                 return NULL;
    5916             :         }
    5917           0 :         call = &ndr_table_winreg.calls[8];
    5918             : 
    5919           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    5920           0 :         if (push == NULL) {
    5921           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    5922           0 :                 return NULL;
    5923             :         }
    5924             : 
    5925           0 :         push->flags |= ndr_push_flags;
    5926             : 
    5927           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    5928           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    5929           0 :                 TALLOC_FREE(push);
    5930           0 :                 PyErr_SetNdrError(err);
    5931           0 :                 return NULL;
    5932             :         }
    5933           0 :         blob = ndr_push_blob(push);
    5934           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    5935           0 :         TALLOC_FREE(push);
    5936           0 :         return ret;
    5937             : }
    5938             : 
    5939           0 : static PyObject *py_winreg_DeleteValue_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5940             : {
    5941           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5942           0 :         PyObject *bigendian_obj = NULL;
    5943           0 :         PyObject *ndr64_obj = NULL;
    5944           0 :         uint32_t ndr_push_flags = 0;
    5945             : 
    5946           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    5947             :                 discard_const_p(char *, kwnames),
    5948             :                 &bigendian_obj,
    5949             :                 &ndr64_obj)) {
    5950           0 :                 return NULL;
    5951             :         }
    5952             : 
    5953           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5954           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5955             :         }
    5956           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5957           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5958             :         }
    5959             : 
    5960           0 :         return py_winreg_DeleteValue_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    5961             : }
    5962             : 
    5963           0 : static PyObject *py_winreg_DeleteValue_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    5964             : {
    5965           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    5966           0 :         PyObject *bigendian_obj = NULL;
    5967           0 :         PyObject *ndr64_obj = NULL;
    5968           0 :         uint32_t ndr_push_flags = 0;
    5969             : 
    5970           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    5971             :                 discard_const_p(char *, kwnames),
    5972             :                 &bigendian_obj,
    5973             :                 &ndr64_obj)) {
    5974           0 :                 return NULL;
    5975             :         }
    5976             : 
    5977           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    5978           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    5979             :         }
    5980           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    5981           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    5982             :         }
    5983             : 
    5984           0 :         return py_winreg_DeleteValue_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    5985             : }
    5986             : 
    5987           0 : static PyObject *py_winreg_DeleteValue_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    5988             : {
    5989           0 :         const struct ndr_interface_call *call = NULL;
    5990           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(py_obj);
    5991           0 :         struct ndr_pull *pull = NULL;
    5992             :         enum ndr_err_code err;
    5993             : 
    5994           0 :         if (ndr_table_winreg.num_calls < 9) {
    5995           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_DeleteValue_ndr_unpack");
    5996           0 :                 return NULL;
    5997             :         }
    5998           0 :         call = &ndr_table_winreg.calls[8];
    5999             : 
    6000           0 :         pull = ndr_pull_init_blob(blob, object);
    6001           0 :         if (pull == NULL) {
    6002           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    6003           0 :                 return NULL;
    6004             :         }
    6005             : 
    6006           0 :         pull->flags |= ndr_pull_flags;
    6007             : 
    6008           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    6009           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    6010           0 :                 TALLOC_FREE(pull);
    6011           0 :                 PyErr_SetNdrError(err);
    6012           0 :                 return NULL;
    6013             :         }
    6014           0 :         if (!allow_remaining) {
    6015             :                 uint32_t highest_ofs;
    6016             : 
    6017           0 :                 if (pull->offset > pull->relative_highest_offset) {
    6018           0 :                         highest_ofs = pull->offset;
    6019             :                 } else {
    6020           0 :                         highest_ofs = pull->relative_highest_offset;
    6021             :                 }
    6022           0 :                 if (highest_ofs < pull->data_size) {
    6023           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    6024             :                                 "not all bytes consumed ofs[%u] size[%u]",
    6025             :                                 highest_ofs, pull->data_size);
    6026           0 :                         TALLOC_FREE(pull);
    6027           0 :                         PyErr_SetNdrError(err);
    6028           0 :                         return NULL;
    6029             :                 }
    6030             :         }
    6031             : 
    6032           0 :         TALLOC_FREE(pull);
    6033           0 :         Py_RETURN_NONE;
    6034             : }
    6035             : 
    6036           0 : static PyObject *py_winreg_DeleteValue_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    6037             : {
    6038             :         DATA_BLOB blob;
    6039           0 :         Py_ssize_t blob_length = 0;
    6040           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    6041           0 :         PyObject *bigendian_obj = NULL;
    6042           0 :         PyObject *ndr64_obj = NULL;
    6043           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    6044           0 :         PyObject *allow_remaining_obj = NULL;
    6045           0 :         bool allow_remaining = false;
    6046             : 
    6047           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    6048             :                 discard_const_p(char *, kwnames),
    6049             :                 &blob.data, &blob_length,
    6050             :                 &bigendian_obj,
    6051             :                 &ndr64_obj,
    6052             :                 &allow_remaining_obj)) {
    6053           0 :                 return NULL;
    6054             :         }
    6055           0 :         blob.length = blob_length;
    6056             : 
    6057           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    6058           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    6059             :         }
    6060           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    6061           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    6062             :         }
    6063             : 
    6064           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    6065           0 :                 allow_remaining = true;
    6066             :         }
    6067             : 
    6068           0 :         return py_winreg_DeleteValue_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    6069             : }
    6070             : 
    6071           0 : static PyObject *py_winreg_DeleteValue_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    6072             : {
    6073             :         DATA_BLOB blob;
    6074           0 :         Py_ssize_t blob_length = 0;
    6075           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    6076           0 :         PyObject *bigendian_obj = NULL;
    6077           0 :         PyObject *ndr64_obj = NULL;
    6078           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    6079           0 :         PyObject *allow_remaining_obj = NULL;
    6080           0 :         bool allow_remaining = false;
    6081             : 
    6082           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    6083             :                 discard_const_p(char *, kwnames),
    6084             :                 &blob.data, &blob_length,
    6085             :                 &bigendian_obj,
    6086             :                 &ndr64_obj,
    6087             :                 &allow_remaining_obj)) {
    6088           0 :                 return NULL;
    6089             :         }
    6090           0 :         blob.length = blob_length;
    6091             : 
    6092           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    6093           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    6094             :         }
    6095           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    6096           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    6097             :         }
    6098             : 
    6099           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    6100           0 :                 allow_remaining = true;
    6101             :         }
    6102             : 
    6103           0 :         return py_winreg_DeleteValue_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    6104             : }
    6105             : 
    6106           0 : static PyObject *py_winreg_DeleteValue_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    6107             : {
    6108           0 :         const struct ndr_interface_call *call = NULL;
    6109           0 :         struct winreg_DeleteValue *object = (struct winreg_DeleteValue *)pytalloc_get_ptr(py_obj);
    6110             :         PyObject *ret;
    6111             :         char *retstr;
    6112             : 
    6113           0 :         if (ndr_table_winreg.num_calls < 9) {
    6114           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_DeleteValue_ndr_print");
    6115           0 :                 return NULL;
    6116             :         }
    6117           0 :         call = &ndr_table_winreg.calls[8];
    6118             : 
    6119           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    6120           0 :         ret = PyUnicode_FromString(retstr);
    6121           0 :         TALLOC_FREE(retstr);
    6122             : 
    6123           0 :         return ret;
    6124             : }
    6125             : 
    6126           0 : static PyObject *py_winreg_DeleteValue_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    6127             : {
    6128           0 :         return py_winreg_DeleteValue_ndr_print(py_obj, "winreg_DeleteValue_in", NDR_IN);
    6129             : }
    6130             : 
    6131           0 : static PyObject *py_winreg_DeleteValue_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    6132             : {
    6133           0 :         return py_winreg_DeleteValue_ndr_print(py_obj, "winreg_DeleteValue_out", NDR_OUT);
    6134             : }
    6135             : 
    6136             : static PyMethodDef py_winreg_DeleteValue_methods[] = {
    6137             :         { "opnum", (PyCFunction)py_winreg_DeleteValue_ndr_opnum, METH_NOARGS|METH_CLASS,
    6138             :                 "winreg.DeleteValue.opnum() -> 8 (0x08) " },
    6139             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteValue_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    6140             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    6141             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteValue_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    6142             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    6143             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteValue_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    6144             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    6145             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_DeleteValue_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    6146             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    6147             :         { "__ndr_print_in__", (PyCFunction)py_winreg_DeleteValue_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    6148             :         { "__ndr_print_out__", (PyCFunction)py_winreg_DeleteValue_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    6149             :         { NULL, NULL, 0, NULL }
    6150             : };
    6151             : 
    6152             : 
    6153             : static PyTypeObject winreg_DeleteValue_Type = {
    6154             :         PyVarObject_HEAD_INIT(NULL, 0)
    6155             :         .tp_name = "winreg.DeleteValue",
    6156             :         .tp_getset = py_winreg_DeleteValue_getsetters,
    6157             :         .tp_methods = py_winreg_DeleteValue_methods,
    6158             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    6159             :         .tp_new = py_winreg_DeleteValue_new,
    6160             : };
    6161             : 
    6162           0 : static bool pack_py_winreg_DeleteValue_args_in(PyObject *args, PyObject *kwargs, struct winreg_DeleteValue *r)
    6163             : {
    6164             :         PyObject *py_handle;
    6165             :         PyObject *py_value;
    6166           0 :         const char *kwnames[] = {
    6167             :                 "handle", "value", NULL
    6168             :         };
    6169             : 
    6170           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OO:winreg_DeleteValue", discard_const_p(char *, kwnames), &py_handle, &py_value)) {
    6171           0 :                 return false;
    6172             :         }
    6173             : 
    6174           0 :         if (py_handle == NULL) {
    6175           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    6176           0 :                 return false;
    6177             :         }
    6178           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    6179           0 :         if (r->in.handle == NULL) {
    6180           0 :                 PyErr_NoMemory();
    6181           0 :                 return false;
    6182             :         }
    6183           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    6184           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    6185           0 :                 PyErr_NoMemory();
    6186           0 :                 return false;
    6187             :         }
    6188           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    6189           0 :         if (py_value == NULL) {
    6190           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.value");
    6191           0 :                 return false;
    6192             :         }
    6193           0 :         PY_CHECK_TYPE(&winreg_String_Type, py_value, return false;);
    6194           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_value)) == NULL) {
    6195           0 :                 PyErr_NoMemory();
    6196           0 :                 return false;
    6197             :         }
    6198           0 :         r->in.value = *(struct winreg_String *)pytalloc_get_ptr(py_value);
    6199           0 :         return true;
    6200             : }
    6201             : 
    6202           0 : static PyObject *unpack_py_winreg_DeleteValue_args_out(struct winreg_DeleteValue *r)
    6203             : {
    6204             :         PyObject *result;
    6205           0 :         result = Py_None;
    6206           0 :         Py_INCREF(result);
    6207           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    6208           0 :                 PyErr_SetWERROR(r->out.result);
    6209           0 :                 return NULL;
    6210             :         }
    6211             : 
    6212           0 :         return result;
    6213             : }
    6214             : 
    6215             : 
    6216           0 : static PyObject *py_winreg_EnumKey_in_get_handle(PyObject *obj, void *closure)
    6217             : {
    6218           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6219             :         PyObject *py_handle;
    6220           0 :         if (object->in.handle == NULL) {
    6221           0 :                 Py_RETURN_NONE;
    6222             :         }
    6223           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    6224           0 :         return py_handle;
    6225             : }
    6226             : 
    6227           0 : static int py_winreg_EnumKey_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    6228             : {
    6229           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6230           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    6231           0 :         if (value == NULL) {
    6232           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    6233           0 :                 return -1;
    6234             :         }
    6235           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    6236           0 :         if (object->in.handle == NULL) {
    6237           0 :                 PyErr_NoMemory();
    6238           0 :                 return -1;
    6239             :         }
    6240           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    6241           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    6242           0 :                 PyErr_NoMemory();
    6243           0 :                 return -1;
    6244             :         }
    6245           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    6246           0 :         return 0;
    6247             : }
    6248             : 
    6249           0 : static PyObject *py_winreg_EnumKey_in_get_enum_index(PyObject *obj, void *closure)
    6250             : {
    6251           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6252             :         PyObject *py_enum_index;
    6253           0 :         py_enum_index = PyLong_FromUnsignedLongLong((uint32_t)object->in.enum_index);
    6254           0 :         return py_enum_index;
    6255             : }
    6256             : 
    6257           0 : static int py_winreg_EnumKey_in_set_enum_index(PyObject *py_obj, PyObject *value, void *closure)
    6258             : {
    6259           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6260           0 :         if (value == NULL) {
    6261           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.enum_index");
    6262           0 :                 return -1;
    6263             :         }
    6264             :         {
    6265           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.enum_index));
    6266           0 :                 if (PyLong_Check(value)) {
    6267             :                         unsigned long long test_var;
    6268           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    6269           0 :                         if (PyErr_Occurred() != NULL) {
    6270           0 :                                 return -1;
    6271             :                         }
    6272           0 :                         if (test_var > uint_max) {
    6273           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    6274             :                                   PyLong_Type.tp_name, uint_max, test_var);
    6275           0 :                                 return -1;
    6276             :                         }
    6277           0 :                         object->in.enum_index = test_var;
    6278             :                 } else {
    6279           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    6280             :                           PyLong_Type.tp_name);
    6281           0 :                         return -1;
    6282             :                 }
    6283             :         }
    6284           0 :         return 0;
    6285             : }
    6286             : 
    6287           0 : static PyObject *py_winreg_EnumKey_in_get_name(PyObject *obj, void *closure)
    6288             : {
    6289           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6290             :         PyObject *py_name;
    6291           0 :         if (object->in.name == NULL) {
    6292           0 :                 Py_RETURN_NONE;
    6293             :         }
    6294           0 :         py_name = pytalloc_reference_ex(&winreg_StringBuf_Type, object->in.name, object->in.name);
    6295           0 :         return py_name;
    6296             : }
    6297             : 
    6298           0 : static int py_winreg_EnumKey_in_set_name(PyObject *py_obj, PyObject *value, void *closure)
    6299             : {
    6300           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6301           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.name));
    6302           0 :         if (value == NULL) {
    6303           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.name");
    6304           0 :                 return -1;
    6305             :         }
    6306           0 :         object->in.name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.name);
    6307           0 :         if (object->in.name == NULL) {
    6308           0 :                 PyErr_NoMemory();
    6309           0 :                 return -1;
    6310             :         }
    6311           0 :         PY_CHECK_TYPE(&winreg_StringBuf_Type, value, return -1;);
    6312           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    6313           0 :                 PyErr_NoMemory();
    6314           0 :                 return -1;
    6315             :         }
    6316           0 :         object->in.name = (struct winreg_StringBuf *)pytalloc_get_ptr(value);
    6317           0 :         return 0;
    6318             : }
    6319             : 
    6320           0 : static PyObject *py_winreg_EnumKey_out_get_name(PyObject *obj, void *closure)
    6321             : {
    6322           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6323             :         PyObject *py_name;
    6324           0 :         if (object->out.name == NULL) {
    6325           0 :                 Py_RETURN_NONE;
    6326             :         }
    6327           0 :         py_name = pytalloc_reference_ex(&winreg_StringBuf_Type, object->out.name, object->out.name);
    6328           0 :         return py_name;
    6329             : }
    6330             : 
    6331           0 : static int py_winreg_EnumKey_out_set_name(PyObject *py_obj, PyObject *value, void *closure)
    6332             : {
    6333           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6334           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.name));
    6335           0 :         if (value == NULL) {
    6336           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.name");
    6337           0 :                 return -1;
    6338             :         }
    6339           0 :         object->out.name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.name);
    6340           0 :         if (object->out.name == NULL) {
    6341           0 :                 PyErr_NoMemory();
    6342           0 :                 return -1;
    6343             :         }
    6344           0 :         PY_CHECK_TYPE(&winreg_StringBuf_Type, value, return -1;);
    6345           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    6346           0 :                 PyErr_NoMemory();
    6347           0 :                 return -1;
    6348             :         }
    6349           0 :         object->out.name = (struct winreg_StringBuf *)pytalloc_get_ptr(value);
    6350           0 :         return 0;
    6351             : }
    6352             : 
    6353           0 : static PyObject *py_winreg_EnumKey_in_get_keyclass(PyObject *obj, void *closure)
    6354             : {
    6355           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6356             :         PyObject *py_keyclass;
    6357           0 :         if (object->in.keyclass == NULL) {
    6358           0 :                 Py_RETURN_NONE;
    6359             :         }
    6360           0 :         if (object->in.keyclass == NULL) {
    6361           0 :                 py_keyclass = Py_None;
    6362           0 :                 Py_INCREF(py_keyclass);
    6363             :         } else {
    6364           0 :                 py_keyclass = pytalloc_reference_ex(&winreg_StringBuf_Type, object->in.keyclass, object->in.keyclass);
    6365             :         }
    6366           0 :         return py_keyclass;
    6367             : }
    6368             : 
    6369           0 : static int py_winreg_EnumKey_in_set_keyclass(PyObject *py_obj, PyObject *value, void *closure)
    6370             : {
    6371           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6372           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.keyclass));
    6373           0 :         if (value == NULL) {
    6374           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.keyclass");
    6375           0 :                 return -1;
    6376             :         }
    6377           0 :         if (value == Py_None) {
    6378           0 :                 object->in.keyclass = NULL;
    6379             :         } else {
    6380           0 :                 object->in.keyclass = NULL;
    6381           0 :                 PY_CHECK_TYPE(&winreg_StringBuf_Type, value, return -1;);
    6382           0 :                 if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    6383           0 :                         PyErr_NoMemory();
    6384           0 :                         return -1;
    6385             :                 }
    6386           0 :                 object->in.keyclass = (struct winreg_StringBuf *)pytalloc_get_ptr(value);
    6387             :         }
    6388           0 :         return 0;
    6389             : }
    6390             : 
    6391           0 : static PyObject *py_winreg_EnumKey_out_get_keyclass(PyObject *obj, void *closure)
    6392             : {
    6393           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6394             :         PyObject *py_keyclass;
    6395           0 :         if (object->out.keyclass == NULL) {
    6396           0 :                 Py_RETURN_NONE;
    6397             :         }
    6398           0 :         if (object->out.keyclass == NULL) {
    6399           0 :                 py_keyclass = Py_None;
    6400           0 :                 Py_INCREF(py_keyclass);
    6401             :         } else {
    6402           0 :                 py_keyclass = pytalloc_reference_ex(&winreg_StringBuf_Type, object->out.keyclass, object->out.keyclass);
    6403             :         }
    6404           0 :         return py_keyclass;
    6405             : }
    6406             : 
    6407           0 : static int py_winreg_EnumKey_out_set_keyclass(PyObject *py_obj, PyObject *value, void *closure)
    6408             : {
    6409           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6410           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.keyclass));
    6411           0 :         if (value == NULL) {
    6412           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.keyclass");
    6413           0 :                 return -1;
    6414             :         }
    6415           0 :         if (value == Py_None) {
    6416           0 :                 object->out.keyclass = NULL;
    6417             :         } else {
    6418           0 :                 object->out.keyclass = NULL;
    6419           0 :                 PY_CHECK_TYPE(&winreg_StringBuf_Type, value, return -1;);
    6420           0 :                 if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    6421           0 :                         PyErr_NoMemory();
    6422           0 :                         return -1;
    6423             :                 }
    6424           0 :                 object->out.keyclass = (struct winreg_StringBuf *)pytalloc_get_ptr(value);
    6425             :         }
    6426           0 :         return 0;
    6427             : }
    6428             : 
    6429           0 : static PyObject *py_winreg_EnumKey_in_get_last_changed_time(PyObject *obj, void *closure)
    6430             : {
    6431           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6432             :         PyObject *py_last_changed_time;
    6433           0 :         if (object->in.last_changed_time == NULL) {
    6434           0 :                 Py_RETURN_NONE;
    6435             :         }
    6436           0 :         if (object->in.last_changed_time == NULL) {
    6437           0 :                 py_last_changed_time = Py_None;
    6438           0 :                 Py_INCREF(py_last_changed_time);
    6439             :         } else {
    6440           0 :                 py_last_changed_time = PyLong_FromUnsignedLongLong(*object->in.last_changed_time);
    6441             :         }
    6442           0 :         return py_last_changed_time;
    6443             : }
    6444             : 
    6445           0 : static int py_winreg_EnumKey_in_set_last_changed_time(PyObject *py_obj, PyObject *value, void *closure)
    6446             : {
    6447           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6448           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.last_changed_time));
    6449           0 :         if (value == NULL) {
    6450           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.last_changed_time");
    6451           0 :                 return -1;
    6452             :         }
    6453           0 :         if (value == Py_None) {
    6454           0 :                 object->in.last_changed_time = NULL;
    6455             :         } else {
    6456           0 :                 object->in.last_changed_time = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.last_changed_time);
    6457           0 :                 if (object->in.last_changed_time == NULL) {
    6458           0 :                         PyErr_NoMemory();
    6459           0 :                         return -1;
    6460             :                 }
    6461             :                 {
    6462           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.last_changed_time));
    6463           0 :                         if (PyLong_Check(value)) {
    6464             :                                 unsigned long long test_var;
    6465           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    6466           0 :                                 if (PyErr_Occurred() != NULL) {
    6467           0 :                                         return -1;
    6468             :                                 }
    6469           0 :                                 if (test_var > uint_max) {
    6470           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    6471             :                                           PyLong_Type.tp_name, uint_max, test_var);
    6472           0 :                                         return -1;
    6473             :                                 }
    6474           0 :                                 *object->in.last_changed_time = test_var;
    6475             :                         } else {
    6476           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    6477             :                                   PyLong_Type.tp_name);
    6478           0 :                                 return -1;
    6479             :                         }
    6480             :                 }
    6481             :         }
    6482           0 :         return 0;
    6483             : }
    6484             : 
    6485           0 : static PyObject *py_winreg_EnumKey_out_get_last_changed_time(PyObject *obj, void *closure)
    6486             : {
    6487           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6488             :         PyObject *py_last_changed_time;
    6489           0 :         if (object->out.last_changed_time == NULL) {
    6490           0 :                 Py_RETURN_NONE;
    6491             :         }
    6492           0 :         if (object->out.last_changed_time == NULL) {
    6493           0 :                 py_last_changed_time = Py_None;
    6494           0 :                 Py_INCREF(py_last_changed_time);
    6495             :         } else {
    6496           0 :                 py_last_changed_time = PyLong_FromUnsignedLongLong(*object->out.last_changed_time);
    6497             :         }
    6498           0 :         return py_last_changed_time;
    6499             : }
    6500             : 
    6501           0 : static int py_winreg_EnumKey_out_set_last_changed_time(PyObject *py_obj, PyObject *value, void *closure)
    6502             : {
    6503           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6504           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.last_changed_time));
    6505           0 :         if (value == NULL) {
    6506           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.last_changed_time");
    6507           0 :                 return -1;
    6508             :         }
    6509           0 :         if (value == Py_None) {
    6510           0 :                 object->out.last_changed_time = NULL;
    6511             :         } else {
    6512           0 :                 object->out.last_changed_time = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.last_changed_time);
    6513           0 :                 if (object->out.last_changed_time == NULL) {
    6514           0 :                         PyErr_NoMemory();
    6515           0 :                         return -1;
    6516             :                 }
    6517             :                 {
    6518           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.last_changed_time));
    6519           0 :                         if (PyLong_Check(value)) {
    6520             :                                 unsigned long long test_var;
    6521           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    6522           0 :                                 if (PyErr_Occurred() != NULL) {
    6523           0 :                                         return -1;
    6524             :                                 }
    6525           0 :                                 if (test_var > uint_max) {
    6526           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    6527             :                                           PyLong_Type.tp_name, uint_max, test_var);
    6528           0 :                                         return -1;
    6529             :                                 }
    6530           0 :                                 *object->out.last_changed_time = test_var;
    6531             :                         } else {
    6532           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    6533             :                                   PyLong_Type.tp_name);
    6534           0 :                                 return -1;
    6535             :                         }
    6536             :                 }
    6537             :         }
    6538           0 :         return 0;
    6539             : }
    6540             : 
    6541           0 : static PyObject *py_winreg_EnumKey_get_result(PyObject *obj, void *closure)
    6542             : {
    6543           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(obj);
    6544             :         PyObject *py_result;
    6545           0 :         py_result = PyErr_FromWERROR(object->out.result);
    6546           0 :         return py_result;
    6547             : }
    6548             : 
    6549           0 : static int py_winreg_EnumKey_set_result(PyObject *py_obj, PyObject *value, void *closure)
    6550             : {
    6551           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6552           0 :         if (value == NULL) {
    6553           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    6554           0 :                 return -1;
    6555             :         }
    6556           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    6557           0 :         return 0;
    6558             : }
    6559             : 
    6560             : static PyGetSetDef py_winreg_EnumKey_getsetters[] = {
    6561             :         {
    6562             :                 .name = discard_const_p(char, "in_handle"),
    6563             :                 .get = py_winreg_EnumKey_in_get_handle,
    6564             :                 .set = py_winreg_EnumKey_in_set_handle,
    6565             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    6566             :         },
    6567             :         {
    6568             :                 .name = discard_const_p(char, "in_enum_index"),
    6569             :                 .get = py_winreg_EnumKey_in_get_enum_index,
    6570             :                 .set = py_winreg_EnumKey_in_set_enum_index,
    6571             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    6572             :         },
    6573             :         {
    6574             :                 .name = discard_const_p(char, "in_name"),
    6575             :                 .get = py_winreg_EnumKey_in_get_name,
    6576             :                 .set = py_winreg_EnumKey_in_set_name,
    6577             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_StringBuf")
    6578             :         },
    6579             :         {
    6580             :                 .name = discard_const_p(char, "out_name"),
    6581             :                 .get = py_winreg_EnumKey_out_get_name,
    6582             :                 .set = py_winreg_EnumKey_out_set_name,
    6583             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_StringBuf")
    6584             :         },
    6585             :         {
    6586             :                 .name = discard_const_p(char, "in_keyclass"),
    6587             :                 .get = py_winreg_EnumKey_in_get_keyclass,
    6588             :                 .set = py_winreg_EnumKey_in_set_keyclass,
    6589             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_StringBuf")
    6590             :         },
    6591             :         {
    6592             :                 .name = discard_const_p(char, "out_keyclass"),
    6593             :                 .get = py_winreg_EnumKey_out_get_keyclass,
    6594             :                 .set = py_winreg_EnumKey_out_set_keyclass,
    6595             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_StringBuf")
    6596             :         },
    6597             :         {
    6598             :                 .name = discard_const_p(char, "in_last_changed_time"),
    6599             :                 .get = py_winreg_EnumKey_in_get_last_changed_time,
    6600             :                 .set = py_winreg_EnumKey_in_set_last_changed_time,
    6601             :                 .doc = discard_const_p(char, "PIDL-generated element of base type NTTIME")
    6602             :         },
    6603             :         {
    6604             :                 .name = discard_const_p(char, "out_last_changed_time"),
    6605             :                 .get = py_winreg_EnumKey_out_get_last_changed_time,
    6606             :                 .set = py_winreg_EnumKey_out_set_last_changed_time,
    6607             :                 .doc = discard_const_p(char, "PIDL-generated element of base type NTTIME")
    6608             :         },
    6609             :         {
    6610             :                 .name = discard_const_p(char, "result"),
    6611             :                 .get = py_winreg_EnumKey_get_result,
    6612             :                 .set = py_winreg_EnumKey_set_result,
    6613             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    6614             :         },
    6615             :         { .name = NULL }
    6616             : };
    6617             : 
    6618           0 : static PyObject *py_winreg_EnumKey_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    6619             : {
    6620           0 :         PyObject *self = pytalloc_new(struct winreg_EnumKey, type);
    6621           0 :         struct winreg_EnumKey *_self = (struct winreg_EnumKey *)pytalloc_get_ptr(self);
    6622           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    6623           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    6624           0 :         _self->in.name = talloc_zero(mem_ctx, struct winreg_StringBuf);
    6625           0 :         _self->out.name = talloc_zero(mem_ctx, struct winreg_StringBuf);
    6626           0 :         return self;
    6627             : }
    6628             : 
    6629           0 : static PyObject *py_winreg_EnumKey_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    6630             : {
    6631             : 
    6632             : 
    6633           0 :         return PyLong_FromLong(9);
    6634             : }
    6635             : 
    6636           0 : static PyObject *py_winreg_EnumKey_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    6637             : {
    6638           0 :         const struct ndr_interface_call *call = NULL;
    6639           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6640           0 :         PyObject *ret = NULL;
    6641           0 :         struct ndr_push *push = NULL;
    6642             :         DATA_BLOB blob;
    6643             :         enum ndr_err_code err;
    6644             : 
    6645           0 :         if (ndr_table_winreg.num_calls < 10) {
    6646           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_EnumKey_ndr_pack");
    6647           0 :                 return NULL;
    6648             :         }
    6649           0 :         call = &ndr_table_winreg.calls[9];
    6650             : 
    6651           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    6652           0 :         if (push == NULL) {
    6653           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    6654           0 :                 return NULL;
    6655             :         }
    6656             : 
    6657           0 :         push->flags |= ndr_push_flags;
    6658             : 
    6659           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    6660           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    6661           0 :                 TALLOC_FREE(push);
    6662           0 :                 PyErr_SetNdrError(err);
    6663           0 :                 return NULL;
    6664             :         }
    6665           0 :         blob = ndr_push_blob(push);
    6666           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    6667           0 :         TALLOC_FREE(push);
    6668           0 :         return ret;
    6669             : }
    6670             : 
    6671           0 : static PyObject *py_winreg_EnumKey_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    6672             : {
    6673           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    6674           0 :         PyObject *bigendian_obj = NULL;
    6675           0 :         PyObject *ndr64_obj = NULL;
    6676           0 :         uint32_t ndr_push_flags = 0;
    6677             : 
    6678           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    6679             :                 discard_const_p(char *, kwnames),
    6680             :                 &bigendian_obj,
    6681             :                 &ndr64_obj)) {
    6682           0 :                 return NULL;
    6683             :         }
    6684             : 
    6685           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    6686           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    6687             :         }
    6688           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    6689           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    6690             :         }
    6691             : 
    6692           0 :         return py_winreg_EnumKey_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    6693             : }
    6694             : 
    6695           0 : static PyObject *py_winreg_EnumKey_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    6696             : {
    6697           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    6698           0 :         PyObject *bigendian_obj = NULL;
    6699           0 :         PyObject *ndr64_obj = NULL;
    6700           0 :         uint32_t ndr_push_flags = 0;
    6701             : 
    6702           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    6703             :                 discard_const_p(char *, kwnames),
    6704             :                 &bigendian_obj,
    6705             :                 &ndr64_obj)) {
    6706           0 :                 return NULL;
    6707             :         }
    6708             : 
    6709           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    6710           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    6711             :         }
    6712           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    6713           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    6714             :         }
    6715             : 
    6716           0 :         return py_winreg_EnumKey_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    6717             : }
    6718             : 
    6719           0 : static PyObject *py_winreg_EnumKey_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    6720             : {
    6721           0 :         const struct ndr_interface_call *call = NULL;
    6722           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6723           0 :         struct ndr_pull *pull = NULL;
    6724             :         enum ndr_err_code err;
    6725             : 
    6726           0 :         if (ndr_table_winreg.num_calls < 10) {
    6727           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_EnumKey_ndr_unpack");
    6728           0 :                 return NULL;
    6729             :         }
    6730           0 :         call = &ndr_table_winreg.calls[9];
    6731             : 
    6732           0 :         pull = ndr_pull_init_blob(blob, object);
    6733           0 :         if (pull == NULL) {
    6734           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    6735           0 :                 return NULL;
    6736             :         }
    6737             : 
    6738           0 :         pull->flags |= ndr_pull_flags;
    6739             : 
    6740           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    6741           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    6742           0 :                 TALLOC_FREE(pull);
    6743           0 :                 PyErr_SetNdrError(err);
    6744           0 :                 return NULL;
    6745             :         }
    6746           0 :         if (!allow_remaining) {
    6747             :                 uint32_t highest_ofs;
    6748             : 
    6749           0 :                 if (pull->offset > pull->relative_highest_offset) {
    6750           0 :                         highest_ofs = pull->offset;
    6751             :                 } else {
    6752           0 :                         highest_ofs = pull->relative_highest_offset;
    6753             :                 }
    6754           0 :                 if (highest_ofs < pull->data_size) {
    6755           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    6756             :                                 "not all bytes consumed ofs[%u] size[%u]",
    6757             :                                 highest_ofs, pull->data_size);
    6758           0 :                         TALLOC_FREE(pull);
    6759           0 :                         PyErr_SetNdrError(err);
    6760           0 :                         return NULL;
    6761             :                 }
    6762             :         }
    6763             : 
    6764           0 :         TALLOC_FREE(pull);
    6765           0 :         Py_RETURN_NONE;
    6766             : }
    6767             : 
    6768           0 : static PyObject *py_winreg_EnumKey_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    6769             : {
    6770             :         DATA_BLOB blob;
    6771           0 :         Py_ssize_t blob_length = 0;
    6772           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    6773           0 :         PyObject *bigendian_obj = NULL;
    6774           0 :         PyObject *ndr64_obj = NULL;
    6775           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    6776           0 :         PyObject *allow_remaining_obj = NULL;
    6777           0 :         bool allow_remaining = false;
    6778             : 
    6779           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    6780             :                 discard_const_p(char *, kwnames),
    6781             :                 &blob.data, &blob_length,
    6782             :                 &bigendian_obj,
    6783             :                 &ndr64_obj,
    6784             :                 &allow_remaining_obj)) {
    6785           0 :                 return NULL;
    6786             :         }
    6787           0 :         blob.length = blob_length;
    6788             : 
    6789           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    6790           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    6791             :         }
    6792           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    6793           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    6794             :         }
    6795             : 
    6796           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    6797           0 :                 allow_remaining = true;
    6798             :         }
    6799             : 
    6800           0 :         return py_winreg_EnumKey_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    6801             : }
    6802             : 
    6803           0 : static PyObject *py_winreg_EnumKey_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    6804             : {
    6805             :         DATA_BLOB blob;
    6806           0 :         Py_ssize_t blob_length = 0;
    6807           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    6808           0 :         PyObject *bigendian_obj = NULL;
    6809           0 :         PyObject *ndr64_obj = NULL;
    6810           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    6811           0 :         PyObject *allow_remaining_obj = NULL;
    6812           0 :         bool allow_remaining = false;
    6813             : 
    6814           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    6815             :                 discard_const_p(char *, kwnames),
    6816             :                 &blob.data, &blob_length,
    6817             :                 &bigendian_obj,
    6818             :                 &ndr64_obj,
    6819             :                 &allow_remaining_obj)) {
    6820           0 :                 return NULL;
    6821             :         }
    6822           0 :         blob.length = blob_length;
    6823             : 
    6824           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    6825           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    6826             :         }
    6827           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    6828           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    6829             :         }
    6830             : 
    6831           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    6832           0 :                 allow_remaining = true;
    6833             :         }
    6834             : 
    6835           0 :         return py_winreg_EnumKey_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    6836             : }
    6837             : 
    6838           0 : static PyObject *py_winreg_EnumKey_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    6839             : {
    6840           0 :         const struct ndr_interface_call *call = NULL;
    6841           0 :         struct winreg_EnumKey *object = (struct winreg_EnumKey *)pytalloc_get_ptr(py_obj);
    6842             :         PyObject *ret;
    6843             :         char *retstr;
    6844             : 
    6845           0 :         if (ndr_table_winreg.num_calls < 10) {
    6846           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_EnumKey_ndr_print");
    6847           0 :                 return NULL;
    6848             :         }
    6849           0 :         call = &ndr_table_winreg.calls[9];
    6850             : 
    6851           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    6852           0 :         ret = PyUnicode_FromString(retstr);
    6853           0 :         TALLOC_FREE(retstr);
    6854             : 
    6855           0 :         return ret;
    6856             : }
    6857             : 
    6858           0 : static PyObject *py_winreg_EnumKey_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    6859             : {
    6860           0 :         return py_winreg_EnumKey_ndr_print(py_obj, "winreg_EnumKey_in", NDR_IN);
    6861             : }
    6862             : 
    6863           0 : static PyObject *py_winreg_EnumKey_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    6864             : {
    6865           0 :         return py_winreg_EnumKey_ndr_print(py_obj, "winreg_EnumKey_out", NDR_OUT);
    6866             : }
    6867             : 
    6868             : static PyMethodDef py_winreg_EnumKey_methods[] = {
    6869             :         { "opnum", (PyCFunction)py_winreg_EnumKey_ndr_opnum, METH_NOARGS|METH_CLASS,
    6870             :                 "winreg.EnumKey.opnum() -> 9 (0x09) " },
    6871             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumKey_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    6872             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    6873             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumKey_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    6874             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    6875             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumKey_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    6876             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    6877             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumKey_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    6878             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    6879             :         { "__ndr_print_in__", (PyCFunction)py_winreg_EnumKey_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    6880             :         { "__ndr_print_out__", (PyCFunction)py_winreg_EnumKey_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    6881             :         { NULL, NULL, 0, NULL }
    6882             : };
    6883             : 
    6884             : 
    6885             : static PyTypeObject winreg_EnumKey_Type = {
    6886             :         PyVarObject_HEAD_INIT(NULL, 0)
    6887             :         .tp_name = "winreg.EnumKey",
    6888             :         .tp_getset = py_winreg_EnumKey_getsetters,
    6889             :         .tp_methods = py_winreg_EnumKey_methods,
    6890             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    6891             :         .tp_new = py_winreg_EnumKey_new,
    6892             : };
    6893             : 
    6894           0 : static bool pack_py_winreg_EnumKey_args_in(PyObject *args, PyObject *kwargs, struct winreg_EnumKey *r)
    6895             : {
    6896             :         PyObject *py_handle;
    6897             :         PyObject *py_enum_index;
    6898             :         PyObject *py_name;
    6899             :         PyObject *py_keyclass;
    6900             :         PyObject *py_last_changed_time;
    6901           0 :         const char *kwnames[] = {
    6902             :                 "handle", "enum_index", "name", "keyclass", "last_changed_time", NULL
    6903             :         };
    6904             : 
    6905           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOO:winreg_EnumKey", discard_const_p(char *, kwnames), &py_handle, &py_enum_index, &py_name, &py_keyclass, &py_last_changed_time)) {
    6906           0 :                 return false;
    6907             :         }
    6908             : 
    6909           0 :         if (py_handle == NULL) {
    6910           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    6911           0 :                 return false;
    6912             :         }
    6913           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    6914           0 :         if (r->in.handle == NULL) {
    6915           0 :                 PyErr_NoMemory();
    6916           0 :                 return false;
    6917             :         }
    6918           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    6919           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    6920           0 :                 PyErr_NoMemory();
    6921           0 :                 return false;
    6922             :         }
    6923           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    6924           0 :         if (py_enum_index == NULL) {
    6925           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.enum_index");
    6926           0 :                 return false;
    6927             :         }
    6928             :         {
    6929           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.enum_index));
    6930           0 :                 if (PyLong_Check(py_enum_index)) {
    6931             :                         unsigned long long test_var;
    6932           0 :                         test_var = PyLong_AsUnsignedLongLong(py_enum_index);
    6933           0 :                         if (PyErr_Occurred() != NULL) {
    6934           0 :                                 return false;
    6935             :                         }
    6936           0 :                         if (test_var > uint_max) {
    6937           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    6938             :                                   PyLong_Type.tp_name, uint_max, test_var);
    6939           0 :                                 return false;
    6940             :                         }
    6941           0 :                         r->in.enum_index = test_var;
    6942             :                 } else {
    6943           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    6944             :                           PyLong_Type.tp_name);
    6945           0 :                         return false;
    6946             :                 }
    6947             :         }
    6948           0 :         if (py_name == NULL) {
    6949           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.name");
    6950           0 :                 return false;
    6951             :         }
    6952           0 :         r->in.name = talloc_ptrtype(r, r->in.name);
    6953           0 :         if (r->in.name == NULL) {
    6954           0 :                 PyErr_NoMemory();
    6955           0 :                 return false;
    6956             :         }
    6957           0 :         PY_CHECK_TYPE(&winreg_StringBuf_Type, py_name, return false;);
    6958           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_name)) == NULL) {
    6959           0 :                 PyErr_NoMemory();
    6960           0 :                 return false;
    6961             :         }
    6962           0 :         r->in.name = (struct winreg_StringBuf *)pytalloc_get_ptr(py_name);
    6963           0 :         if (py_keyclass == NULL) {
    6964           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.keyclass");
    6965           0 :                 return false;
    6966             :         }
    6967           0 :         if (py_keyclass == Py_None) {
    6968           0 :                 r->in.keyclass = NULL;
    6969             :         } else {
    6970           0 :                 r->in.keyclass = NULL;
    6971           0 :                 PY_CHECK_TYPE(&winreg_StringBuf_Type, py_keyclass, return false;);
    6972           0 :                 if (talloc_reference(r, pytalloc_get_mem_ctx(py_keyclass)) == NULL) {
    6973           0 :                         PyErr_NoMemory();
    6974           0 :                         return false;
    6975             :                 }
    6976           0 :                 r->in.keyclass = (struct winreg_StringBuf *)pytalloc_get_ptr(py_keyclass);
    6977             :         }
    6978           0 :         if (py_last_changed_time == NULL) {
    6979           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.last_changed_time");
    6980           0 :                 return false;
    6981             :         }
    6982           0 :         if (py_last_changed_time == Py_None) {
    6983           0 :                 r->in.last_changed_time = NULL;
    6984             :         } else {
    6985           0 :                 r->in.last_changed_time = talloc_ptrtype(r, r->in.last_changed_time);
    6986           0 :                 if (r->in.last_changed_time == NULL) {
    6987           0 :                         PyErr_NoMemory();
    6988           0 :                         return false;
    6989             :                 }
    6990             :                 {
    6991           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.last_changed_time));
    6992           0 :                         if (PyLong_Check(py_last_changed_time)) {
    6993             :                                 unsigned long long test_var;
    6994           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_last_changed_time);
    6995           0 :                                 if (PyErr_Occurred() != NULL) {
    6996           0 :                                         return false;
    6997             :                                 }
    6998           0 :                                 if (test_var > uint_max) {
    6999           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7000             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7001           0 :                                         return false;
    7002             :                                 }
    7003           0 :                                 *r->in.last_changed_time = test_var;
    7004             :                         } else {
    7005           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7006             :                                   PyLong_Type.tp_name);
    7007           0 :                                 return false;
    7008             :                         }
    7009             :                 }
    7010             :         }
    7011           0 :         return true;
    7012             : }
    7013             : 
    7014           0 : static PyObject *unpack_py_winreg_EnumKey_args_out(struct winreg_EnumKey *r)
    7015             : {
    7016             :         PyObject *result;
    7017             :         PyObject *py_name;
    7018             :         PyObject *py_keyclass;
    7019             :         PyObject *py_last_changed_time;
    7020           0 :         result = PyTuple_New(3);
    7021           0 :         py_name = pytalloc_reference_ex(&winreg_StringBuf_Type, r->out.name, r->out.name);
    7022           0 :         PyTuple_SetItem(result, 0, py_name);
    7023           0 :         if (r->out.keyclass == NULL) {
    7024           0 :                 py_keyclass = Py_None;
    7025           0 :                 Py_INCREF(py_keyclass);
    7026             :         } else {
    7027           0 :                 py_keyclass = pytalloc_reference_ex(&winreg_StringBuf_Type, r->out.keyclass, r->out.keyclass);
    7028             :         }
    7029           0 :         PyTuple_SetItem(result, 1, py_keyclass);
    7030           0 :         if (r->out.last_changed_time == NULL) {
    7031           0 :                 py_last_changed_time = Py_None;
    7032           0 :                 Py_INCREF(py_last_changed_time);
    7033             :         } else {
    7034           0 :                 py_last_changed_time = PyLong_FromUnsignedLongLong(*r->out.last_changed_time);
    7035             :         }
    7036           0 :         PyTuple_SetItem(result, 2, py_last_changed_time);
    7037           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    7038           0 :                 PyErr_SetWERROR(r->out.result);
    7039           0 :                 return NULL;
    7040             :         }
    7041             : 
    7042           0 :         return result;
    7043             : }
    7044             : 
    7045             : 
    7046           0 : static PyObject *py_winreg_EnumValue_in_get_handle(PyObject *obj, void *closure)
    7047             : {
    7048           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7049             :         PyObject *py_handle;
    7050           0 :         if (object->in.handle == NULL) {
    7051           0 :                 Py_RETURN_NONE;
    7052             :         }
    7053           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    7054           0 :         return py_handle;
    7055             : }
    7056             : 
    7057           0 : static int py_winreg_EnumValue_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    7058             : {
    7059           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7060           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    7061           0 :         if (value == NULL) {
    7062           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    7063           0 :                 return -1;
    7064             :         }
    7065           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    7066           0 :         if (object->in.handle == NULL) {
    7067           0 :                 PyErr_NoMemory();
    7068           0 :                 return -1;
    7069             :         }
    7070           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    7071           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    7072           0 :                 PyErr_NoMemory();
    7073           0 :                 return -1;
    7074             :         }
    7075           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    7076           0 :         return 0;
    7077             : }
    7078             : 
    7079           0 : static PyObject *py_winreg_EnumValue_in_get_enum_index(PyObject *obj, void *closure)
    7080             : {
    7081           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7082             :         PyObject *py_enum_index;
    7083           0 :         py_enum_index = PyLong_FromUnsignedLongLong((uint32_t)object->in.enum_index);
    7084           0 :         return py_enum_index;
    7085             : }
    7086             : 
    7087           0 : static int py_winreg_EnumValue_in_set_enum_index(PyObject *py_obj, PyObject *value, void *closure)
    7088             : {
    7089           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7090           0 :         if (value == NULL) {
    7091           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.enum_index");
    7092           0 :                 return -1;
    7093             :         }
    7094             :         {
    7095           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.enum_index));
    7096           0 :                 if (PyLong_Check(value)) {
    7097             :                         unsigned long long test_var;
    7098           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    7099           0 :                         if (PyErr_Occurred() != NULL) {
    7100           0 :                                 return -1;
    7101             :                         }
    7102           0 :                         if (test_var > uint_max) {
    7103           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7104             :                                   PyLong_Type.tp_name, uint_max, test_var);
    7105           0 :                                 return -1;
    7106             :                         }
    7107           0 :                         object->in.enum_index = test_var;
    7108             :                 } else {
    7109           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7110             :                           PyLong_Type.tp_name);
    7111           0 :                         return -1;
    7112             :                 }
    7113             :         }
    7114           0 :         return 0;
    7115             : }
    7116             : 
    7117           0 : static PyObject *py_winreg_EnumValue_in_get_name(PyObject *obj, void *closure)
    7118             : {
    7119           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7120             :         PyObject *py_name;
    7121           0 :         if (object->in.name == NULL) {
    7122           0 :                 Py_RETURN_NONE;
    7123             :         }
    7124           0 :         py_name = pytalloc_reference_ex(&winreg_ValNameBuf_Type, object->in.name, object->in.name);
    7125           0 :         return py_name;
    7126             : }
    7127             : 
    7128           0 : static int py_winreg_EnumValue_in_set_name(PyObject *py_obj, PyObject *value, void *closure)
    7129             : {
    7130           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7131           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.name));
    7132           0 :         if (value == NULL) {
    7133           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.name");
    7134           0 :                 return -1;
    7135             :         }
    7136           0 :         object->in.name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.name);
    7137           0 :         if (object->in.name == NULL) {
    7138           0 :                 PyErr_NoMemory();
    7139           0 :                 return -1;
    7140             :         }
    7141           0 :         PY_CHECK_TYPE(&winreg_ValNameBuf_Type, value, return -1;);
    7142           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    7143           0 :                 PyErr_NoMemory();
    7144           0 :                 return -1;
    7145             :         }
    7146           0 :         object->in.name = (struct winreg_ValNameBuf *)pytalloc_get_ptr(value);
    7147           0 :         return 0;
    7148             : }
    7149             : 
    7150           0 : static PyObject *py_winreg_EnumValue_out_get_name(PyObject *obj, void *closure)
    7151             : {
    7152           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7153             :         PyObject *py_name;
    7154           0 :         if (object->out.name == NULL) {
    7155           0 :                 Py_RETURN_NONE;
    7156             :         }
    7157           0 :         py_name = pytalloc_reference_ex(&winreg_ValNameBuf_Type, object->out.name, object->out.name);
    7158           0 :         return py_name;
    7159             : }
    7160             : 
    7161           0 : static int py_winreg_EnumValue_out_set_name(PyObject *py_obj, PyObject *value, void *closure)
    7162             : {
    7163           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7164           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.name));
    7165           0 :         if (value == NULL) {
    7166           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.name");
    7167           0 :                 return -1;
    7168             :         }
    7169           0 :         object->out.name = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.name);
    7170           0 :         if (object->out.name == NULL) {
    7171           0 :                 PyErr_NoMemory();
    7172           0 :                 return -1;
    7173             :         }
    7174           0 :         PY_CHECK_TYPE(&winreg_ValNameBuf_Type, value, return -1;);
    7175           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    7176           0 :                 PyErr_NoMemory();
    7177           0 :                 return -1;
    7178             :         }
    7179           0 :         object->out.name = (struct winreg_ValNameBuf *)pytalloc_get_ptr(value);
    7180           0 :         return 0;
    7181             : }
    7182             : 
    7183           0 : static PyObject *py_winreg_EnumValue_in_get_type(PyObject *obj, void *closure)
    7184             : {
    7185           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7186             :         PyObject *py_type;
    7187           0 :         if (object->in.type == NULL) {
    7188           0 :                 Py_RETURN_NONE;
    7189             :         }
    7190           0 :         if (object->in.type == NULL) {
    7191           0 :                 py_type = Py_None;
    7192           0 :                 Py_INCREF(py_type);
    7193             :         } else {
    7194           0 :                 py_type = PyLong_FromUnsignedLongLong((uint32_t)*object->in.type);
    7195             :         }
    7196           0 :         return py_type;
    7197             : }
    7198             : 
    7199           0 : static int py_winreg_EnumValue_in_set_type(PyObject *py_obj, PyObject *value, void *closure)
    7200             : {
    7201           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7202           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.type));
    7203           0 :         if (value == NULL) {
    7204           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.type");
    7205           0 :                 return -1;
    7206             :         }
    7207           0 :         if (value == Py_None) {
    7208           0 :                 object->in.type = NULL;
    7209             :         } else {
    7210           0 :                 object->in.type = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.type);
    7211           0 :                 if (object->in.type == NULL) {
    7212           0 :                         PyErr_NoMemory();
    7213           0 :                         return -1;
    7214             :                 }
    7215             :                 {
    7216           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.type));
    7217           0 :                         if (PyLong_Check(value)) {
    7218             :                                 unsigned long long test_var;
    7219           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    7220           0 :                                 if (PyErr_Occurred() != NULL) {
    7221           0 :                                         return -1;
    7222             :                                 }
    7223           0 :                                 if (test_var > uint_max) {
    7224           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7225             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7226           0 :                                         return -1;
    7227             :                                 }
    7228           0 :                                 *object->in.type = test_var;
    7229             :                         } else {
    7230           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7231             :                                   PyLong_Type.tp_name);
    7232           0 :                                 return -1;
    7233             :                         }
    7234             :                 }
    7235             :         }
    7236           0 :         return 0;
    7237             : }
    7238             : 
    7239           0 : static PyObject *py_winreg_EnumValue_out_get_type(PyObject *obj, void *closure)
    7240             : {
    7241           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7242             :         PyObject *py_type;
    7243           0 :         if (object->out.type == NULL) {
    7244           0 :                 Py_RETURN_NONE;
    7245             :         }
    7246           0 :         if (object->out.type == NULL) {
    7247           0 :                 py_type = Py_None;
    7248           0 :                 Py_INCREF(py_type);
    7249             :         } else {
    7250           0 :                 py_type = PyLong_FromUnsignedLongLong((uint32_t)*object->out.type);
    7251             :         }
    7252           0 :         return py_type;
    7253             : }
    7254             : 
    7255           0 : static int py_winreg_EnumValue_out_set_type(PyObject *py_obj, PyObject *value, void *closure)
    7256             : {
    7257           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7258           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.type));
    7259           0 :         if (value == NULL) {
    7260           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.type");
    7261           0 :                 return -1;
    7262             :         }
    7263           0 :         if (value == Py_None) {
    7264           0 :                 object->out.type = NULL;
    7265             :         } else {
    7266           0 :                 object->out.type = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.type);
    7267           0 :                 if (object->out.type == NULL) {
    7268           0 :                         PyErr_NoMemory();
    7269           0 :                         return -1;
    7270             :                 }
    7271             :                 {
    7272           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.type));
    7273           0 :                         if (PyLong_Check(value)) {
    7274             :                                 unsigned long long test_var;
    7275           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    7276           0 :                                 if (PyErr_Occurred() != NULL) {
    7277           0 :                                         return -1;
    7278             :                                 }
    7279           0 :                                 if (test_var > uint_max) {
    7280           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7281             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7282           0 :                                         return -1;
    7283             :                                 }
    7284           0 :                                 *object->out.type = test_var;
    7285             :                         } else {
    7286           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7287             :                                   PyLong_Type.tp_name);
    7288           0 :                                 return -1;
    7289             :                         }
    7290             :                 }
    7291             :         }
    7292           0 :         return 0;
    7293             : }
    7294             : 
    7295           0 : static PyObject *py_winreg_EnumValue_in_get_value(PyObject *obj, void *closure)
    7296             : {
    7297           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7298             :         PyObject *py_value;
    7299           0 :         if (object->in.value == NULL) {
    7300           0 :                 Py_RETURN_NONE;
    7301             :         }
    7302           0 :         if (object->in.value == NULL) {
    7303           0 :                 py_value = Py_None;
    7304           0 :                 Py_INCREF(py_value);
    7305             :         } else {
    7306           0 :                 py_value = PyList_New(object->in.length?*object->in.length:0);
    7307           0 :                 if (py_value == NULL) {
    7308           0 :                         return NULL;
    7309             :                 }
    7310             :                 {
    7311             :                         int value_cntr_1;
    7312           0 :                         for (value_cntr_1 = 0; value_cntr_1 < (object->in.length?*object->in.length:0); value_cntr_1++) {
    7313             :                                 PyObject *py_value_1;
    7314           0 :                                 py_value_1 = PyLong_FromLong((uint16_t)object->in.value[value_cntr_1]);
    7315           0 :                                 PyList_SetItem(py_value, value_cntr_1, py_value_1);
    7316             :                         }
    7317             :                 }
    7318             :         }
    7319           0 :         return py_value;
    7320             : }
    7321             : 
    7322           0 : static int py_winreg_EnumValue_in_set_value(PyObject *py_obj, PyObject *value, void *closure)
    7323             : {
    7324           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7325           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.value));
    7326           0 :         if (value == NULL) {
    7327           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.value");
    7328           0 :                 return -1;
    7329             :         }
    7330           0 :         if (value == Py_None) {
    7331           0 :                 object->in.value = NULL;
    7332             :         } else {
    7333           0 :                 object->in.value = NULL;
    7334           0 :                 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    7335             :                 {
    7336             :                         int value_cntr_1;
    7337           0 :                         object->in.value = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.value, PyList_GET_SIZE(value));
    7338           0 :                         if (!object->in.value) { return -1;; }
    7339           0 :                         talloc_set_name_const(object->in.value, "ARRAY: object->in.value");
    7340           0 :                         for (value_cntr_1 = 0; value_cntr_1 < PyList_GET_SIZE(value); value_cntr_1++) {
    7341           0 :                                 if (PyList_GET_ITEM(value, value_cntr_1) == NULL) {
    7342           0 :                                         PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.value[value_cntr_1]");
    7343           0 :                                         return -1;
    7344             :                                 }
    7345             :                                 {
    7346           0 :                                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.value[value_cntr_1]));
    7347           0 :                                         if (PyLong_Check(PyList_GET_ITEM(value, value_cntr_1))) {
    7348             :                                                 unsigned long long test_var;
    7349           0 :                                                 test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, value_cntr_1));
    7350           0 :                                                 if (PyErr_Occurred() != NULL) {
    7351           0 :                                                         return -1;
    7352             :                                                 }
    7353           0 :                                                 if (test_var > uint_max) {
    7354           0 :                                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7355             :                                                           PyLong_Type.tp_name, uint_max, test_var);
    7356           0 :                                                         return -1;
    7357             :                                                 }
    7358           0 :                                                 object->in.value[value_cntr_1] = test_var;
    7359             :                                         } else {
    7360           0 :                                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7361             :                                                   PyLong_Type.tp_name);
    7362           0 :                                                 return -1;
    7363             :                                         }
    7364             :                                 }
    7365             :                         }
    7366             :                 }
    7367             :         }
    7368           0 :         return 0;
    7369             : }
    7370             : 
    7371           0 : static PyObject *py_winreg_EnumValue_out_get_value(PyObject *obj, void *closure)
    7372             : {
    7373           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7374             :         PyObject *py_value;
    7375           0 :         if (object->out.value == NULL) {
    7376           0 :                 Py_RETURN_NONE;
    7377             :         }
    7378           0 :         if (object->out.value == NULL) {
    7379           0 :                 py_value = Py_None;
    7380           0 :                 Py_INCREF(py_value);
    7381             :         } else {
    7382           0 :                 py_value = PyList_New(object->out.length?*object->out.length:0);
    7383           0 :                 if (py_value == NULL) {
    7384           0 :                         return NULL;
    7385             :                 }
    7386             :                 {
    7387             :                         int value_cntr_1;
    7388           0 :                         for (value_cntr_1 = 0; value_cntr_1 < (object->out.length?*object->out.length:0); value_cntr_1++) {
    7389             :                                 PyObject *py_value_1;
    7390           0 :                                 py_value_1 = PyLong_FromLong((uint16_t)object->out.value[value_cntr_1]);
    7391           0 :                                 PyList_SetItem(py_value, value_cntr_1, py_value_1);
    7392             :                         }
    7393             :                 }
    7394             :         }
    7395           0 :         return py_value;
    7396             : }
    7397             : 
    7398           0 : static int py_winreg_EnumValue_out_set_value(PyObject *py_obj, PyObject *value, void *closure)
    7399             : {
    7400           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7401           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.value));
    7402           0 :         if (value == NULL) {
    7403           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.value");
    7404           0 :                 return -1;
    7405             :         }
    7406           0 :         if (value == Py_None) {
    7407           0 :                 object->out.value = NULL;
    7408             :         } else {
    7409           0 :                 object->out.value = NULL;
    7410           0 :                 PY_CHECK_TYPE(&PyList_Type, value, return -1;);
    7411             :                 {
    7412             :                         int value_cntr_1;
    7413           0 :                         object->out.value = talloc_array_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.value, PyList_GET_SIZE(value));
    7414           0 :                         if (!object->out.value) { return -1;; }
    7415           0 :                         talloc_set_name_const(object->out.value, "ARRAY: object->out.value");
    7416           0 :                         for (value_cntr_1 = 0; value_cntr_1 < PyList_GET_SIZE(value); value_cntr_1++) {
    7417           0 :                                 if (PyList_GET_ITEM(value, value_cntr_1) == NULL) {
    7418           0 :                                         PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.value[value_cntr_1]");
    7419           0 :                                         return -1;
    7420             :                                 }
    7421             :                                 {
    7422           0 :                                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->out.value[value_cntr_1]));
    7423           0 :                                         if (PyLong_Check(PyList_GET_ITEM(value, value_cntr_1))) {
    7424             :                                                 unsigned long long test_var;
    7425           0 :                                                 test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(value, value_cntr_1));
    7426           0 :                                                 if (PyErr_Occurred() != NULL) {
    7427           0 :                                                         return -1;
    7428             :                                                 }
    7429           0 :                                                 if (test_var > uint_max) {
    7430           0 :                                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7431             :                                                           PyLong_Type.tp_name, uint_max, test_var);
    7432           0 :                                                         return -1;
    7433             :                                                 }
    7434           0 :                                                 object->out.value[value_cntr_1] = test_var;
    7435             :                                         } else {
    7436           0 :                                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7437             :                                                   PyLong_Type.tp_name);
    7438           0 :                                                 return -1;
    7439             :                                         }
    7440             :                                 }
    7441             :                         }
    7442             :                 }
    7443             :         }
    7444           0 :         return 0;
    7445             : }
    7446             : 
    7447           0 : static PyObject *py_winreg_EnumValue_in_get_size(PyObject *obj, void *closure)
    7448             : {
    7449           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7450             :         PyObject *py_size;
    7451           0 :         if (object->in.size == NULL) {
    7452           0 :                 Py_RETURN_NONE;
    7453             :         }
    7454           0 :         if (object->in.size == NULL) {
    7455           0 :                 py_size = Py_None;
    7456           0 :                 Py_INCREF(py_size);
    7457             :         } else {
    7458           0 :                 py_size = PyLong_FromUnsignedLongLong((uint32_t)*object->in.size);
    7459             :         }
    7460           0 :         return py_size;
    7461             : }
    7462             : 
    7463           0 : static int py_winreg_EnumValue_in_set_size(PyObject *py_obj, PyObject *value, void *closure)
    7464             : {
    7465           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7466           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.size));
    7467           0 :         if (value == NULL) {
    7468           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.size");
    7469           0 :                 return -1;
    7470             :         }
    7471           0 :         if (value == Py_None) {
    7472           0 :                 object->in.size = NULL;
    7473             :         } else {
    7474           0 :                 object->in.size = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.size);
    7475           0 :                 if (object->in.size == NULL) {
    7476           0 :                         PyErr_NoMemory();
    7477           0 :                         return -1;
    7478             :                 }
    7479             :                 {
    7480           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.size));
    7481           0 :                         if (PyLong_Check(value)) {
    7482             :                                 unsigned long long test_var;
    7483           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    7484           0 :                                 if (PyErr_Occurred() != NULL) {
    7485           0 :                                         return -1;
    7486             :                                 }
    7487           0 :                                 if (test_var > uint_max) {
    7488           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7489             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7490           0 :                                         return -1;
    7491             :                                 }
    7492           0 :                                 *object->in.size = test_var;
    7493             :                         } else {
    7494           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7495             :                                   PyLong_Type.tp_name);
    7496           0 :                                 return -1;
    7497             :                         }
    7498             :                 }
    7499             :         }
    7500           0 :         return 0;
    7501             : }
    7502             : 
    7503           0 : static PyObject *py_winreg_EnumValue_out_get_size(PyObject *obj, void *closure)
    7504             : {
    7505           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7506             :         PyObject *py_size;
    7507           0 :         if (object->out.size == NULL) {
    7508           0 :                 Py_RETURN_NONE;
    7509             :         }
    7510           0 :         if (object->out.size == NULL) {
    7511           0 :                 py_size = Py_None;
    7512           0 :                 Py_INCREF(py_size);
    7513             :         } else {
    7514           0 :                 py_size = PyLong_FromUnsignedLongLong((uint32_t)*object->out.size);
    7515             :         }
    7516           0 :         return py_size;
    7517             : }
    7518             : 
    7519           0 : static int py_winreg_EnumValue_out_set_size(PyObject *py_obj, PyObject *value, void *closure)
    7520             : {
    7521           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7522           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.size));
    7523           0 :         if (value == NULL) {
    7524           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.size");
    7525           0 :                 return -1;
    7526             :         }
    7527           0 :         if (value == Py_None) {
    7528           0 :                 object->out.size = NULL;
    7529             :         } else {
    7530           0 :                 object->out.size = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.size);
    7531           0 :                 if (object->out.size == NULL) {
    7532           0 :                         PyErr_NoMemory();
    7533           0 :                         return -1;
    7534             :                 }
    7535             :                 {
    7536           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.size));
    7537           0 :                         if (PyLong_Check(value)) {
    7538             :                                 unsigned long long test_var;
    7539           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    7540           0 :                                 if (PyErr_Occurred() != NULL) {
    7541           0 :                                         return -1;
    7542             :                                 }
    7543           0 :                                 if (test_var > uint_max) {
    7544           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7545             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7546           0 :                                         return -1;
    7547             :                                 }
    7548           0 :                                 *object->out.size = test_var;
    7549             :                         } else {
    7550           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7551             :                                   PyLong_Type.tp_name);
    7552           0 :                                 return -1;
    7553             :                         }
    7554             :                 }
    7555             :         }
    7556           0 :         return 0;
    7557             : }
    7558             : 
    7559           0 : static PyObject *py_winreg_EnumValue_in_get_length(PyObject *obj, void *closure)
    7560             : {
    7561           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7562             :         PyObject *py_length;
    7563           0 :         if (object->in.length == NULL) {
    7564           0 :                 Py_RETURN_NONE;
    7565             :         }
    7566           0 :         if (object->in.length == NULL) {
    7567           0 :                 py_length = Py_None;
    7568           0 :                 Py_INCREF(py_length);
    7569             :         } else {
    7570           0 :                 py_length = PyLong_FromUnsignedLongLong((uint32_t)*object->in.length);
    7571             :         }
    7572           0 :         return py_length;
    7573             : }
    7574             : 
    7575           0 : static int py_winreg_EnumValue_in_set_length(PyObject *py_obj, PyObject *value, void *closure)
    7576             : {
    7577           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7578           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.length));
    7579           0 :         if (value == NULL) {
    7580           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.length");
    7581           0 :                 return -1;
    7582             :         }
    7583           0 :         if (value == Py_None) {
    7584           0 :                 object->in.length = NULL;
    7585             :         } else {
    7586           0 :                 object->in.length = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.length);
    7587           0 :                 if (object->in.length == NULL) {
    7588           0 :                         PyErr_NoMemory();
    7589           0 :                         return -1;
    7590             :                 }
    7591             :                 {
    7592           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->in.length));
    7593           0 :                         if (PyLong_Check(value)) {
    7594             :                                 unsigned long long test_var;
    7595           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    7596           0 :                                 if (PyErr_Occurred() != NULL) {
    7597           0 :                                         return -1;
    7598             :                                 }
    7599           0 :                                 if (test_var > uint_max) {
    7600           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7601             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7602           0 :                                         return -1;
    7603             :                                 }
    7604           0 :                                 *object->in.length = test_var;
    7605             :                         } else {
    7606           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7607             :                                   PyLong_Type.tp_name);
    7608           0 :                                 return -1;
    7609             :                         }
    7610             :                 }
    7611             :         }
    7612           0 :         return 0;
    7613             : }
    7614             : 
    7615           0 : static PyObject *py_winreg_EnumValue_out_get_length(PyObject *obj, void *closure)
    7616             : {
    7617           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7618             :         PyObject *py_length;
    7619           0 :         if (object->out.length == NULL) {
    7620           0 :                 Py_RETURN_NONE;
    7621             :         }
    7622           0 :         if (object->out.length == NULL) {
    7623           0 :                 py_length = Py_None;
    7624           0 :                 Py_INCREF(py_length);
    7625             :         } else {
    7626           0 :                 py_length = PyLong_FromUnsignedLongLong((uint32_t)*object->out.length);
    7627             :         }
    7628           0 :         return py_length;
    7629             : }
    7630             : 
    7631           0 : static int py_winreg_EnumValue_out_set_length(PyObject *py_obj, PyObject *value, void *closure)
    7632             : {
    7633           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7634           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.length));
    7635           0 :         if (value == NULL) {
    7636           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.length");
    7637           0 :                 return -1;
    7638             :         }
    7639           0 :         if (value == Py_None) {
    7640           0 :                 object->out.length = NULL;
    7641             :         } else {
    7642           0 :                 object->out.length = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.length);
    7643           0 :                 if (object->out.length == NULL) {
    7644           0 :                         PyErr_NoMemory();
    7645           0 :                         return -1;
    7646             :                 }
    7647             :                 {
    7648           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*object->out.length));
    7649           0 :                         if (PyLong_Check(value)) {
    7650             :                                 unsigned long long test_var;
    7651           0 :                                 test_var = PyLong_AsUnsignedLongLong(value);
    7652           0 :                                 if (PyErr_Occurred() != NULL) {
    7653           0 :                                         return -1;
    7654             :                                 }
    7655           0 :                                 if (test_var > uint_max) {
    7656           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    7657             :                                           PyLong_Type.tp_name, uint_max, test_var);
    7658           0 :                                         return -1;
    7659             :                                 }
    7660           0 :                                 *object->out.length = test_var;
    7661             :                         } else {
    7662           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    7663             :                                   PyLong_Type.tp_name);
    7664           0 :                                 return -1;
    7665             :                         }
    7666             :                 }
    7667             :         }
    7668           0 :         return 0;
    7669             : }
    7670             : 
    7671           0 : static PyObject *py_winreg_EnumValue_get_result(PyObject *obj, void *closure)
    7672             : {
    7673           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(obj);
    7674             :         PyObject *py_result;
    7675           0 :         py_result = PyErr_FromWERROR(object->out.result);
    7676           0 :         return py_result;
    7677             : }
    7678             : 
    7679           0 : static int py_winreg_EnumValue_set_result(PyObject *py_obj, PyObject *value, void *closure)
    7680             : {
    7681           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7682           0 :         if (value == NULL) {
    7683           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    7684           0 :                 return -1;
    7685             :         }
    7686           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    7687           0 :         return 0;
    7688             : }
    7689             : 
    7690             : static PyGetSetDef py_winreg_EnumValue_getsetters[] = {
    7691             :         {
    7692             :                 .name = discard_const_p(char, "in_handle"),
    7693             :                 .get = py_winreg_EnumValue_in_get_handle,
    7694             :                 .set = py_winreg_EnumValue_in_set_handle,
    7695             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    7696             :         },
    7697             :         {
    7698             :                 .name = discard_const_p(char, "in_enum_index"),
    7699             :                 .get = py_winreg_EnumValue_in_get_enum_index,
    7700             :                 .set = py_winreg_EnumValue_in_set_enum_index,
    7701             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    7702             :         },
    7703             :         {
    7704             :                 .name = discard_const_p(char, "in_name"),
    7705             :                 .get = py_winreg_EnumValue_in_get_name,
    7706             :                 .set = py_winreg_EnumValue_in_set_name,
    7707             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_ValNameBuf")
    7708             :         },
    7709             :         {
    7710             :                 .name = discard_const_p(char, "out_name"),
    7711             :                 .get = py_winreg_EnumValue_out_get_name,
    7712             :                 .set = py_winreg_EnumValue_out_set_name,
    7713             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_ValNameBuf")
    7714             :         },
    7715             :         {
    7716             :                 .name = discard_const_p(char, "in_type"),
    7717             :                 .get = py_winreg_EnumValue_in_get_type,
    7718             :                 .set = py_winreg_EnumValue_in_set_type,
    7719             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_Type")
    7720             :         },
    7721             :         {
    7722             :                 .name = discard_const_p(char, "out_type"),
    7723             :                 .get = py_winreg_EnumValue_out_get_type,
    7724             :                 .set = py_winreg_EnumValue_out_set_type,
    7725             :                 .doc = discard_const_p(char, "PIDL-generated element of base type winreg_Type")
    7726             :         },
    7727             :         {
    7728             :                 .name = discard_const_p(char, "in_value"),
    7729             :                 .get = py_winreg_EnumValue_in_get_value,
    7730             :                 .set = py_winreg_EnumValue_in_set_value,
    7731             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    7732             :         },
    7733             :         {
    7734             :                 .name = discard_const_p(char, "out_value"),
    7735             :                 .get = py_winreg_EnumValue_out_get_value,
    7736             :                 .set = py_winreg_EnumValue_out_set_value,
    7737             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint8")
    7738             :         },
    7739             :         {
    7740             :                 .name = discard_const_p(char, "in_size"),
    7741             :                 .get = py_winreg_EnumValue_in_get_size,
    7742             :                 .set = py_winreg_EnumValue_in_set_size,
    7743             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    7744             :         },
    7745             :         {
    7746             :                 .name = discard_const_p(char, "out_size"),
    7747             :                 .get = py_winreg_EnumValue_out_get_size,
    7748             :                 .set = py_winreg_EnumValue_out_set_size,
    7749             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    7750             :         },
    7751             :         {
    7752             :                 .name = discard_const_p(char, "in_length"),
    7753             :                 .get = py_winreg_EnumValue_in_get_length,
    7754             :                 .set = py_winreg_EnumValue_in_set_length,
    7755             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    7756             :         },
    7757             :         {
    7758             :                 .name = discard_const_p(char, "out_length"),
    7759             :                 .get = py_winreg_EnumValue_out_get_length,
    7760             :                 .set = py_winreg_EnumValue_out_set_length,
    7761             :                 .doc = discard_const_p(char, "PIDL-generated element of base type uint32")
    7762             :         },
    7763             :         {
    7764             :                 .name = discard_const_p(char, "result"),
    7765             :                 .get = py_winreg_EnumValue_get_result,
    7766             :                 .set = py_winreg_EnumValue_set_result,
    7767             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    7768             :         },
    7769             :         { .name = NULL }
    7770             : };
    7771             : 
    7772           0 : static PyObject *py_winreg_EnumValue_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    7773             : {
    7774           0 :         PyObject *self = pytalloc_new(struct winreg_EnumValue, type);
    7775           0 :         struct winreg_EnumValue *_self = (struct winreg_EnumValue *)pytalloc_get_ptr(self);
    7776           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    7777           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    7778           0 :         _self->in.name = talloc_zero(mem_ctx, struct winreg_ValNameBuf);
    7779           0 :         _self->out.name = talloc_zero(mem_ctx, struct winreg_ValNameBuf);
    7780           0 :         return self;
    7781             : }
    7782             : 
    7783           0 : static PyObject *py_winreg_EnumValue_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    7784             : {
    7785             : 
    7786             : 
    7787           0 :         return PyLong_FromLong(10);
    7788             : }
    7789             : 
    7790           0 : static PyObject *py_winreg_EnumValue_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    7791             : {
    7792           0 :         const struct ndr_interface_call *call = NULL;
    7793           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7794           0 :         PyObject *ret = NULL;
    7795           0 :         struct ndr_push *push = NULL;
    7796             :         DATA_BLOB blob;
    7797             :         enum ndr_err_code err;
    7798             : 
    7799           0 :         if (ndr_table_winreg.num_calls < 11) {
    7800           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_EnumValue_ndr_pack");
    7801           0 :                 return NULL;
    7802             :         }
    7803           0 :         call = &ndr_table_winreg.calls[10];
    7804             : 
    7805           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    7806           0 :         if (push == NULL) {
    7807           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    7808           0 :                 return NULL;
    7809             :         }
    7810             : 
    7811           0 :         push->flags |= ndr_push_flags;
    7812             : 
    7813           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    7814           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    7815           0 :                 TALLOC_FREE(push);
    7816           0 :                 PyErr_SetNdrError(err);
    7817           0 :                 return NULL;
    7818             :         }
    7819           0 :         blob = ndr_push_blob(push);
    7820           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    7821           0 :         TALLOC_FREE(push);
    7822           0 :         return ret;
    7823             : }
    7824             : 
    7825           0 : static PyObject *py_winreg_EnumValue_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    7826             : {
    7827           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    7828           0 :         PyObject *bigendian_obj = NULL;
    7829           0 :         PyObject *ndr64_obj = NULL;
    7830           0 :         uint32_t ndr_push_flags = 0;
    7831             : 
    7832           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    7833             :                 discard_const_p(char *, kwnames),
    7834             :                 &bigendian_obj,
    7835             :                 &ndr64_obj)) {
    7836           0 :                 return NULL;
    7837             :         }
    7838             : 
    7839           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    7840           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    7841             :         }
    7842           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    7843           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    7844             :         }
    7845             : 
    7846           0 :         return py_winreg_EnumValue_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    7847             : }
    7848             : 
    7849           0 : static PyObject *py_winreg_EnumValue_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    7850             : {
    7851           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    7852           0 :         PyObject *bigendian_obj = NULL;
    7853           0 :         PyObject *ndr64_obj = NULL;
    7854           0 :         uint32_t ndr_push_flags = 0;
    7855             : 
    7856           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    7857             :                 discard_const_p(char *, kwnames),
    7858             :                 &bigendian_obj,
    7859             :                 &ndr64_obj)) {
    7860           0 :                 return NULL;
    7861             :         }
    7862             : 
    7863           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    7864           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    7865             :         }
    7866           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    7867           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    7868             :         }
    7869             : 
    7870           0 :         return py_winreg_EnumValue_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    7871             : }
    7872             : 
    7873           0 : static PyObject *py_winreg_EnumValue_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    7874             : {
    7875           0 :         const struct ndr_interface_call *call = NULL;
    7876           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7877           0 :         struct ndr_pull *pull = NULL;
    7878             :         enum ndr_err_code err;
    7879             : 
    7880           0 :         if (ndr_table_winreg.num_calls < 11) {
    7881           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_EnumValue_ndr_unpack");
    7882           0 :                 return NULL;
    7883             :         }
    7884           0 :         call = &ndr_table_winreg.calls[10];
    7885             : 
    7886           0 :         pull = ndr_pull_init_blob(blob, object);
    7887           0 :         if (pull == NULL) {
    7888           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    7889           0 :                 return NULL;
    7890             :         }
    7891             : 
    7892           0 :         pull->flags |= ndr_pull_flags;
    7893             : 
    7894           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    7895           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    7896           0 :                 TALLOC_FREE(pull);
    7897           0 :                 PyErr_SetNdrError(err);
    7898           0 :                 return NULL;
    7899             :         }
    7900           0 :         if (!allow_remaining) {
    7901             :                 uint32_t highest_ofs;
    7902             : 
    7903           0 :                 if (pull->offset > pull->relative_highest_offset) {
    7904           0 :                         highest_ofs = pull->offset;
    7905             :                 } else {
    7906           0 :                         highest_ofs = pull->relative_highest_offset;
    7907             :                 }
    7908           0 :                 if (highest_ofs < pull->data_size) {
    7909           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    7910             :                                 "not all bytes consumed ofs[%u] size[%u]",
    7911             :                                 highest_ofs, pull->data_size);
    7912           0 :                         TALLOC_FREE(pull);
    7913           0 :                         PyErr_SetNdrError(err);
    7914           0 :                         return NULL;
    7915             :                 }
    7916             :         }
    7917             : 
    7918           0 :         TALLOC_FREE(pull);
    7919           0 :         Py_RETURN_NONE;
    7920             : }
    7921             : 
    7922           0 : static PyObject *py_winreg_EnumValue_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    7923             : {
    7924             :         DATA_BLOB blob;
    7925           0 :         Py_ssize_t blob_length = 0;
    7926           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    7927           0 :         PyObject *bigendian_obj = NULL;
    7928           0 :         PyObject *ndr64_obj = NULL;
    7929           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    7930           0 :         PyObject *allow_remaining_obj = NULL;
    7931           0 :         bool allow_remaining = false;
    7932             : 
    7933           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    7934             :                 discard_const_p(char *, kwnames),
    7935             :                 &blob.data, &blob_length,
    7936             :                 &bigendian_obj,
    7937             :                 &ndr64_obj,
    7938             :                 &allow_remaining_obj)) {
    7939           0 :                 return NULL;
    7940             :         }
    7941           0 :         blob.length = blob_length;
    7942             : 
    7943           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    7944           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    7945             :         }
    7946           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    7947           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    7948             :         }
    7949             : 
    7950           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    7951           0 :                 allow_remaining = true;
    7952             :         }
    7953             : 
    7954           0 :         return py_winreg_EnumValue_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    7955             : }
    7956             : 
    7957           0 : static PyObject *py_winreg_EnumValue_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    7958             : {
    7959             :         DATA_BLOB blob;
    7960           0 :         Py_ssize_t blob_length = 0;
    7961           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    7962           0 :         PyObject *bigendian_obj = NULL;
    7963           0 :         PyObject *ndr64_obj = NULL;
    7964           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    7965           0 :         PyObject *allow_remaining_obj = NULL;
    7966           0 :         bool allow_remaining = false;
    7967             : 
    7968           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    7969             :                 discard_const_p(char *, kwnames),
    7970             :                 &blob.data, &blob_length,
    7971             :                 &bigendian_obj,
    7972             :                 &ndr64_obj,
    7973             :                 &allow_remaining_obj)) {
    7974           0 :                 return NULL;
    7975             :         }
    7976           0 :         blob.length = blob_length;
    7977             : 
    7978           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    7979           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    7980             :         }
    7981           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    7982           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    7983             :         }
    7984             : 
    7985           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    7986           0 :                 allow_remaining = true;
    7987             :         }
    7988             : 
    7989           0 :         return py_winreg_EnumValue_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    7990             : }
    7991             : 
    7992           0 : static PyObject *py_winreg_EnumValue_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    7993             : {
    7994           0 :         const struct ndr_interface_call *call = NULL;
    7995           0 :         struct winreg_EnumValue *object = (struct winreg_EnumValue *)pytalloc_get_ptr(py_obj);
    7996             :         PyObject *ret;
    7997             :         char *retstr;
    7998             : 
    7999           0 :         if (ndr_table_winreg.num_calls < 11) {
    8000           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_EnumValue_ndr_print");
    8001           0 :                 return NULL;
    8002             :         }
    8003           0 :         call = &ndr_table_winreg.calls[10];
    8004             : 
    8005           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    8006           0 :         ret = PyUnicode_FromString(retstr);
    8007           0 :         TALLOC_FREE(retstr);
    8008             : 
    8009           0 :         return ret;
    8010             : }
    8011             : 
    8012           0 : static PyObject *py_winreg_EnumValue_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    8013             : {
    8014           0 :         return py_winreg_EnumValue_ndr_print(py_obj, "winreg_EnumValue_in", NDR_IN);
    8015             : }
    8016             : 
    8017           0 : static PyObject *py_winreg_EnumValue_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    8018             : {
    8019           0 :         return py_winreg_EnumValue_ndr_print(py_obj, "winreg_EnumValue_out", NDR_OUT);
    8020             : }
    8021             : 
    8022             : static PyMethodDef py_winreg_EnumValue_methods[] = {
    8023             :         { "opnum", (PyCFunction)py_winreg_EnumValue_ndr_opnum, METH_NOARGS|METH_CLASS,
    8024             :                 "winreg.EnumValue.opnum() -> 10 (0x0a) " },
    8025             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumValue_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    8026             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    8027             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumValue_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    8028             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    8029             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumValue_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    8030             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    8031             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_EnumValue_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    8032             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    8033             :         { "__ndr_print_in__", (PyCFunction)py_winreg_EnumValue_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    8034             :         { "__ndr_print_out__", (PyCFunction)py_winreg_EnumValue_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    8035             :         { NULL, NULL, 0, NULL }
    8036             : };
    8037             : 
    8038             : 
    8039             : static PyTypeObject winreg_EnumValue_Type = {
    8040             :         PyVarObject_HEAD_INIT(NULL, 0)
    8041             :         .tp_name = "winreg.EnumValue",
    8042             :         .tp_getset = py_winreg_EnumValue_getsetters,
    8043             :         .tp_methods = py_winreg_EnumValue_methods,
    8044             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    8045             :         .tp_new = py_winreg_EnumValue_new,
    8046             : };
    8047             : 
    8048           0 : static bool pack_py_winreg_EnumValue_args_in(PyObject *args, PyObject *kwargs, struct winreg_EnumValue *r)
    8049             : {
    8050             :         PyObject *py_handle;
    8051             :         PyObject *py_enum_index;
    8052             :         PyObject *py_name;
    8053             :         PyObject *py_type;
    8054             :         PyObject *py_value;
    8055             :         PyObject *py_size;
    8056             :         PyObject *py_length;
    8057           0 :         const char *kwnames[] = {
    8058             :                 "handle", "enum_index", "name", "type", "value", "size", "length", NULL
    8059             :         };
    8060             : 
    8061           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOOOOOO:winreg_EnumValue", discard_const_p(char *, kwnames), &py_handle, &py_enum_index, &py_name, &py_type, &py_value, &py_size, &py_length)) {
    8062           0 :                 return false;
    8063             :         }
    8064             : 
    8065           0 :         if (py_handle == NULL) {
    8066           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    8067           0 :                 return false;
    8068             :         }
    8069           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    8070           0 :         if (r->in.handle == NULL) {
    8071           0 :                 PyErr_NoMemory();
    8072           0 :                 return false;
    8073             :         }
    8074           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    8075           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    8076           0 :                 PyErr_NoMemory();
    8077           0 :                 return false;
    8078             :         }
    8079           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    8080           0 :         if (py_enum_index == NULL) {
    8081           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.enum_index");
    8082           0 :                 return false;
    8083             :         }
    8084             :         {
    8085           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.enum_index));
    8086           0 :                 if (PyLong_Check(py_enum_index)) {
    8087             :                         unsigned long long test_var;
    8088           0 :                         test_var = PyLong_AsUnsignedLongLong(py_enum_index);
    8089           0 :                         if (PyErr_Occurred() != NULL) {
    8090           0 :                                 return false;
    8091             :                         }
    8092           0 :                         if (test_var > uint_max) {
    8093           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    8094             :                                   PyLong_Type.tp_name, uint_max, test_var);
    8095           0 :                                 return false;
    8096             :                         }
    8097           0 :                         r->in.enum_index = test_var;
    8098             :                 } else {
    8099           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    8100             :                           PyLong_Type.tp_name);
    8101           0 :                         return false;
    8102             :                 }
    8103             :         }
    8104           0 :         if (py_name == NULL) {
    8105           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.name");
    8106           0 :                 return false;
    8107             :         }
    8108           0 :         r->in.name = talloc_ptrtype(r, r->in.name);
    8109           0 :         if (r->in.name == NULL) {
    8110           0 :                 PyErr_NoMemory();
    8111           0 :                 return false;
    8112             :         }
    8113           0 :         PY_CHECK_TYPE(&winreg_ValNameBuf_Type, py_name, return false;);
    8114           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_name)) == NULL) {
    8115           0 :                 PyErr_NoMemory();
    8116           0 :                 return false;
    8117             :         }
    8118           0 :         r->in.name = (struct winreg_ValNameBuf *)pytalloc_get_ptr(py_name);
    8119           0 :         if (py_type == NULL) {
    8120           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.type");
    8121           0 :                 return false;
    8122             :         }
    8123           0 :         if (py_type == Py_None) {
    8124           0 :                 r->in.type = NULL;
    8125             :         } else {
    8126           0 :                 r->in.type = talloc_ptrtype(r, r->in.type);
    8127           0 :                 if (r->in.type == NULL) {
    8128           0 :                         PyErr_NoMemory();
    8129           0 :                         return false;
    8130             :                 }
    8131             :                 {
    8132           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.type));
    8133           0 :                         if (PyLong_Check(py_type)) {
    8134             :                                 unsigned long long test_var;
    8135           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_type);
    8136           0 :                                 if (PyErr_Occurred() != NULL) {
    8137           0 :                                         return false;
    8138             :                                 }
    8139           0 :                                 if (test_var > uint_max) {
    8140           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    8141             :                                           PyLong_Type.tp_name, uint_max, test_var);
    8142           0 :                                         return false;
    8143             :                                 }
    8144           0 :                                 *r->in.type = test_var;
    8145             :                         } else {
    8146           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    8147             :                                   PyLong_Type.tp_name);
    8148           0 :                                 return false;
    8149             :                         }
    8150             :                 }
    8151             :         }
    8152           0 :         if (py_value == NULL) {
    8153           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.value");
    8154           0 :                 return false;
    8155             :         }
    8156           0 :         if (py_value == Py_None) {
    8157           0 :                 r->in.value = NULL;
    8158             :         } else {
    8159           0 :                 r->in.value = NULL;
    8160           0 :                 PY_CHECK_TYPE(&PyList_Type, py_value, return false;);
    8161             :                 {
    8162             :                         int value_cntr_1;
    8163           0 :                         r->in.value = talloc_array_ptrtype(r, r->in.value, PyList_GET_SIZE(py_value));
    8164           0 :                         if (!r->in.value) { return false;; }
    8165           0 :                         talloc_set_name_const(r->in.value, "ARRAY: r->in.value");
    8166           0 :                         for (value_cntr_1 = 0; value_cntr_1 < PyList_GET_SIZE(py_value); value_cntr_1++) {
    8167           0 :                                 if (PyList_GET_ITEM(py_value, value_cntr_1) == NULL) {
    8168           0 :                                         PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.value[value_cntr_1]");
    8169           0 :                                         return false;
    8170             :                                 }
    8171             :                                 {
    8172           0 :                                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.value[value_cntr_1]));
    8173           0 :                                         if (PyLong_Check(PyList_GET_ITEM(py_value, value_cntr_1))) {
    8174             :                                                 unsigned long long test_var;
    8175           0 :                                                 test_var = PyLong_AsUnsignedLongLong(PyList_GET_ITEM(py_value, value_cntr_1));
    8176           0 :                                                 if (PyErr_Occurred() != NULL) {
    8177           0 :                                                         return false;
    8178             :                                                 }
    8179           0 :                                                 if (test_var > uint_max) {
    8180           0 :                                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    8181             :                                                           PyLong_Type.tp_name, uint_max, test_var);
    8182           0 :                                                         return false;
    8183             :                                                 }
    8184           0 :                                                 r->in.value[value_cntr_1] = test_var;
    8185             :                                         } else {
    8186           0 :                                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    8187             :                                                   PyLong_Type.tp_name);
    8188           0 :                                                 return false;
    8189             :                                         }
    8190             :                                 }
    8191             :                         }
    8192             :                 }
    8193             :         }
    8194           0 :         if (py_size == NULL) {
    8195           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.size");
    8196           0 :                 return false;
    8197             :         }
    8198           0 :         if (py_size == Py_None) {
    8199           0 :                 r->in.size = NULL;
    8200             :         } else {
    8201           0 :                 r->in.size = talloc_ptrtype(r, r->in.size);
    8202           0 :                 if (r->in.size == NULL) {
    8203           0 :                         PyErr_NoMemory();
    8204           0 :                         return false;
    8205             :                 }
    8206             :                 {
    8207           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.size));
    8208           0 :                         if (PyLong_Check(py_size)) {
    8209             :                                 unsigned long long test_var;
    8210           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_size);
    8211           0 :                                 if (PyErr_Occurred() != NULL) {
    8212           0 :                                         return false;
    8213             :                                 }
    8214           0 :                                 if (test_var > uint_max) {
    8215           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    8216             :                                           PyLong_Type.tp_name, uint_max, test_var);
    8217           0 :                                         return false;
    8218             :                                 }
    8219           0 :                                 *r->in.size = test_var;
    8220             :                         } else {
    8221           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    8222             :                                   PyLong_Type.tp_name);
    8223           0 :                                 return false;
    8224             :                         }
    8225             :                 }
    8226             :         }
    8227           0 :         if (py_length == NULL) {
    8228           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.length");
    8229           0 :                 return false;
    8230             :         }
    8231           0 :         if (py_length == Py_None) {
    8232           0 :                 r->in.length = NULL;
    8233             :         } else {
    8234           0 :                 r->in.length = talloc_ptrtype(r, r->in.length);
    8235           0 :                 if (r->in.length == NULL) {
    8236           0 :                         PyErr_NoMemory();
    8237           0 :                         return false;
    8238             :                 }
    8239             :                 {
    8240           0 :                         const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(*r->in.length));
    8241           0 :                         if (PyLong_Check(py_length)) {
    8242             :                                 unsigned long long test_var;
    8243           0 :                                 test_var = PyLong_AsUnsignedLongLong(py_length);
    8244           0 :                                 if (PyErr_Occurred() != NULL) {
    8245           0 :                                         return false;
    8246             :                                 }
    8247           0 :                                 if (test_var > uint_max) {
    8248           0 :                                         PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    8249             :                                           PyLong_Type.tp_name, uint_max, test_var);
    8250           0 :                                         return false;
    8251             :                                 }
    8252           0 :                                 *r->in.length = test_var;
    8253             :                         } else {
    8254           0 :                                 PyErr_Format(PyExc_TypeError, "Expected type %s",\
    8255             :                                   PyLong_Type.tp_name);
    8256           0 :                                 return false;
    8257             :                         }
    8258             :                 }
    8259             :         }
    8260           0 :         return true;
    8261             : }
    8262             : 
    8263           0 : static PyObject *unpack_py_winreg_EnumValue_args_out(struct winreg_EnumValue *r)
    8264             : {
    8265             :         PyObject *result;
    8266             :         PyObject *py_name;
    8267             :         PyObject *py_type;
    8268             :         PyObject *py_value;
    8269             :         PyObject *py_size;
    8270             :         PyObject *py_length;
    8271           0 :         result = PyTuple_New(5);
    8272           0 :         py_name = pytalloc_reference_ex(&winreg_ValNameBuf_Type, r->out.name, r->out.name);
    8273           0 :         PyTuple_SetItem(result, 0, py_name);
    8274           0 :         if (r->out.type == NULL) {
    8275           0 :                 py_type = Py_None;
    8276           0 :                 Py_INCREF(py_type);
    8277             :         } else {
    8278           0 :                 py_type = PyLong_FromUnsignedLongLong((uint32_t)*r->out.type);
    8279             :         }
    8280           0 :         PyTuple_SetItem(result, 1, py_type);
    8281           0 :         if (r->out.value == NULL) {
    8282           0 :                 py_value = Py_None;
    8283           0 :                 Py_INCREF(py_value);
    8284             :         } else {
    8285           0 :                 py_value = PyList_New(r->out.length?*r->out.length:0);
    8286           0 :                 if (py_value == NULL) {
    8287           0 :                         return NULL;
    8288             :                 }
    8289             :                 {
    8290             :                         int value_cntr_1;
    8291           0 :                         for (value_cntr_1 = 0; value_cntr_1 < (r->out.length?*r->out.length:0); value_cntr_1++) {
    8292             :                                 PyObject *py_value_1;
    8293           0 :                                 py_value_1 = PyLong_FromLong((uint16_t)r->out.value[value_cntr_1]);
    8294           0 :                                 PyList_SetItem(py_value, value_cntr_1, py_value_1);
    8295             :                         }
    8296             :                 }
    8297             :         }
    8298           0 :         PyTuple_SetItem(result, 2, py_value);
    8299           0 :         if (r->out.size == NULL) {
    8300           0 :                 py_size = Py_None;
    8301           0 :                 Py_INCREF(py_size);
    8302             :         } else {
    8303           0 :                 py_size = PyLong_FromUnsignedLongLong((uint32_t)*r->out.size);
    8304             :         }
    8305           0 :         PyTuple_SetItem(result, 3, py_size);
    8306           0 :         if (r->out.length == NULL) {
    8307           0 :                 py_length = Py_None;
    8308           0 :                 Py_INCREF(py_length);
    8309             :         } else {
    8310           0 :                 py_length = PyLong_FromUnsignedLongLong((uint32_t)*r->out.length);
    8311             :         }
    8312           0 :         PyTuple_SetItem(result, 4, py_length);
    8313           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    8314           0 :                 PyErr_SetWERROR(r->out.result);
    8315           0 :                 return NULL;
    8316             :         }
    8317             : 
    8318           0 :         return result;
    8319             : }
    8320             : 
    8321             : 
    8322           0 : static PyObject *py_winreg_FlushKey_in_get_handle(PyObject *obj, void *closure)
    8323             : {
    8324           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(obj);
    8325             :         PyObject *py_handle;
    8326           0 :         if (object->in.handle == NULL) {
    8327           0 :                 Py_RETURN_NONE;
    8328             :         }
    8329           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    8330           0 :         return py_handle;
    8331             : }
    8332             : 
    8333           0 : static int py_winreg_FlushKey_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    8334             : {
    8335           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(py_obj);
    8336           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    8337           0 :         if (value == NULL) {
    8338           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    8339           0 :                 return -1;
    8340             :         }
    8341           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    8342           0 :         if (object->in.handle == NULL) {
    8343           0 :                 PyErr_NoMemory();
    8344           0 :                 return -1;
    8345             :         }
    8346           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    8347           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    8348           0 :                 PyErr_NoMemory();
    8349           0 :                 return -1;
    8350             :         }
    8351           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    8352           0 :         return 0;
    8353             : }
    8354             : 
    8355           0 : static PyObject *py_winreg_FlushKey_get_result(PyObject *obj, void *closure)
    8356             : {
    8357           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(obj);
    8358             :         PyObject *py_result;
    8359           0 :         py_result = PyErr_FromWERROR(object->out.result);
    8360           0 :         return py_result;
    8361             : }
    8362             : 
    8363           0 : static int py_winreg_FlushKey_set_result(PyObject *py_obj, PyObject *value, void *closure)
    8364             : {
    8365           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(py_obj);
    8366           0 :         if (value == NULL) {
    8367           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    8368           0 :                 return -1;
    8369             :         }
    8370           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    8371           0 :         return 0;
    8372             : }
    8373             : 
    8374             : static PyGetSetDef py_winreg_FlushKey_getsetters[] = {
    8375             :         {
    8376             :                 .name = discard_const_p(char, "in_handle"),
    8377             :                 .get = py_winreg_FlushKey_in_get_handle,
    8378             :                 .set = py_winreg_FlushKey_in_set_handle,
    8379             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    8380             :         },
    8381             :         {
    8382             :                 .name = discard_const_p(char, "result"),
    8383             :                 .get = py_winreg_FlushKey_get_result,
    8384             :                 .set = py_winreg_FlushKey_set_result,
    8385             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    8386             :         },
    8387             :         { .name = NULL }
    8388             : };
    8389             : 
    8390           0 : static PyObject *py_winreg_FlushKey_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    8391             : {
    8392           0 :         PyObject *self = pytalloc_new(struct winreg_FlushKey, type);
    8393           0 :         struct winreg_FlushKey *_self = (struct winreg_FlushKey *)pytalloc_get_ptr(self);
    8394           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    8395           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    8396           0 :         return self;
    8397             : }
    8398             : 
    8399           0 : static PyObject *py_winreg_FlushKey_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    8400             : {
    8401             : 
    8402             : 
    8403           0 :         return PyLong_FromLong(11);
    8404             : }
    8405             : 
    8406           0 : static PyObject *py_winreg_FlushKey_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    8407             : {
    8408           0 :         const struct ndr_interface_call *call = NULL;
    8409           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(py_obj);
    8410           0 :         PyObject *ret = NULL;
    8411           0 :         struct ndr_push *push = NULL;
    8412             :         DATA_BLOB blob;
    8413             :         enum ndr_err_code err;
    8414             : 
    8415           0 :         if (ndr_table_winreg.num_calls < 12) {
    8416           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_FlushKey_ndr_pack");
    8417           0 :                 return NULL;
    8418             :         }
    8419           0 :         call = &ndr_table_winreg.calls[11];
    8420             : 
    8421           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    8422           0 :         if (push == NULL) {
    8423           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    8424           0 :                 return NULL;
    8425             :         }
    8426             : 
    8427           0 :         push->flags |= ndr_push_flags;
    8428             : 
    8429           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    8430           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    8431           0 :                 TALLOC_FREE(push);
    8432           0 :                 PyErr_SetNdrError(err);
    8433           0 :                 return NULL;
    8434             :         }
    8435           0 :         blob = ndr_push_blob(push);
    8436           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    8437           0 :         TALLOC_FREE(push);
    8438           0 :         return ret;
    8439             : }
    8440             : 
    8441           0 : static PyObject *py_winreg_FlushKey_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    8442             : {
    8443           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    8444           0 :         PyObject *bigendian_obj = NULL;
    8445           0 :         PyObject *ndr64_obj = NULL;
    8446           0 :         uint32_t ndr_push_flags = 0;
    8447             : 
    8448           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    8449             :                 discard_const_p(char *, kwnames),
    8450             :                 &bigendian_obj,
    8451             :                 &ndr64_obj)) {
    8452           0 :                 return NULL;
    8453             :         }
    8454             : 
    8455           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    8456           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    8457             :         }
    8458           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    8459           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    8460             :         }
    8461             : 
    8462           0 :         return py_winreg_FlushKey_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    8463             : }
    8464             : 
    8465           0 : static PyObject *py_winreg_FlushKey_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    8466             : {
    8467           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    8468           0 :         PyObject *bigendian_obj = NULL;
    8469           0 :         PyObject *ndr64_obj = NULL;
    8470           0 :         uint32_t ndr_push_flags = 0;
    8471             : 
    8472           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    8473             :                 discard_const_p(char *, kwnames),
    8474             :                 &bigendian_obj,
    8475             :                 &ndr64_obj)) {
    8476           0 :                 return NULL;
    8477             :         }
    8478             : 
    8479           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    8480           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    8481             :         }
    8482           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    8483           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    8484             :         }
    8485             : 
    8486           0 :         return py_winreg_FlushKey_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    8487             : }
    8488             : 
    8489           0 : static PyObject *py_winreg_FlushKey_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    8490             : {
    8491           0 :         const struct ndr_interface_call *call = NULL;
    8492           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(py_obj);
    8493           0 :         struct ndr_pull *pull = NULL;
    8494             :         enum ndr_err_code err;
    8495             : 
    8496           0 :         if (ndr_table_winreg.num_calls < 12) {
    8497           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_FlushKey_ndr_unpack");
    8498           0 :                 return NULL;
    8499             :         }
    8500           0 :         call = &ndr_table_winreg.calls[11];
    8501             : 
    8502           0 :         pull = ndr_pull_init_blob(blob, object);
    8503           0 :         if (pull == NULL) {
    8504           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    8505           0 :                 return NULL;
    8506             :         }
    8507             : 
    8508           0 :         pull->flags |= ndr_pull_flags;
    8509             : 
    8510           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    8511           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    8512           0 :                 TALLOC_FREE(pull);
    8513           0 :                 PyErr_SetNdrError(err);
    8514           0 :                 return NULL;
    8515             :         }
    8516           0 :         if (!allow_remaining) {
    8517             :                 uint32_t highest_ofs;
    8518             : 
    8519           0 :                 if (pull->offset > pull->relative_highest_offset) {
    8520           0 :                         highest_ofs = pull->offset;
    8521             :                 } else {
    8522           0 :                         highest_ofs = pull->relative_highest_offset;
    8523             :                 }
    8524           0 :                 if (highest_ofs < pull->data_size) {
    8525           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    8526             :                                 "not all bytes consumed ofs[%u] size[%u]",
    8527             :                                 highest_ofs, pull->data_size);
    8528           0 :                         TALLOC_FREE(pull);
    8529           0 :                         PyErr_SetNdrError(err);
    8530           0 :                         return NULL;
    8531             :                 }
    8532             :         }
    8533             : 
    8534           0 :         TALLOC_FREE(pull);
    8535           0 :         Py_RETURN_NONE;
    8536             : }
    8537             : 
    8538           0 : static PyObject *py_winreg_FlushKey_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    8539             : {
    8540             :         DATA_BLOB blob;
    8541           0 :         Py_ssize_t blob_length = 0;
    8542           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    8543           0 :         PyObject *bigendian_obj = NULL;
    8544           0 :         PyObject *ndr64_obj = NULL;
    8545           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    8546           0 :         PyObject *allow_remaining_obj = NULL;
    8547           0 :         bool allow_remaining = false;
    8548             : 
    8549           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    8550             :                 discard_const_p(char *, kwnames),
    8551             :                 &blob.data, &blob_length,
    8552             :                 &bigendian_obj,
    8553             :                 &ndr64_obj,
    8554             :                 &allow_remaining_obj)) {
    8555           0 :                 return NULL;
    8556             :         }
    8557           0 :         blob.length = blob_length;
    8558             : 
    8559           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    8560           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    8561             :         }
    8562           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    8563           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    8564             :         }
    8565             : 
    8566           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    8567           0 :                 allow_remaining = true;
    8568             :         }
    8569             : 
    8570           0 :         return py_winreg_FlushKey_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    8571             : }
    8572             : 
    8573           0 : static PyObject *py_winreg_FlushKey_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    8574             : {
    8575             :         DATA_BLOB blob;
    8576           0 :         Py_ssize_t blob_length = 0;
    8577           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    8578           0 :         PyObject *bigendian_obj = NULL;
    8579           0 :         PyObject *ndr64_obj = NULL;
    8580           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    8581           0 :         PyObject *allow_remaining_obj = NULL;
    8582           0 :         bool allow_remaining = false;
    8583             : 
    8584           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    8585             :                 discard_const_p(char *, kwnames),
    8586             :                 &blob.data, &blob_length,
    8587             :                 &bigendian_obj,
    8588             :                 &ndr64_obj,
    8589             :                 &allow_remaining_obj)) {
    8590           0 :                 return NULL;
    8591             :         }
    8592           0 :         blob.length = blob_length;
    8593             : 
    8594           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    8595           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    8596             :         }
    8597           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    8598           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    8599             :         }
    8600             : 
    8601           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    8602           0 :                 allow_remaining = true;
    8603             :         }
    8604             : 
    8605           0 :         return py_winreg_FlushKey_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    8606             : }
    8607             : 
    8608           0 : static PyObject *py_winreg_FlushKey_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    8609             : {
    8610           0 :         const struct ndr_interface_call *call = NULL;
    8611           0 :         struct winreg_FlushKey *object = (struct winreg_FlushKey *)pytalloc_get_ptr(py_obj);
    8612             :         PyObject *ret;
    8613             :         char *retstr;
    8614             : 
    8615           0 :         if (ndr_table_winreg.num_calls < 12) {
    8616           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_FlushKey_ndr_print");
    8617           0 :                 return NULL;
    8618             :         }
    8619           0 :         call = &ndr_table_winreg.calls[11];
    8620             : 
    8621           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    8622           0 :         ret = PyUnicode_FromString(retstr);
    8623           0 :         TALLOC_FREE(retstr);
    8624             : 
    8625           0 :         return ret;
    8626             : }
    8627             : 
    8628           0 : static PyObject *py_winreg_FlushKey_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    8629             : {
    8630           0 :         return py_winreg_FlushKey_ndr_print(py_obj, "winreg_FlushKey_in", NDR_IN);
    8631             : }
    8632             : 
    8633           0 : static PyObject *py_winreg_FlushKey_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    8634             : {
    8635           0 :         return py_winreg_FlushKey_ndr_print(py_obj, "winreg_FlushKey_out", NDR_OUT);
    8636             : }
    8637             : 
    8638             : static PyMethodDef py_winreg_FlushKey_methods[] = {
    8639             :         { "opnum", (PyCFunction)py_winreg_FlushKey_ndr_opnum, METH_NOARGS|METH_CLASS,
    8640             :                 "winreg.FlushKey.opnum() -> 11 (0x0b) " },
    8641             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_FlushKey_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    8642             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    8643             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_FlushKey_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    8644             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    8645             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_FlushKey_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    8646             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    8647             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_FlushKey_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    8648             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    8649             :         { "__ndr_print_in__", (PyCFunction)py_winreg_FlushKey_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    8650             :         { "__ndr_print_out__", (PyCFunction)py_winreg_FlushKey_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    8651             :         { NULL, NULL, 0, NULL }
    8652             : };
    8653             : 
    8654             : 
    8655             : static PyTypeObject winreg_FlushKey_Type = {
    8656             :         PyVarObject_HEAD_INIT(NULL, 0)
    8657             :         .tp_name = "winreg.FlushKey",
    8658             :         .tp_getset = py_winreg_FlushKey_getsetters,
    8659             :         .tp_methods = py_winreg_FlushKey_methods,
    8660             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    8661             :         .tp_new = py_winreg_FlushKey_new,
    8662             : };
    8663             : 
    8664           0 : static bool pack_py_winreg_FlushKey_args_in(PyObject *args, PyObject *kwargs, struct winreg_FlushKey *r)
    8665             : {
    8666             :         PyObject *py_handle;
    8667           0 :         const char *kwnames[] = {
    8668             :                 "handle", NULL
    8669             :         };
    8670             : 
    8671           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:winreg_FlushKey", discard_const_p(char *, kwnames), &py_handle)) {
    8672           0 :                 return false;
    8673             :         }
    8674             : 
    8675           0 :         if (py_handle == NULL) {
    8676           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    8677           0 :                 return false;
    8678             :         }
    8679           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    8680           0 :         if (r->in.handle == NULL) {
    8681           0 :                 PyErr_NoMemory();
    8682           0 :                 return false;
    8683             :         }
    8684           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    8685           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    8686           0 :                 PyErr_NoMemory();
    8687           0 :                 return false;
    8688             :         }
    8689           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    8690           0 :         return true;
    8691             : }
    8692             : 
    8693           0 : static PyObject *unpack_py_winreg_FlushKey_args_out(struct winreg_FlushKey *r)
    8694             : {
    8695             :         PyObject *result;
    8696           0 :         result = Py_None;
    8697           0 :         Py_INCREF(result);
    8698           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    8699           0 :                 PyErr_SetWERROR(r->out.result);
    8700           0 :                 return NULL;
    8701             :         }
    8702             : 
    8703           0 :         return result;
    8704             : }
    8705             : 
    8706             : 
    8707           0 : static PyObject *py_winreg_GetKeySecurity_in_get_handle(PyObject *obj, void *closure)
    8708             : {
    8709           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(obj);
    8710             :         PyObject *py_handle;
    8711           0 :         if (object->in.handle == NULL) {
    8712           0 :                 Py_RETURN_NONE;
    8713             :         }
    8714           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    8715           0 :         return py_handle;
    8716             : }
    8717             : 
    8718           0 : static int py_winreg_GetKeySecurity_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    8719             : {
    8720           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    8721           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    8722           0 :         if (value == NULL) {
    8723           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    8724           0 :                 return -1;
    8725             :         }
    8726           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    8727           0 :         if (object->in.handle == NULL) {
    8728           0 :                 PyErr_NoMemory();
    8729           0 :                 return -1;
    8730             :         }
    8731           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    8732           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    8733           0 :                 PyErr_NoMemory();
    8734           0 :                 return -1;
    8735             :         }
    8736           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    8737           0 :         return 0;
    8738             : }
    8739             : 
    8740           0 : static PyObject *py_winreg_GetKeySecurity_in_get_sec_info(PyObject *obj, void *closure)
    8741             : {
    8742           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(obj);
    8743             :         PyObject *py_sec_info;
    8744           0 :         py_sec_info = PyLong_FromUnsignedLongLong((uint32_t)object->in.sec_info);
    8745           0 :         return py_sec_info;
    8746             : }
    8747             : 
    8748           0 : static int py_winreg_GetKeySecurity_in_set_sec_info(PyObject *py_obj, PyObject *value, void *closure)
    8749             : {
    8750           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    8751           0 :         if (value == NULL) {
    8752           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.sec_info");
    8753           0 :                 return -1;
    8754             :         }
    8755             :         {
    8756           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(object->in.sec_info));
    8757           0 :                 if (PyLong_Check(value)) {
    8758             :                         unsigned long long test_var;
    8759           0 :                         test_var = PyLong_AsUnsignedLongLong(value);
    8760           0 :                         if (PyErr_Occurred() != NULL) {
    8761           0 :                                 return -1;
    8762             :                         }
    8763           0 :                         if (test_var > uint_max) {
    8764           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    8765             :                                   PyLong_Type.tp_name, uint_max, test_var);
    8766           0 :                                 return -1;
    8767             :                         }
    8768           0 :                         object->in.sec_info = test_var;
    8769             :                 } else {
    8770           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    8771             :                           PyLong_Type.tp_name);
    8772           0 :                         return -1;
    8773             :                 }
    8774             :         }
    8775           0 :         return 0;
    8776             : }
    8777             : 
    8778           0 : static PyObject *py_winreg_GetKeySecurity_in_get_sd(PyObject *obj, void *closure)
    8779             : {
    8780           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(obj);
    8781             :         PyObject *py_sd;
    8782           0 :         if (object->in.sd == NULL) {
    8783           0 :                 Py_RETURN_NONE;
    8784             :         }
    8785           0 :         py_sd = pytalloc_reference_ex(&KeySecurityData_Type, object->in.sd, object->in.sd);
    8786           0 :         return py_sd;
    8787             : }
    8788             : 
    8789           0 : static int py_winreg_GetKeySecurity_in_set_sd(PyObject *py_obj, PyObject *value, void *closure)
    8790             : {
    8791           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    8792           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.sd));
    8793           0 :         if (value == NULL) {
    8794           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.sd");
    8795           0 :                 return -1;
    8796             :         }
    8797           0 :         object->in.sd = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.sd);
    8798           0 :         if (object->in.sd == NULL) {
    8799           0 :                 PyErr_NoMemory();
    8800           0 :                 return -1;
    8801             :         }
    8802           0 :         PY_CHECK_TYPE(&KeySecurityData_Type, value, return -1;);
    8803           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    8804           0 :                 PyErr_NoMemory();
    8805           0 :                 return -1;
    8806             :         }
    8807           0 :         object->in.sd = (struct KeySecurityData *)pytalloc_get_ptr(value);
    8808           0 :         return 0;
    8809             : }
    8810             : 
    8811           0 : static PyObject *py_winreg_GetKeySecurity_out_get_sd(PyObject *obj, void *closure)
    8812             : {
    8813           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(obj);
    8814             :         PyObject *py_sd;
    8815           0 :         if (object->out.sd == NULL) {
    8816           0 :                 Py_RETURN_NONE;
    8817             :         }
    8818           0 :         py_sd = pytalloc_reference_ex(&KeySecurityData_Type, object->out.sd, object->out.sd);
    8819           0 :         return py_sd;
    8820             : }
    8821             : 
    8822           0 : static int py_winreg_GetKeySecurity_out_set_sd(PyObject *py_obj, PyObject *value, void *closure)
    8823             : {
    8824           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    8825           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->out.sd));
    8826           0 :         if (value == NULL) {
    8827           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.sd");
    8828           0 :                 return -1;
    8829             :         }
    8830           0 :         object->out.sd = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->out.sd);
    8831           0 :         if (object->out.sd == NULL) {
    8832           0 :                 PyErr_NoMemory();
    8833           0 :                 return -1;
    8834             :         }
    8835           0 :         PY_CHECK_TYPE(&KeySecurityData_Type, value, return -1;);
    8836           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    8837           0 :                 PyErr_NoMemory();
    8838           0 :                 return -1;
    8839             :         }
    8840           0 :         object->out.sd = (struct KeySecurityData *)pytalloc_get_ptr(value);
    8841           0 :         return 0;
    8842             : }
    8843             : 
    8844           0 : static PyObject *py_winreg_GetKeySecurity_get_result(PyObject *obj, void *closure)
    8845             : {
    8846           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(obj);
    8847             :         PyObject *py_result;
    8848           0 :         py_result = PyErr_FromWERROR(object->out.result);
    8849           0 :         return py_result;
    8850             : }
    8851             : 
    8852           0 : static int py_winreg_GetKeySecurity_set_result(PyObject *py_obj, PyObject *value, void *closure)
    8853             : {
    8854           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    8855           0 :         if (value == NULL) {
    8856           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->out.result");
    8857           0 :                 return -1;
    8858             :         }
    8859           0 :         object->out.result = W_ERROR(PyLong_AsLong(value));
    8860           0 :         return 0;
    8861             : }
    8862             : 
    8863             : static PyGetSetDef py_winreg_GetKeySecurity_getsetters[] = {
    8864             :         {
    8865             :                 .name = discard_const_p(char, "in_handle"),
    8866             :                 .get = py_winreg_GetKeySecurity_in_get_handle,
    8867             :                 .set = py_winreg_GetKeySecurity_in_set_handle,
    8868             :                 .doc = discard_const_p(char, "PIDL-generated element of base type policy_handle")
    8869             :         },
    8870             :         {
    8871             :                 .name = discard_const_p(char, "in_sec_info"),
    8872             :                 .get = py_winreg_GetKeySecurity_in_get_sec_info,
    8873             :                 .set = py_winreg_GetKeySecurity_in_set_sec_info,
    8874             :                 .doc = discard_const_p(char, "PIDL-generated element of base type security_secinfo")
    8875             :         },
    8876             :         {
    8877             :                 .name = discard_const_p(char, "in_sd"),
    8878             :                 .get = py_winreg_GetKeySecurity_in_get_sd,
    8879             :                 .set = py_winreg_GetKeySecurity_in_set_sd,
    8880             :                 .doc = discard_const_p(char, "PIDL-generated element of base type KeySecurityData")
    8881             :         },
    8882             :         {
    8883             :                 .name = discard_const_p(char, "out_sd"),
    8884             :                 .get = py_winreg_GetKeySecurity_out_get_sd,
    8885             :                 .set = py_winreg_GetKeySecurity_out_set_sd,
    8886             :                 .doc = discard_const_p(char, "PIDL-generated element of base type KeySecurityData")
    8887             :         },
    8888             :         {
    8889             :                 .name = discard_const_p(char, "result"),
    8890             :                 .get = py_winreg_GetKeySecurity_get_result,
    8891             :                 .set = py_winreg_GetKeySecurity_set_result,
    8892             :                 .doc = discard_const_p(char, "PIDL-generated element of type WERROR")
    8893             :         },
    8894             :         { .name = NULL }
    8895             : };
    8896             : 
    8897           0 : static PyObject *py_winreg_GetKeySecurity_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
    8898             : {
    8899           0 :         PyObject *self = pytalloc_new(struct winreg_GetKeySecurity, type);
    8900           0 :         struct winreg_GetKeySecurity *_self = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(self);
    8901           0 :         TALLOC_CTX *mem_ctx = pytalloc_get_mem_ctx(self);
    8902           0 :         _self->in.handle = talloc_zero(mem_ctx, struct policy_handle);
    8903           0 :         _self->in.sd = talloc_zero(mem_ctx, struct KeySecurityData);
    8904           0 :         _self->out.sd = talloc_zero(mem_ctx, struct KeySecurityData);
    8905           0 :         return self;
    8906             : }
    8907             : 
    8908           0 : static PyObject *py_winreg_GetKeySecurity_ndr_opnum(PyTypeObject *type, PyObject *Py_UNUSED(ignored))
    8909             : {
    8910             : 
    8911             : 
    8912           0 :         return PyLong_FromLong(12);
    8913             : }
    8914             : 
    8915           0 : static PyObject *py_winreg_GetKeySecurity_ndr_pack(PyObject *py_obj, int ndr_inout_flags, uint32_t ndr_push_flags)
    8916             : {
    8917           0 :         const struct ndr_interface_call *call = NULL;
    8918           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    8919           0 :         PyObject *ret = NULL;
    8920           0 :         struct ndr_push *push = NULL;
    8921             :         DATA_BLOB blob;
    8922             :         enum ndr_err_code err;
    8923             : 
    8924           0 :         if (ndr_table_winreg.num_calls < 13) {
    8925           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_GetKeySecurity_ndr_pack");
    8926           0 :                 return NULL;
    8927             :         }
    8928           0 :         call = &ndr_table_winreg.calls[12];
    8929             : 
    8930           0 :         push = ndr_push_init_ctx(pytalloc_get_mem_ctx(py_obj));
    8931           0 :         if (push == NULL) {
    8932           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    8933           0 :                 return NULL;
    8934             :         }
    8935             : 
    8936           0 :         push->flags |= ndr_push_flags;
    8937             : 
    8938           0 :         err = call->ndr_push(push, ndr_inout_flags, object);
    8939           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    8940           0 :                 TALLOC_FREE(push);
    8941           0 :                 PyErr_SetNdrError(err);
    8942           0 :                 return NULL;
    8943             :         }
    8944           0 :         blob = ndr_push_blob(push);
    8945           0 :         ret = PyBytes_FromStringAndSize((char *)blob.data, blob.length);
    8946           0 :         TALLOC_FREE(push);
    8947           0 :         return ret;
    8948             : }
    8949             : 
    8950           0 : static PyObject *py_winreg_GetKeySecurity_ndr_pack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    8951             : {
    8952           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    8953           0 :         PyObject *bigendian_obj = NULL;
    8954           0 :         PyObject *ndr64_obj = NULL;
    8955           0 :         uint32_t ndr_push_flags = 0;
    8956             : 
    8957           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_in__",
    8958             :                 discard_const_p(char *, kwnames),
    8959             :                 &bigendian_obj,
    8960             :                 &ndr64_obj)) {
    8961           0 :                 return NULL;
    8962             :         }
    8963             : 
    8964           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    8965           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    8966             :         }
    8967           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    8968           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    8969             :         }
    8970             : 
    8971           0 :         return py_winreg_GetKeySecurity_ndr_pack(py_obj, NDR_IN, ndr_push_flags);
    8972             : }
    8973             : 
    8974           0 : static PyObject *py_winreg_GetKeySecurity_ndr_pack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    8975             : {
    8976           0 :         const char * const kwnames[] = { "bigendian", "ndr64", NULL };
    8977           0 :         PyObject *bigendian_obj = NULL;
    8978           0 :         PyObject *ndr64_obj = NULL;
    8979           0 :         uint32_t ndr_push_flags = 0;
    8980             : 
    8981           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "|OO:__ndr_pack_out__",
    8982             :                 discard_const_p(char *, kwnames),
    8983             :                 &bigendian_obj,
    8984             :                 &ndr64_obj)) {
    8985           0 :                 return NULL;
    8986             :         }
    8987             : 
    8988           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    8989           0 :                 ndr_push_flags |= LIBNDR_FLAG_BIGENDIAN;
    8990             :         }
    8991           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    8992           0 :                 ndr_push_flags |= LIBNDR_FLAG_NDR64;
    8993             :         }
    8994             : 
    8995           0 :         return py_winreg_GetKeySecurity_ndr_pack(py_obj, NDR_OUT, ndr_push_flags);
    8996             : }
    8997             : 
    8998           0 : static PyObject *py_winreg_GetKeySecurity_ndr_unpack(PyObject *py_obj, const DATA_BLOB *blob, int ndr_inout_flags, uint32_t ndr_pull_flags, bool allow_remaining)
    8999             : {
    9000           0 :         const struct ndr_interface_call *call = NULL;
    9001           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    9002           0 :         struct ndr_pull *pull = NULL;
    9003             :         enum ndr_err_code err;
    9004             : 
    9005           0 :         if (ndr_table_winreg.num_calls < 13) {
    9006           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_GetKeySecurity_ndr_unpack");
    9007           0 :                 return NULL;
    9008             :         }
    9009           0 :         call = &ndr_table_winreg.calls[12];
    9010             : 
    9011           0 :         pull = ndr_pull_init_blob(blob, object);
    9012           0 :         if (pull == NULL) {
    9013           0 :                 PyErr_SetNdrError(NDR_ERR_ALLOC);
    9014           0 :                 return NULL;
    9015             :         }
    9016             : 
    9017           0 :         pull->flags |= ndr_pull_flags;
    9018             : 
    9019           0 :         err = call->ndr_pull(pull, ndr_inout_flags, object);
    9020           0 :         if (!NDR_ERR_CODE_IS_SUCCESS(err)) {
    9021           0 :                 TALLOC_FREE(pull);
    9022           0 :                 PyErr_SetNdrError(err);
    9023           0 :                 return NULL;
    9024             :         }
    9025           0 :         if (!allow_remaining) {
    9026             :                 uint32_t highest_ofs;
    9027             : 
    9028           0 :                 if (pull->offset > pull->relative_highest_offset) {
    9029           0 :                         highest_ofs = pull->offset;
    9030             :                 } else {
    9031           0 :                         highest_ofs = pull->relative_highest_offset;
    9032             :                 }
    9033           0 :                 if (highest_ofs < pull->data_size) {
    9034           0 :                         err = ndr_pull_error(pull, NDR_ERR_UNREAD_BYTES,
    9035             :                                 "not all bytes consumed ofs[%u] size[%u]",
    9036             :                                 highest_ofs, pull->data_size);
    9037           0 :                         TALLOC_FREE(pull);
    9038           0 :                         PyErr_SetNdrError(err);
    9039           0 :                         return NULL;
    9040             :                 }
    9041             :         }
    9042             : 
    9043           0 :         TALLOC_FREE(pull);
    9044           0 :         Py_RETURN_NONE;
    9045             : }
    9046             : 
    9047           0 : static PyObject *py_winreg_GetKeySecurity_ndr_unpack_in(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    9048             : {
    9049             :         DATA_BLOB blob;
    9050           0 :         Py_ssize_t blob_length = 0;
    9051           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    9052           0 :         PyObject *bigendian_obj = NULL;
    9053           0 :         PyObject *ndr64_obj = NULL;
    9054           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    9055           0 :         PyObject *allow_remaining_obj = NULL;
    9056           0 :         bool allow_remaining = false;
    9057             : 
    9058           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_in__",
    9059             :                 discard_const_p(char *, kwnames),
    9060             :                 &blob.data, &blob_length,
    9061             :                 &bigendian_obj,
    9062             :                 &ndr64_obj,
    9063             :                 &allow_remaining_obj)) {
    9064           0 :                 return NULL;
    9065             :         }
    9066           0 :         blob.length = blob_length;
    9067             : 
    9068           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    9069           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    9070             :         }
    9071           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    9072           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    9073             :         }
    9074             : 
    9075           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    9076           0 :                 allow_remaining = true;
    9077             :         }
    9078             : 
    9079           0 :         return py_winreg_GetKeySecurity_ndr_unpack(py_obj, &blob, NDR_IN, ndr_pull_flags, allow_remaining);
    9080             : }
    9081             : 
    9082           0 : static PyObject *py_winreg_GetKeySecurity_ndr_unpack_out(PyObject *py_obj, PyObject *args, PyObject *kwargs)
    9083             : {
    9084             :         DATA_BLOB blob;
    9085           0 :         Py_ssize_t blob_length = 0;
    9086           0 :         const char * const kwnames[] = { "data_blob", "bigendian", "ndr64", "allow_remaining", NULL };
    9087           0 :         PyObject *bigendian_obj = NULL;
    9088           0 :         PyObject *ndr64_obj = NULL;
    9089           0 :         uint32_t ndr_pull_flags = LIBNDR_FLAG_REF_ALLOC;
    9090           0 :         PyObject *allow_remaining_obj = NULL;
    9091           0 :         bool allow_remaining = false;
    9092             : 
    9093           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, PYARG_BYTES_LEN "|OOO:__ndr_unpack_out__",
    9094             :                 discard_const_p(char *, kwnames),
    9095             :                 &blob.data, &blob_length,
    9096             :                 &bigendian_obj,
    9097             :                 &ndr64_obj,
    9098             :                 &allow_remaining_obj)) {
    9099           0 :                 return NULL;
    9100             :         }
    9101           0 :         blob.length = blob_length;
    9102             : 
    9103           0 :         if (bigendian_obj && PyObject_IsTrue(bigendian_obj)) {
    9104           0 :                 ndr_pull_flags |= LIBNDR_FLAG_BIGENDIAN;
    9105             :         }
    9106           0 :         if (ndr64_obj && PyObject_IsTrue(ndr64_obj)) {
    9107           0 :                 ndr_pull_flags |= LIBNDR_FLAG_NDR64;
    9108             :         }
    9109             : 
    9110           0 :         if (allow_remaining_obj && PyObject_IsTrue(allow_remaining_obj)) {
    9111           0 :                 allow_remaining = true;
    9112             :         }
    9113             : 
    9114           0 :         return py_winreg_GetKeySecurity_ndr_unpack(py_obj, &blob, NDR_OUT, ndr_pull_flags, allow_remaining);
    9115             : }
    9116             : 
    9117           0 : static PyObject *py_winreg_GetKeySecurity_ndr_print(PyObject *py_obj, const char *name, int ndr_inout_flags)
    9118             : {
    9119           0 :         const struct ndr_interface_call *call = NULL;
    9120           0 :         struct winreg_GetKeySecurity *object = (struct winreg_GetKeySecurity *)pytalloc_get_ptr(py_obj);
    9121             :         PyObject *ret;
    9122             :         char *retstr;
    9123             : 
    9124           0 :         if (ndr_table_winreg.num_calls < 13) {
    9125           0 :                 PyErr_SetString(PyExc_TypeError, "Internal Error, ndr_interface_call missing for py_winreg_GetKeySecurity_ndr_print");
    9126           0 :                 return NULL;
    9127             :         }
    9128           0 :         call = &ndr_table_winreg.calls[12];
    9129             : 
    9130           0 :         retstr = ndr_print_function_string(pytalloc_get_mem_ctx(py_obj), call->ndr_print, name, ndr_inout_flags, object);
    9131           0 :         ret = PyUnicode_FromString(retstr);
    9132           0 :         TALLOC_FREE(retstr);
    9133             : 
    9134           0 :         return ret;
    9135             : }
    9136             : 
    9137           0 : static PyObject *py_winreg_GetKeySecurity_ndr_print_in(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    9138             : {
    9139           0 :         return py_winreg_GetKeySecurity_ndr_print(py_obj, "winreg_GetKeySecurity_in", NDR_IN);
    9140             : }
    9141             : 
    9142           0 : static PyObject *py_winreg_GetKeySecurity_ndr_print_out(PyObject *py_obj, PyObject *Py_UNUSED(ignored))
    9143             : {
    9144           0 :         return py_winreg_GetKeySecurity_ndr_print(py_obj, "winreg_GetKeySecurity_out", NDR_OUT);
    9145             : }
    9146             : 
    9147             : static PyMethodDef py_winreg_GetKeySecurity_methods[] = {
    9148             :         { "opnum", (PyCFunction)py_winreg_GetKeySecurity_ndr_opnum, METH_NOARGS|METH_CLASS,
    9149             :                 "winreg.GetKeySecurity.opnum() -> 12 (0x0c) " },
    9150             :         { "__ndr_pack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_GetKeySecurity_ndr_pack_in), METH_VARARGS|METH_KEYWORDS,
    9151             :                 "S.ndr_pack_in(object, bigendian=False, ndr64=False) -> blob\nNDR pack input" },
    9152             :         { "__ndr_pack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_GetKeySecurity_ndr_pack_out), METH_VARARGS|METH_KEYWORDS,
    9153             :                 "S.ndr_pack_out(object, bigendian=False, ndr64=False) -> blob\nNDR pack output" },
    9154             :         { "__ndr_unpack_in__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_GetKeySecurity_ndr_unpack_in), METH_VARARGS|METH_KEYWORDS,
    9155             :                 "S.ndr_unpack_in(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack input" },
    9156             :         { "__ndr_unpack_out__", PY_DISCARD_FUNC_SIG(PyCFunction,py_winreg_GetKeySecurity_ndr_unpack_out), METH_VARARGS|METH_KEYWORDS,
    9157             :                 "S.ndr_unpack_out(class, blob, bigendian=False, ndr64=False, allow_remaining=False) -> None\nNDR unpack output" },
    9158             :         { "__ndr_print_in__", (PyCFunction)py_winreg_GetKeySecurity_ndr_print_in, METH_NOARGS, "S.ndr_print_in(object) -> None\nNDR print input" },
    9159             :         { "__ndr_print_out__", (PyCFunction)py_winreg_GetKeySecurity_ndr_print_out, METH_NOARGS, "S.ndr_print_out(object) -> None\nNDR print output" },
    9160             :         { NULL, NULL, 0, NULL }
    9161             : };
    9162             : 
    9163             : 
    9164             : static PyTypeObject winreg_GetKeySecurity_Type = {
    9165             :         PyVarObject_HEAD_INIT(NULL, 0)
    9166             :         .tp_name = "winreg.GetKeySecurity",
    9167             :         .tp_getset = py_winreg_GetKeySecurity_getsetters,
    9168             :         .tp_methods = py_winreg_GetKeySecurity_methods,
    9169             :         .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
    9170             :         .tp_new = py_winreg_GetKeySecurity_new,
    9171             : };
    9172             : 
    9173           0 : static bool pack_py_winreg_GetKeySecurity_args_in(PyObject *args, PyObject *kwargs, struct winreg_GetKeySecurity *r)
    9174             : {
    9175             :         PyObject *py_handle;
    9176             :         PyObject *py_sec_info;
    9177             :         PyObject *py_sd;
    9178           0 :         const char *kwnames[] = {
    9179             :                 "handle", "sec_info", "sd", NULL
    9180             :         };
    9181             : 
    9182           0 :         if (!PyArg_ParseTupleAndKeywords(args, kwargs, "OOO:winreg_GetKeySecurity", discard_const_p(char *, kwnames), &py_handle, &py_sec_info, &py_sd)) {
    9183           0 :                 return false;
    9184             :         }
    9185             : 
    9186           0 :         if (py_handle == NULL) {
    9187           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.handle");
    9188           0 :                 return false;
    9189             :         }
    9190           0 :         r->in.handle = talloc_ptrtype(r, r->in.handle);
    9191           0 :         if (r->in.handle == NULL) {
    9192           0 :                 PyErr_NoMemory();
    9193           0 :                 return false;
    9194             :         }
    9195           0 :         PY_CHECK_TYPE(policy_handle_Type, py_handle, return false;);
    9196           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_handle)) == NULL) {
    9197           0 :                 PyErr_NoMemory();
    9198           0 :                 return false;
    9199             :         }
    9200           0 :         r->in.handle = (struct policy_handle *)pytalloc_get_ptr(py_handle);
    9201           0 :         if (py_sec_info == NULL) {
    9202           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.sec_info");
    9203           0 :                 return false;
    9204             :         }
    9205             :         {
    9206           0 :                 const unsigned long long uint_max = ndr_sizeof2uintmax(sizeof(r->in.sec_info));
    9207           0 :                 if (PyLong_Check(py_sec_info)) {
    9208             :                         unsigned long long test_var;
    9209           0 :                         test_var = PyLong_AsUnsignedLongLong(py_sec_info);
    9210           0 :                         if (PyErr_Occurred() != NULL) {
    9211           0 :                                 return false;
    9212             :                         }
    9213           0 :                         if (test_var > uint_max) {
    9214           0 :                                 PyErr_Format(PyExc_OverflowError, "Expected type %s within range 0 - %llu, got %llu",\
    9215             :                                   PyLong_Type.tp_name, uint_max, test_var);
    9216           0 :                                 return false;
    9217             :                         }
    9218           0 :                         r->in.sec_info = test_var;
    9219             :                 } else {
    9220           0 :                         PyErr_Format(PyExc_TypeError, "Expected type %s",\
    9221             :                           PyLong_Type.tp_name);
    9222           0 :                         return false;
    9223             :                 }
    9224             :         }
    9225           0 :         if (py_sd == NULL) {
    9226           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct r->in.sd");
    9227           0 :                 return false;
    9228             :         }
    9229           0 :         r->in.sd = talloc_ptrtype(r, r->in.sd);
    9230           0 :         if (r->in.sd == NULL) {
    9231           0 :                 PyErr_NoMemory();
    9232           0 :                 return false;
    9233             :         }
    9234           0 :         PY_CHECK_TYPE(&KeySecurityData_Type, py_sd, return false;);
    9235           0 :         if (talloc_reference(r, pytalloc_get_mem_ctx(py_sd)) == NULL) {
    9236           0 :                 PyErr_NoMemory();
    9237           0 :                 return false;
    9238             :         }
    9239           0 :         r->in.sd = (struct KeySecurityData *)pytalloc_get_ptr(py_sd);
    9240           0 :         return true;
    9241             : }
    9242             : 
    9243           0 : static PyObject *unpack_py_winreg_GetKeySecurity_args_out(struct winreg_GetKeySecurity *r)
    9244             : {
    9245             :         PyObject *result;
    9246             :         PyObject *py_sd;
    9247           0 :         py_sd = pytalloc_reference_ex(&KeySecurityData_Type, r->out.sd, r->out.sd);
    9248           0 :         result = py_sd;
    9249           0 :         if (!W_ERROR_IS_OK(r->out.result)) {
    9250           0 :                 PyErr_SetWERROR(r->out.result);
    9251           0 :                 return NULL;
    9252             :         }
    9253             : 
    9254           0 :         return result;
    9255             : }
    9256             : 
    9257             : 
    9258           0 : static PyObject *py_winreg_LoadKey_in_get_handle(PyObject *obj, void *closure)
    9259             : {
    9260           0 :         struct winreg_LoadKey *object = (struct winreg_LoadKey *)pytalloc_get_ptr(obj);
    9261             :         PyObject *py_handle;
    9262           0 :         if (object->in.handle == NULL) {
    9263           0 :                 Py_RETURN_NONE;
    9264             :         }
    9265           0 :         py_handle = pytalloc_reference_ex(policy_handle_Type, object->in.handle, object->in.handle);
    9266           0 :         return py_handle;
    9267             : }
    9268             : 
    9269           0 : static int py_winreg_LoadKey_in_set_handle(PyObject *py_obj, PyObject *value, void *closure)
    9270             : {
    9271           0 :         struct winreg_LoadKey *object = (struct winreg_LoadKey *)pytalloc_get_ptr(py_obj);
    9272           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.handle));
    9273           0 :         if (value == NULL) {
    9274           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.handle");
    9275           0 :                 return -1;
    9276             :         }
    9277           0 :         object->in.handle = talloc_ptrtype(pytalloc_get_mem_ctx(py_obj), object->in.handle);
    9278           0 :         if (object->in.handle == NULL) {
    9279           0 :                 PyErr_NoMemory();
    9280           0 :                 return -1;
    9281             :         }
    9282           0 :         PY_CHECK_TYPE(policy_handle_Type, value, return -1;);
    9283           0 :         if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    9284           0 :                 PyErr_NoMemory();
    9285           0 :                 return -1;
    9286             :         }
    9287           0 :         object->in.handle = (struct policy_handle *)pytalloc_get_ptr(value);
    9288           0 :         return 0;
    9289             : }
    9290             : 
    9291           0 : static PyObject *py_winreg_LoadKey_in_get_keyname(PyObject *obj, void *closure)
    9292             : {
    9293           0 :         struct winreg_LoadKey *object = (struct winreg_LoadKey *)pytalloc_get_ptr(obj);
    9294             :         PyObject *py_keyname;
    9295           0 :         if (object->in.keyname == NULL) {
    9296           0 :                 Py_RETURN_NONE;
    9297             :         }
    9298           0 :         if (object->in.keyname == NULL) {
    9299           0 :                 py_keyname = Py_None;
    9300           0 :                 Py_INCREF(py_keyname);
    9301             :         } else {
    9302           0 :                 py_keyname = pytalloc_reference_ex(&winreg_String_Type, object->in.keyname, object->in.keyname);
    9303             :         }
    9304           0 :         return py_keyname;
    9305             : }
    9306             : 
    9307           0 : static int py_winreg_LoadKey_in_set_keyname(PyObject *py_obj, PyObject *value, void *closure)
    9308             : {
    9309           0 :         struct winreg_LoadKey *object = (struct winreg_LoadKey *)pytalloc_get_ptr(py_obj);
    9310           0 :         talloc_unlink(pytalloc_get_mem_ctx(py_obj), discard_const(object->in.keyname));
    9311           0 :         if (value == NULL) {
    9312           0 :                 PyErr_Format(PyExc_AttributeError, "Cannot delete NDR object: struct object->in.keyname");
    9313           0 :                 return -1;
    9314             :         }
    9315           0 :         if (value == Py_None) {
    9316           0 :                 object->in.keyname = NULL;
    9317             :         } else {
    9318           0 :                 object->in.keyname = NULL;
    9319           0 :                 PY_CHECK_TYPE(&winreg_String_Type, value, return -1;);
    9320           0 :                 if (talloc_reference(pytalloc_get_mem_ctx(py_obj), pytalloc_get_mem_ctx(value)) == NULL) {
    9321           0 :                         PyErr_NoMemory();
    9322           0 :                         return -1;
    9323             :                 }
    9324           0 :                 object->in.keyname = (struct winreg_String *)pytalloc_get_ptr(value);
    9325             :         }
    9326           0 :         return 0;