smbd: remove coupling between get_ea_names_from_file() and "ea support"
[sfrench/samba-autobuild/.git] / source3 / rpc_client / cli_winreg_spoolss.c
index e3d8a3d20548e55aeea9afcd129b08ca49df74e7..5ec97e6a94cace344486f07a59b990d8be4bdee2 100644 (file)
 
 /*        FLAGS,                NAME,                              with,   height,   left, top, right, bottom */
 static const struct spoolss_FormInfo1 builtin_forms1[] = {
-       { SPOOLSS_FORM_BUILTIN, "10x11",                          {0x3e030,0x44368}, {0x0,0x0,0x3e030,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "10x14",                          {0x3e030,0x56d10}, {0x0,0x0,0x3e030,0x56d10} },
-       { SPOOLSS_FORM_BUILTIN, "11x17",                          {0x44368,0x696b8}, {0x0,0x0,0x44368,0x696b8} },
-       { SPOOLSS_FORM_BUILTIN, "12x11",                          {0x4a724,0x443e1}, {0x0,0x0,0x4a724,0x443e1} },
-       { SPOOLSS_FORM_BUILTIN, "15x11",                          {0x5d048,0x44368}, {0x0,0x0,0x5d048,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "6 3/4 Envelope",                 {0x167ab,0x284ec}, {0x0,0x0,0x167ab,0x284ec} },
-       { SPOOLSS_FORM_BUILTIN, "9x11",                           {0x37cf8,0x44368}, {0x0,0x0,0x37cf8,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "A0",                             {0xcd528,0x122488},{0x0,0x0,0xcd528,0x122488} },
-       { SPOOLSS_FORM_BUILTIN, "A1",                             {0x91050,0xcd528}, {0x0,0x0,0x91050,0xcd528} },
-       { SPOOLSS_FORM_BUILTIN, "A2",                             {0x668a0,0x91050}, {0x0,0x0,0x668a0,0x91050} },
-       { SPOOLSS_FORM_BUILTIN, "A3 Extra Transverse",            {0x4e9d0,0x6ca48}, {0x0,0x0,0x4e9d0,0x6ca48} },
-       { SPOOLSS_FORM_BUILTIN, "A3 Extra",                       {0x4e9d0,0x6ca48}, {0x0,0x0,0x4e9d0,0x6ca48} },
-       { SPOOLSS_FORM_BUILTIN, "A3 Rotated",                     {0x668a0,0x48828}, {0x0,0x0,0x668a0,0x48828} },
-       { SPOOLSS_FORM_BUILTIN, "A3 Transverse",                  {0x48828,0x668a0}, {0x0,0x0,0x48828,0x668a0} },
-       { SPOOLSS_FORM_BUILTIN, "A3",                             {0x48828,0x668a0}, {0x0,0x0,0x48828,0x668a0} },
-       { SPOOLSS_FORM_BUILTIN, "A4 Extra",                       {0x397c2,0x4eb16}, {0x0,0x0,0x397c2,0x4eb16} },
-       { SPOOLSS_FORM_BUILTIN, "A4 Plus",                        {0x33450,0x50910}, {0x0,0x0,0x33450,0x50910} },
-       { SPOOLSS_FORM_BUILTIN, "A4 Rotated",                     {0x48828,0x33450}, {0x0,0x0,0x48828,0x33450} },
-       { SPOOLSS_FORM_BUILTIN, "A4 Small",                       {0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
-       { SPOOLSS_FORM_BUILTIN, "A4 Transverse",                  {0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
-       { SPOOLSS_FORM_BUILTIN, "A4",                             {0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
-       { SPOOLSS_FORM_BUILTIN, "A5 Extra",                       {0x2a7b0,0x395f8}, {0x0,0x0,0x2a7b0,0x395f8} },
-       { SPOOLSS_FORM_BUILTIN, "A5 Rotated",                     {0x33450,0x24220}, {0x0,0x0,0x33450,0x24220} },
-       { SPOOLSS_FORM_BUILTIN, "A5 Transverse",                  {0x24220,0x33450}, {0x0,0x0,0x24220,0x33450} },
-       { SPOOLSS_FORM_BUILTIN, "A5",                             {0x24220,0x33450}, {0x0,0x0,0x24220,0x33450} },
-       { SPOOLSS_FORM_BUILTIN, "A6 Rotated",                     {0x24220,0x19a28}, {0x0,0x0,0x24220,0x19a28} },
-       { SPOOLSS_FORM_BUILTIN, "A6",                             {0x19a28,0x24220}, {0x0,0x0,0x19a28,0x24220} },
-       { SPOOLSS_FORM_BUILTIN, "B4 (ISO)",                       {0x3d090,0x562e8}, {0x0,0x0,0x3d090,0x562e8} },
-       { SPOOLSS_FORM_BUILTIN, "B4 (JIS) Rotated",               {0x58de0,0x3ebe8}, {0x0,0x0,0x58de0,0x3ebe8} },
-       { SPOOLSS_FORM_BUILTIN, "B4 (JIS)",                       {0x3ebe8,0x58de0}, {0x0,0x0,0x3ebe8,0x58de0} },
-       { SPOOLSS_FORM_BUILTIN, "B5 (ISO) Extra",                 {0x31128,0x43620}, {0x0,0x0,0x31128,0x43620} },
-       { SPOOLSS_FORM_BUILTIN, "B5 (JIS) Rotated",               {0x3ebe8,0x2c6f0}, {0x0,0x0,0x3ebe8,0x2c6f0} },
-       { SPOOLSS_FORM_BUILTIN, "B5 (JIS) Transverse",            {0x2c6f0,0x3ebe8}, {0x0,0x0,0x2c6f0,0x3ebe8} },
-       { SPOOLSS_FORM_BUILTIN, "B5 (JIS)",                       {0x2c6f0,0x3ebe8}, {0x0,0x0,0x2c6f0,0x3ebe8} },
-       { SPOOLSS_FORM_BUILTIN, "B6 (JIS) Rotated",               {0x2c6f0,0x1f400}, {0x0,0x0,0x2c6f0,0x1f400} },
-       { SPOOLSS_FORM_BUILTIN, "B6 (JIS)",                       {0x1f400,0x2c6f0}, {0x0,0x0,0x1f400,0x2c6f0} },
-       { SPOOLSS_FORM_BUILTIN, "C size sheet",                   {0x696b8,0x886d0}, {0x0,0x0,0x696b8,0x886d0} },
-       { SPOOLSS_FORM_BUILTIN, "D size sheet",                   {0x886d0,0xd2d70}, {0x0,0x0,0x886d0,0xd2d70} },
-       { SPOOLSS_FORM_BUILTIN, "Double Japan Postcard Rotated",  {0x24220,0x30d40}, {0x0,0x0,0x24220,0x30d40} },
-       { SPOOLSS_FORM_BUILTIN, "E size sheet",                   {0xd2d70,0x110da0},{0x0,0x0,0xd2d70,0x110da0} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope #10",                   {0x19947,0x3ae94}, {0x0,0x0,0x19947,0x3ae94} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope #11",                   {0x1be7c,0x40565}, {0x0,0x0,0x1be7c,0x40565} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope #12",                   {0x1d74a,0x44368}, {0x0,0x0,0x1d74a,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope #14",                   {0x1f018,0x47504}, {0x0,0x0,0x1f018,0x47504} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope #9",                    {0x18079,0x37091}, {0x0,0x0,0x18079,0x37091} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope B4",                    {0x3d090,0x562e8}, {0x0,0x0,0x3d090,0x562e8} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope B5",                    {0x2af80,0x3d090}, {0x0,0x0,0x2af80,0x3d090} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope B6",                    {0x2af80,0x1e848}, {0x0,0x0,0x2af80,0x1e848} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope C3",                    {0x4f1a0,0x6fd10}, {0x0,0x0,0x4f1a0,0x6fd10} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope C4",                    {0x37e88,0x4f1a0}, {0x0,0x0,0x37e88,0x4f1a0} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope C5",                    {0x278d0,0x37e88}, {0x0,0x0,0x278d0,0x37e88} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope C6",                    {0x1bd50,0x278d0}, {0x0,0x0,0x1bd50,0x278d0} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope C65",                   {0x1bd50,0x37e88}, {0x0,0x0,0x1bd50,0x37e88} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope DL",                    {0x1adb0,0x35b60}, {0x0,0x0,0x1adb0,0x35b60} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope Invite",                {0x35b60,0x35b60}, {0x0,0x0,0x35b60,0x35b60} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope Monarch",               {0x18079,0x2e824}, {0x0,0x0,0x18079,0x2e824} },
-       { SPOOLSS_FORM_BUILTIN, "Envelope",                       {0x1adb0,0x38270}, {0x0,0x0,0x1adb0,0x38270} },
-       { SPOOLSS_FORM_BUILTIN, "Executive",                      {0x2cf56,0x411cc}, {0x0,0x0,0x2cf56,0x411cc} },
-       { SPOOLSS_FORM_BUILTIN, "Folio",                          {0x34b5c,0x509d8}, {0x0,0x0,0x34b5c,0x509d8} },
-       { SPOOLSS_FORM_BUILTIN, "German Legal Fanfold",           {0x34b5c,0x509d8}, {0x0,0x0,0x34b5c,0x509d8} },
-       { SPOOLSS_FORM_BUILTIN, "German Std Fanfold",             {0x34b5c,0x4a6a0}, {0x0,0x0,0x34b5c,0x4a6a0} },
-       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Chou #3 Rotated", {0x395f8,0x1d4c0}, {0x0,0x0,0x395f8,0x1d4c0} },
-       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Chou #4 Rotated", {0x320c8,0x15f90}, {0x0,0x0,0x320c8,0x15f90} },
-       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Kaku #2 Rotated", {0x510e0,0x3a980}, {0x0,0x0,0x510e0,0x3a980} },
-       { SPOOLSS_FORM_BUILTIN, "Japan Envelope Kaku #3 Rotated", {0x43a08,0x34bc0}, {0x0,0x0,0x43a08,0x34bc0} },
-       { SPOOLSS_FORM_BUILTIN, "Japan Envelope You #4 Rotated",  {0x395f8,0x19a28}, {0x0,0x0,0x395f8,0x19a28} },
-       { SPOOLSS_FORM_BUILTIN, "Japan Envelope You #4",          {0x19a28,0x395f8}, {0x0,0x0,0x19a28,0x395f8} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Double Postcard",       {0x30d40,0x24220}, {0x0,0x0,0x30d40,0x24220} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Chou #3",      {0x1d4c0,0x395f8}, {0x0,0x0,0x1d4c0,0x395f8} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Chou #4",      {0x15f90,0x320c8}, {0x0,0x0,0x15f90,0x320c8} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Kaku #2",      {0x3a980,0x510e0}, {0x0,0x0,0x3a980,0x510e0} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Kaku #3",      {0x34bc0,0x43a08}, {0x0,0x0,0x34bc0,0x43a08} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Postcard Rotated",      {0x24220,0x186a0}, {0x0,0x0,0x24220,0x186a0} },
-       { SPOOLSS_FORM_BUILTIN, "Japanese Postcard",              {0x186a0,0x24220}, {0x0,0x0,0x186a0,0x24220} },
-       { SPOOLSS_FORM_BUILTIN, "Ledger",                         {0x696b8,0x44368}, {0x0,0x0,0x696b8,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "Legal Extra",                    {0x3ae94,0x5d048}, {0x0,0x0,0x3ae94,0x5d048} },
-       { SPOOLSS_FORM_BUILTIN, "Legal",                          {0x34b5c,0x56d10}, {0x0,0x0,0x34b5c,0x56d10} },
-       { SPOOLSS_FORM_BUILTIN, "Letter Extra Transverse",        {0x3ae94,0x4a6a0}, {0x0,0x0,0x3ae94,0x4a6a0} },
-       { SPOOLSS_FORM_BUILTIN, "Letter Extra",                   {0x3ae94,0x4a6a0}, {0x0,0x0,0x3ae94,0x4a6a0} },
-       { SPOOLSS_FORM_BUILTIN, "Letter Plus",                    {0x34b5c,0x4eb16}, {0x0,0x0,0x34b5c,0x4eb16} },
-       { SPOOLSS_FORM_BUILTIN, "Letter Rotated",                 {0x44368,0x34b5c}, {0x0,0x0,0x44368,0x34b5c} },
-       { SPOOLSS_FORM_BUILTIN, "Letter Small",                   {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "Letter Transverse",              {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "Letter",                         {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "Note",                           {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
-       { SPOOLSS_FORM_BUILTIN, "PRC 16K Rotated",                {0x3f7a0,0x2de60}, {0x0,0x0,0x3f7a0,0x2de60} },
-       { SPOOLSS_FORM_BUILTIN, "PRC 16K",                        {0x2de60,0x3f7a0}, {0x0,0x0,0x2de60,0x3f7a0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC 32K Rotated",                {0x2cec0,0x1fbd0}, {0x0,0x0,0x2cec0,0x1fbd0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC 32K",                        {0x1fbd0,0x2cec0}, {0x0,0x0,0x1fbd0,0x2cec0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC 32K(Big) Rotated",           {0x318f8,0x222e0}, {0x0,0x0,0x318f8,0x222e0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC 32K(Big)",                   {0x222e0,0x318f8}, {0x0,0x0,0x222e0,0x318f8} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #1 Rotated",        {0x28488,0x18e70}, {0x0,0x0,0x28488,0x18e70} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #1",                {0x18e70,0x28488}, {0x0,0x0,0x18e70,0x28488} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #10 Rotated",       {0x6fd10,0x4f1a0}, {0x0,0x0,0x6fd10,0x4f1a0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #10",               {0x4f1a0,0x6fd10}, {0x0,0x0,0x4f1a0,0x6fd10} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #2 Rotated",        {0x2af80,0x18e70}, {0x0,0x0,0x2af80,0x18e70} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #2",                {0x18e70,0x2af80}, {0x0,0x0,0x18e70,0x2af80} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #3 Rotated",        {0x2af80,0x1e848}, {0x0,0x0,0x2af80,0x1e848} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #3",                {0x1e848,0x2af80}, {0x0,0x0,0x1e848,0x2af80} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #4 Rotated",        {0x32c80,0x1adb0}, {0x0,0x0,0x32c80,0x1adb0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #4",                {0x1adb0,0x32c80}, {0x0,0x0,0x1adb0,0x32c80} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #5 Rotated",        {0x35b60,0x1adb0}, {0x0,0x0,0x35b60,0x1adb0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #5",                {0x1adb0,0x35b60}, {0x0,0x0,0x1adb0,0x35b60} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #6 Rotated",        {0x38270,0x1d4c0}, {0x0,0x0,0x38270,0x1d4c0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #6",                {0x1d4c0,0x38270}, {0x0,0x0,0x1d4c0,0x38270} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #7 Rotated",        {0x38270,0x27100}, {0x0,0x0,0x38270,0x27100} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #7",                {0x27100,0x38270}, {0x0,0x0,0x27100,0x38270} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #8 Rotated",        {0x4b708,0x1d4c0}, {0x0,0x0,0x4b708,0x1d4c0} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #8",                {0x1d4c0,0x4b708}, {0x0,0x0,0x1d4c0,0x4b708} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #9 Rotated",        {0x4f1a0,0x37e88}, {0x0,0x0,0x4f1a0,0x37e88} },
-       { SPOOLSS_FORM_BUILTIN, "PRC Envelope #9",                {0x37e88,0x4f1a0}, {0x0,0x0,0x37e88,0x4f1a0} },
-       { SPOOLSS_FORM_BUILTIN, "Quarto",                         {0x347d8,0x43238}, {0x0,0x0,0x347d8,0x43238} },
-       { SPOOLSS_FORM_BUILTIN, "Reserved48",                     {0x1,0x1},         {0x0,0x0,0x1,0x1} },
-       { SPOOLSS_FORM_BUILTIN, "Reserved49",                     {0x1,0x1},         {0x0,0x0,0x1,0x1} },
-       { SPOOLSS_FORM_BUILTIN, "Statement",                      {0x221b4,0x34b5c}, {0x0,0x0,0x221b4,0x34b5c} },
-       { SPOOLSS_FORM_BUILTIN, "Super A",                        {0x376b8,0x56ea0}, {0x0,0x0,0x376b8,0x56ea0} },
-       { SPOOLSS_FORM_BUILTIN, "Super B",                        {0x4a768,0x76e58}, {0x0,0x0,0x4a768,0x76e58} },
-       { SPOOLSS_FORM_BUILTIN, "Tabloid Extra",                  {0x4a6a0,0x6f9f0}, {0x0,0x0,0x4a6a0,0x6f9f0} },
-       { SPOOLSS_FORM_BUILTIN, "Tabloid",                        {0x44368,0x696b8}, {0x0,0x0,0x44368,0x696b8} },
-       { SPOOLSS_FORM_BUILTIN, "US Std Fanfold",                 {0x5c3e1,0x44368}, {0x0,0x0,0x5c3e1,0x44368} }
+        { SPOOLSS_FORM_BUILTIN, "Letter",                         {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "Letter Small",                   {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "Tabloid",                        {0x44368,0x696b8}, {0x0,0x0,0x44368,0x696b8} },
+        { SPOOLSS_FORM_BUILTIN, "Ledger",                         {0x696b8,0x44368}, {0x0,0x0,0x696b8,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "Legal",                          {0x34b5c,0x56d10}, {0x0,0x0,0x34b5c,0x56d10} },
+        { SPOOLSS_FORM_BUILTIN, "Statement",                      {0x221b4,0x34b5c}, {0x0,0x0,0x221b4,0x34b5c} },
+        { SPOOLSS_FORM_BUILTIN, "Executive",                      {0x2cf56,0x411cc}, {0x0,0x0,0x2cf56,0x411cc} },
+        { SPOOLSS_FORM_BUILTIN, "A3",                             {0x48828,0x668a0}, {0x0,0x0,0x48828,0x668a0} },
+        { SPOOLSS_FORM_BUILTIN, "A4",                             {0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
+        { SPOOLSS_FORM_BUILTIN, "A4 Small",                       {0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
+        { SPOOLSS_FORM_BUILTIN, "A5",                             {0x24220,0x33450}, {0x0,0x0,0x24220,0x33450} },
+        { SPOOLSS_FORM_BUILTIN, "B4 (JIS)",                       {0x3ebe8,0x58de0}, {0x0,0x0,0x3ebe8,0x58de0} },
+        { SPOOLSS_FORM_BUILTIN, "B5 (JIS)",                       {0x2c6f0,0x3ebe8}, {0x0,0x0,0x2c6f0,0x3ebe8} },
+        { SPOOLSS_FORM_BUILTIN, "Folio",                          {0x34b5c,0x509d8}, {0x0,0x0,0x34b5c,0x509d8} },
+        { SPOOLSS_FORM_BUILTIN, "Quarto",                         {0x347d8,0x43238}, {0x0,0x0,0x347d8,0x43238} },
+        { SPOOLSS_FORM_BUILTIN, "10x14",                          {0x3e030,0x56d10}, {0x0,0x0,0x3e030,0x56d10} },
+        { SPOOLSS_FORM_BUILTIN, "11x17",                          {0x44368,0x696b8}, {0x0,0x0,0x44368,0x696b8} },
+        { SPOOLSS_FORM_BUILTIN, "Note",                           {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope #9",                    {0x18079,0x37091}, {0x0,0x0,0x18079,0x37091} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope #10",                   {0x19947,0x3ae94}, {0x0,0x0,0x19947,0x3ae94} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope #11",                   {0x1be7c,0x40565}, {0x0,0x0,0x1be7c,0x40565} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope #12",                   {0x1d74a,0x44368}, {0x0,0x0,0x1d74a,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope #14",                   {0x1f018,0x47504}, {0x0,0x0,0x1f018,0x47504} },
+        { SPOOLSS_FORM_BUILTIN, "C size sheet",                   {0x696b8,0x886d0}, {0x0,0x0,0x696b8,0x886d0} },
+        { SPOOLSS_FORM_BUILTIN, "D size sheet",                   {0x886d0,0xd2d70}, {0x0,0x0,0x886d0,0xd2d70} },
+        { SPOOLSS_FORM_BUILTIN, "E size sheet",                   {0xd2d70,0x110da0},{0x0,0x0,0xd2d70,0x110da0} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope DL",                    {0x1adb0,0x35b60}, {0x0,0x0,0x1adb0,0x35b60} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope C5",                    {0x278d0,0x37e88}, {0x0,0x0,0x278d0,0x37e88} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope C3",                    {0x4f1a0,0x6fd10}, {0x0,0x0,0x4f1a0,0x6fd10} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope C4",                    {0x37e88,0x4f1a0}, {0x0,0x0,0x37e88,0x4f1a0} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope C6",                    {0x1bd50,0x278d0}, {0x0,0x0,0x1bd50,0x278d0} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope C65",                   {0x1bd50,0x37e88}, {0x0,0x0,0x1bd50,0x37e88} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope B4",                    {0x3d090,0x562e8}, {0x0,0x0,0x3d090,0x562e8} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope B5",                    {0x2af80,0x3d090}, {0x0,0x0,0x2af80,0x3d090} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope B6",                    {0x2af80,0x1e848}, {0x0,0x0,0x2af80,0x1e848} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope",                       {0x1adb0,0x38270}, {0x0,0x0,0x1adb0,0x38270} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope Monarch",               {0x18079,0x2e824}, {0x0,0x0,0x18079,0x2e824} },
+        { SPOOLSS_FORM_BUILTIN, "6 3/4 Envelope",                 {0x167ab,0x284ec}, {0x0,0x0,0x167ab,0x284ec} },
+        { SPOOLSS_FORM_BUILTIN, "US Std Fanfold",                 {0x5c3e1,0x44368}, {0x0,0x0,0x5c3e1,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "German Std Fanfold",             {0x34b5c,0x4a6a0}, {0x0,0x0,0x34b5c,0x4a6a0} },
+        { SPOOLSS_FORM_BUILTIN, "German Legal Fanfold",           {0x34b5c,0x509d8}, {0x0,0x0,0x34b5c,0x509d8} },
+        { SPOOLSS_FORM_BUILTIN, "B4 (ISO)",                       {0x3d090,0x562e8}, {0x0,0x0,0x3d090,0x562e8} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Postcard",              {0x186a0,0x24220}, {0x0,0x0,0x186a0,0x24220} },
+        { SPOOLSS_FORM_BUILTIN, "9x11",                           {0x37cf8,0x44368}, {0x0,0x0,0x37cf8,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "10x11",                          {0x3e030,0x44368}, {0x0,0x0,0x3e030,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "15x11",                          {0x5d048,0x44368}, {0x0,0x0,0x5d048,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "Envelope Invite",                {0x35b60,0x35b60}, {0x0,0x0,0x35b60,0x35b60} },
+        { SPOOLSS_FORM_BUILTIN, "Reserved48",                     {0x1,0x1},         {0x0,0x0,0x1,0x1} },
+        { SPOOLSS_FORM_BUILTIN, "Reserved49",                     {0x1,0x1},         {0x0,0x0,0x1,0x1} },
+        { SPOOLSS_FORM_BUILTIN, "Letter Extra",                   {0x3ae94,0x4a6a0}, {0x0,0x0,0x3ae94,0x4a6a0} },
+        { SPOOLSS_FORM_BUILTIN, "Legal Extra",                    {0x3ae94,0x5d048}, {0x0,0x0,0x3ae94,0x5d048} },
+        { SPOOLSS_FORM_BUILTIN, "Tabloid Extra",                  {0x4a6a0,0x6f9f0}, {0x0,0x0,0x4a6a0,0x6f9f0} },
+        { SPOOLSS_FORM_BUILTIN, "A4 Extra",                       {0x397c2,0x4eb16}, {0x0,0x0,0x397c2,0x4eb16} },
+        { SPOOLSS_FORM_BUILTIN, "Letter Transverse",              {0x34b5c,0x44368}, {0x0,0x0,0x34b5c,0x44368} },
+        { SPOOLSS_FORM_BUILTIN, "A4 Transverse",                  {0x33450,0x48828}, {0x0,0x0,0x33450,0x48828} },
+        { SPOOLSS_FORM_BUILTIN, "Letter Extra Transverse",        {0x3ae94,0x4a6a0}, {0x0,0x0,0x3ae94,0x4a6a0} },
+        { SPOOLSS_FORM_BUILTIN, "Super A",                        {0x376b8,0x56ea0}, {0x0,0x0,0x376b8,0x56ea0} },
+        { SPOOLSS_FORM_BUILTIN, "Super B",                        {0x4a768,0x76e58}, {0x0,0x0,0x4a768,0x76e58} },
+        { SPOOLSS_FORM_BUILTIN, "Letter Plus",                    {0x34b5c,0x4eb16}, {0x0,0x0,0x34b5c,0x4eb16} },
+        { SPOOLSS_FORM_BUILTIN, "A4 Plus",                        {0x33450,0x50910}, {0x0,0x0,0x33450,0x50910} },
+        { SPOOLSS_FORM_BUILTIN, "A5 Transverse",                  {0x24220,0x33450}, {0x0,0x0,0x24220,0x33450} },
+        { SPOOLSS_FORM_BUILTIN, "B5 (JIS) Transverse",            {0x2c6f0,0x3ebe8}, {0x0,0x0,0x2c6f0,0x3ebe8} },
+        { SPOOLSS_FORM_BUILTIN, "A3 Extra",                       {0x4e9d0,0x6ca48}, {0x0,0x0,0x4e9d0,0x6ca48} },
+        { SPOOLSS_FORM_BUILTIN, "A5 Extra",                       {0x2a7b0,0x395f8}, {0x0,0x0,0x2a7b0,0x395f8} },
+        { SPOOLSS_FORM_BUILTIN, "B5 (ISO) Extra",                 {0x31128,0x43620}, {0x0,0x0,0x31128,0x43620} },
+        { SPOOLSS_FORM_BUILTIN, "A2",                             {0x668a0,0x91050}, {0x0,0x0,0x668a0,0x91050} },
+        { SPOOLSS_FORM_BUILTIN, "A3 Transverse",                  {0x48828,0x668a0}, {0x0,0x0,0x48828,0x668a0} },
+        { SPOOLSS_FORM_BUILTIN, "A3 Extra Transverse",            {0x4e9d0,0x6ca48}, {0x0,0x0,0x4e9d0,0x6ca48} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Double Postcard",       {0x30d40,0x24220}, {0x0,0x0,0x30d40,0x24220} },
+        { SPOOLSS_FORM_BUILTIN, "A6",                             {0x19a28,0x24220}, {0x0,0x0,0x19a28,0x24220} },
+        { SPOOLSS_FORM_BUILTIN, "Japan Envelope Kaku #2 Rotated", {0x510e0,0x3a980}, {0x0,0x0,0x510e0,0x3a980} },
+        { SPOOLSS_FORM_BUILTIN, "Japan Envelope Kaku #3 Rotated", {0x43a08,0x34bc0}, {0x0,0x0,0x43a08,0x34bc0} },
+        { SPOOLSS_FORM_BUILTIN, "Japan Envelope Chou #3 Rotated", {0x395f8,0x1d4c0}, {0x0,0x0,0x395f8,0x1d4c0} },
+        { SPOOLSS_FORM_BUILTIN, "Japan Envelope Chou #4 Rotated", {0x320c8,0x15f90}, {0x0,0x0,0x320c8,0x15f90} },
+        { SPOOLSS_FORM_BUILTIN, "Letter Rotated",                 {0x44368,0x34b5c}, {0x0,0x0,0x44368,0x34b5c} },
+        { SPOOLSS_FORM_BUILTIN, "A3 Rotated",                     {0x668a0,0x48828}, {0x0,0x0,0x668a0,0x48828} },
+        { SPOOLSS_FORM_BUILTIN, "A4 Rotated",                     {0x48828,0x33450}, {0x0,0x0,0x48828,0x33450} },
+        { SPOOLSS_FORM_BUILTIN, "A5 Rotated",                     {0x33450,0x24220}, {0x0,0x0,0x33450,0x24220} },
+        { SPOOLSS_FORM_BUILTIN, "B4 (JIS) Rotated",               {0x58de0,0x3ebe8}, {0x0,0x0,0x58de0,0x3ebe8} },
+        { SPOOLSS_FORM_BUILTIN, "B5 (JIS) Rotated",               {0x3ebe8,0x2c6f0}, {0x0,0x0,0x3ebe8,0x2c6f0} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Postcard Rotated",      {0x24220,0x186a0}, {0x0,0x0,0x24220,0x186a0} },
+        { SPOOLSS_FORM_BUILTIN, "Double Japan Postcard Rotated",  {0x24220,0x30d40}, {0x0,0x0,0x24220,0x30d40} },
+        { SPOOLSS_FORM_BUILTIN, "A6 Rotated",                     {0x24220,0x19a28}, {0x0,0x0,0x24220,0x19a28} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Kaku #2",      {0x3a980,0x510e0}, {0x0,0x0,0x3a980,0x510e0} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Kaku #3",      {0x34bc0,0x43a08}, {0x0,0x0,0x34bc0,0x43a08} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Chou #3",      {0x1d4c0,0x395f8}, {0x0,0x0,0x1d4c0,0x395f8} },
+        { SPOOLSS_FORM_BUILTIN, "Japanese Envelope Chou #4",      {0x15f90,0x320c8}, {0x0,0x0,0x15f90,0x320c8} },
+        { SPOOLSS_FORM_BUILTIN, "B6 (JIS)",                       {0x1f400,0x2c6f0}, {0x0,0x0,0x1f400,0x2c6f0} },
+        { SPOOLSS_FORM_BUILTIN, "B6 (JIS) Rotated",               {0x2c6f0,0x1f400}, {0x0,0x0,0x2c6f0,0x1f400} },
+        { SPOOLSS_FORM_BUILTIN, "12x11",                          {0x4a724,0x443e1}, {0x0,0x0,0x4a724,0x443e1} },
+        { SPOOLSS_FORM_BUILTIN, "Japan Envelope You #4",          {0x19a28,0x395f8}, {0x0,0x0,0x19a28,0x395f8} },
+        { SPOOLSS_FORM_BUILTIN, "Japan Envelope You #4 Rotated",  {0x395f8,0x19a28}, {0x0,0x0,0x395f8,0x19a28} },
+        { SPOOLSS_FORM_BUILTIN, "PRC 16K",                        {0x2de60,0x3f7a0}, {0x0,0x0,0x2de60,0x3f7a0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC 32K",                        {0x1fbd0,0x2cec0}, {0x0,0x0,0x1fbd0,0x2cec0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC 32K(Big)",                   {0x222e0,0x318f8}, {0x0,0x0,0x222e0,0x318f8} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #1",                {0x18e70,0x28488}, {0x0,0x0,0x18e70,0x28488} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #2",                {0x18e70,0x2af80}, {0x0,0x0,0x18e70,0x2af80} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #3",                {0x1e848,0x2af80}, {0x0,0x0,0x1e848,0x2af80} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #4",                {0x1adb0,0x32c80}, {0x0,0x0,0x1adb0,0x32c80} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #5",                {0x1adb0,0x35b60}, {0x0,0x0,0x1adb0,0x35b60} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #6",                {0x1d4c0,0x38270}, {0x0,0x0,0x1d4c0,0x38270} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #7",                {0x27100,0x38270}, {0x0,0x0,0x27100,0x38270} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #8",                {0x1d4c0,0x4b708}, {0x0,0x0,0x1d4c0,0x4b708} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #9",                {0x37e88,0x4f1a0}, {0x0,0x0,0x37e88,0x4f1a0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #10",               {0x4f1a0,0x6fd10}, {0x0,0x0,0x4f1a0,0x6fd10} },
+        { SPOOLSS_FORM_BUILTIN, "PRC 16K Rotated",                {0x3f7a0,0x2de60}, {0x0,0x0,0x3f7a0,0x2de60} },
+        { SPOOLSS_FORM_BUILTIN, "PRC 32K Rotated",                {0x2cec0,0x1fbd0}, {0x0,0x0,0x2cec0,0x1fbd0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC 32K(Big) Rotated",           {0x318f8,0x222e0}, {0x0,0x0,0x318f8,0x222e0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #1 Rotated",        {0x28488,0x18e70}, {0x0,0x0,0x28488,0x18e70} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #2 Rotated",        {0x2af80,0x18e70}, {0x0,0x0,0x2af80,0x18e70} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #3 Rotated",        {0x2af80,0x1e848}, {0x0,0x0,0x2af80,0x1e848} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #4 Rotated",        {0x32c80,0x1adb0}, {0x0,0x0,0x32c80,0x1adb0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #5 Rotated",        {0x35b60,0x1adb0}, {0x0,0x0,0x35b60,0x1adb0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #6 Rotated",        {0x38270,0x1d4c0}, {0x0,0x0,0x38270,0x1d4c0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #7 Rotated",        {0x38270,0x27100}, {0x0,0x0,0x38270,0x27100} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #8 Rotated",        {0x4b708,0x1d4c0}, {0x0,0x0,0x4b708,0x1d4c0} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #9 Rotated",        {0x4f1a0,0x37e88}, {0x0,0x0,0x4f1a0,0x37e88} },
+        { SPOOLSS_FORM_BUILTIN, "PRC Envelope #10 Rotated",       {0x6fd10,0x4f1a0}, {0x0,0x0,0x6fd10,0x4f1a0} }
 };
 
 /********************************************************************
@@ -253,7 +251,7 @@ static WERROR winreg_printer_openkey(TALLOC_CTX *mem_ctx,
                keyname = talloc_strdup(mem_ctx, path);
        }
        if (keyname == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(wkey);
@@ -347,7 +345,7 @@ static WERROR winreg_printer_opendriver(TALLOC_CTX *mem_ctx,
                                   TOP_LEVEL_CONTROL_KEY,
                                   architecture, version);
        if (!key_name) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        result = winreg_printer_openkey(mem_ctx,
@@ -399,13 +397,13 @@ static WERROR winreg_enumval_to_sz(TALLOC_CTX *mem_ctx,
        if (v->data_length == 0) {
                *_str = talloc_strdup(mem_ctx, EMPTY_STRING);
                if (*_str == NULL) {
-                       return WERR_NOMEM;
+                       return WERR_NOT_ENOUGH_MEMORY;
                }
                return WERR_OK;
        }
 
        if (!pull_reg_sz(mem_ctx, v->data, _str)) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        return WERR_OK;
@@ -428,14 +426,14 @@ static WERROR winreg_enumval_to_multi_sz(TALLOC_CTX *mem_ctx,
        if (v->data_length == 0) {
                *array = talloc_array(mem_ctx, const char *, 1);
                if (*array == NULL) {
-                       return WERR_NOMEM;
+                       return WERR_NOT_ENOUGH_MEMORY;
                }
                *array[0] = NULL;
                return WERR_OK;
        }
 
        if (!pull_reg_multi_sz(mem_ctx, v->data, array)) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        return WERR_OK;
@@ -467,12 +465,12 @@ static WERROR winreg_printer_write_date(TALLOC_CTX *mem_ctx,
                                      tm->tm_mon + 1, tm->tm_mday, tm->tm_year + 1900);
        }
        if (!str) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        wvalue.name = value;
        if (!push_reg_sz(mem_ctx, &blob, str)) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
        status = dcerpc_winreg_SetValue(winreg_handle,
                                        mem_ctx,
@@ -495,26 +493,12 @@ static WERROR winreg_printer_write_date(TALLOC_CTX *mem_ctx,
 
 static WERROR winreg_printer_date_to_NTTIME(const char *str, NTTIME *data)
 {
-       struct tm tm;
-       time_t t;
-
-       if (strequal(str, "01/01/1601")) {
-               *data = 0;
-               return WERR_OK;
-       }
-
-       ZERO_STRUCT(tm);
+       bool ok;
 
-       if (sscanf(str, "%d/%d/%d",
-                  &tm.tm_mon, &tm.tm_mday, &tm.tm_year) != 3) {
+       ok = spoolss_timestr_to_NTTIME(str, data);
+       if (!ok) {
                return WERR_INVALID_PARAMETER;
        }
-       tm.tm_mon -= 1;
-       tm.tm_year -= 1900;
-       tm.tm_isdst = -1;
-
-       t = mktime(&tm);
-       unix_to_nt_time(data, t);
 
        return WERR_OK;
 }
@@ -531,20 +515,21 @@ static WERROR winreg_printer_write_ver(TALLOC_CTX *mem_ctx,
        NTSTATUS status;
        char *str;
 
-       /* FIXME: check format is right,
-        *      this needs to be something like: 6.1.7600.16385 */
+       /*
+        * this needs to be something like: 6.1.7600.16385
+        */
        str = talloc_asprintf(mem_ctx, "%u.%u.%u.%u",
                              (unsigned)((data >> 48) & 0xFFFF),
                              (unsigned)((data >> 32) & 0xFFFF),
                              (unsigned)((data >> 16) & 0xFFFF),
                              (unsigned)(data & 0xFFFF));
        if (!str) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        wvalue.name = value;
        if (!push_reg_sz(mem_ctx, &blob, str)) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
        status = dcerpc_winreg_SetValue(winreg_handle,
                                        mem_ctx,
@@ -565,19 +550,15 @@ static WERROR winreg_printer_write_ver(TALLOC_CTX *mem_ctx,
        return result;
 }
 
-static WERROR winreg_printer_ver_to_dword(const char *str, uint64_t *data)
+static WERROR winreg_printer_ver_to_qword(const char *str, uint64_t *data)
 {
-       unsigned int v1, v2, v3, v4;
+       bool ok;
 
-       if (sscanf(str, "%u.%u.%u.%u", &v1, &v2, &v3, &v4) != 4) {
+       ok = spoolss_driver_version_to_qword(str, data);
+       if (!ok) {
                return WERR_INVALID_PARAMETER;
        }
 
-       *data = ((uint64_t)(v1 & 0xFFFF) << 48) +
-               ((uint64_t)(v2 & 0xFFFF) << 32) +
-               ((uint64_t)(v3 & 0xFFFF) << 16) +
-               (uint64_t)(v2 & 0xFFFF);
-
        return WERR_OK;
 }
 
@@ -604,13 +585,13 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, sharename);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -627,7 +608,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
        if (W_ERROR_IS_OK(result)) {
                DEBUG(2, ("winreg_create_printer: Skipping, %s already exists\n", path));
                goto done;
-       } else if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+       } else if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                DEBUG(2, ("winreg_create_printer: Creating default values in %s\n", path));
        } else if (!W_ERROR_IS_OK(result)) {
                DEBUG(0, ("winreg_create_printer: Could not open key %s: %s\n",
@@ -671,7 +652,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
 
                wkey.name = talloc_asprintf(tmp_ctx, "%s\\%s", path, subkeys[i]);
                if (wkey.name == NULL) {
-                       result = WERR_NOMEM;
+                       result = WERR_NOT_ENOUGH_MEMORY;
                        goto done;
                }
 
@@ -740,7 +721,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                                longname = talloc_strdup(tmp_ctx, lp_netbios_name());
                        }
                        if (longname == NULL) {
-                               result = WERR_NOMEM;
+                               result = WERR_NOT_ENOUGH_MEMORY;
                                goto done;
                        }
 
@@ -760,7 +741,7 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
                        uncname = talloc_asprintf(tmp_ctx, "\\\\%s\\%s",
                                                  longname, sharename);
                        if (uncname == NULL) {
-                               result = WERR_NOMEM;
+                               result = WERR_NOT_ENOUGH_MEMORY;
                                goto done;
                        }
 
@@ -849,13 +830,13 @@ WERROR winreg_create_printer(TALLOC_CTX *mem_ctx,
        }
        info2 = talloc_zero(tmp_ctx, struct spoolss_SetPrinterInfo2);
        if (info2 == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
        info2->printername = sharename;
        if (info2->printername == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
        info2_mask |= SPOOLSS_PRINTER_INFO_PRINTERNAME;
@@ -936,18 +917,19 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
        DATA_BLOB blob;
        char *path;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, sharename);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -1060,7 +1042,7 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
                }
 
                if (devmode->size != (ndr_size_spoolss_DeviceMode(devmode, 0) - devmode->__driverextra_length)) {
-                       result = WERR_INVALID_PARAM;
+                       result = WERR_INVALID_PARAMETER;
                        goto done;
                }
 
@@ -1068,7 +1050,7 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
                                (ndr_push_flags_fn_t) ndr_push_spoolss_DeviceMode);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        DEBUG(0, ("winreg_update_printer: Failed to marshall device mode\n"));
-                       result = WERR_NOMEM;
+                       result = WERR_NOT_ENOUGH_MEMORY;
                        goto done;
                }
 
@@ -1318,15 +1300,11 @@ WERROR winreg_update_printer(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -1351,6 +1329,7 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
        char *path;
        NTSTATUS status;
        WERROR result = WERR_OK;
+       WERROR ignore;
        const char **enum_names = NULL;
        enum winreg_Type *enum_types = NULL;
        DATA_BLOB *enum_data_blobs = NULL;
@@ -1358,13 +1337,13 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        result = winreg_printer_openkey(tmp_ctx,
@@ -1401,7 +1380,7 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
 
        info2 = talloc_zero(tmp_ctx, struct spoolss_PrinterInfo2);
        if (info2 == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -1552,7 +1531,7 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
        if (W_ERROR_IS_OK(result)) {
                info2->devmode = talloc_zero(info2, struct spoolss_DeviceMode);
                if (info2->devmode == NULL) {
-                       result = WERR_NOMEM;
+                       result = WERR_NOT_ENOUGH_MEMORY;
                        goto done;
                }
                ndr_err = ndr_pull_struct_blob(&blob,
@@ -1561,7 +1540,7 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
                                               (ndr_pull_flags_fn_t) ndr_pull_spoolss_DeviceMode);
                if (!NDR_ERR_CODE_IS_SUCCESS(ndr_err)) {
                        DEBUG(0, ("winreg_get_printer: Failed to unmarshall device mode\n"));
-                       result = WERR_NOMEM;
+                       result = WERR_NOT_ENOUGH_MEMORY;
                        goto done;
                }
        }
@@ -1598,43 +1577,34 @@ WERROR winreg_get_printer(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
        return result;
 }
 
-WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
-                                 struct dcerpc_binding_handle *winreg_handle,
-                                 const char *sharename,
-                                 struct spoolss_security_descriptor **psecdesc)
+static WERROR winreg_get_secdesc(TALLOC_CTX *mem_ctx,
+                                struct dcerpc_binding_handle *winreg_handle,
+                                const char *path,
+                                const char *attribute,
+                                struct spoolss_security_descriptor **psecdesc)
 {
        struct spoolss_security_descriptor *secdesc;
        uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        struct policy_handle hive_hnd, key_hnd;
-       const char *path;
        TALLOC_CTX *tmp_ctx;
        NTSTATUS status;
        WERROR result;
+       WERROR ignore;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
-       }
-
-       path = winreg_printer_data_keyname(tmp_ctx, sharename);
-       if (path == NULL) {
-               talloc_free(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -1649,7 +1619,7 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
                                        &hive_hnd,
                                        &key_hnd);
        if (!W_ERROR_IS_OK(result)) {
-               if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+               if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                        goto create_default;
                }
                goto done;
@@ -1658,15 +1628,14 @@ WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
        status = dcerpc_winreg_query_sd(tmp_ctx,
                                        winreg_handle,
                                        &key_hnd,
-                                       "Security",
+                                       attribute,
                                        &secdesc,
                                        &result);
        if (!NT_STATUS_IS_OK(status)) {
                result = ntstatus_to_werror(status);
        }
        if (!W_ERROR_IS_OK(result)) {
-               if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
-                       WERROR ignore;
+               if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
 
                        if (is_valid_policy_hnd(&key_hnd)) {
                                dcerpc_winreg_CloseKey(winreg_handle,
@@ -1736,7 +1705,7 @@ create_default:
                                                    &size);
 
                        if (new_secdesc == NULL) {
-                               result = WERR_NOMEM;
+                               result = WERR_NOT_ENOUGH_MEMORY;
                                goto done;
                        }
 
@@ -1748,7 +1717,7 @@ create_default:
        status = dcerpc_winreg_set_sd(tmp_ctx,
                                          winreg_handle,
                                          &key_hnd,
-                                         "Security",
+                                         attribute,
                                          secdesc,
                                          &result);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1764,44 +1733,67 @@ create_default:
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        talloc_free(tmp_ctx);
        return result;
 }
 
-WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
+WERROR winreg_get_printer_secdesc(TALLOC_CTX *mem_ctx,
                                  struct dcerpc_binding_handle *winreg_handle,
                                  const char *sharename,
-                                 const struct spoolss_security_descriptor *secdesc)
+                                 struct spoolss_security_descriptor **psecdesc)
+{
+       WERROR result;
+       char *path;
+
+       path = winreg_printer_data_keyname(mem_ctx, sharename);
+       if (path == NULL) {
+               return WERR_NOT_ENOUGH_MEMORY;
+       }
+
+       result = winreg_get_secdesc(mem_ctx, winreg_handle,
+                                   path,
+                                   "Security",
+                                   psecdesc);
+       talloc_free(path);
+
+       return result;
+}
+
+WERROR winreg_get_printserver_secdesc(TALLOC_CTX *mem_ctx,
+                                     struct dcerpc_binding_handle *winreg_handle,
+                                     struct spoolss_security_descriptor **psecdesc)
+{
+       return winreg_get_secdesc(mem_ctx, winreg_handle,
+                                 TOP_LEVEL_CONTROL_KEY,
+                                 "ServerSecurityDescriptor",
+                                 psecdesc);
+}
+
+static WERROR winreg_set_secdesc(TALLOC_CTX *mem_ctx,
+                                struct dcerpc_binding_handle *winreg_handle,
+                                const char *path,
+                                const char *attribute,
+                                const struct spoolss_security_descriptor *secdesc)
 {
        const struct spoolss_security_descriptor *new_secdesc = secdesc;
        struct spoolss_security_descriptor *old_secdesc;
        uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
        struct policy_handle hive_hnd, key_hnd;
-       const char *path;
        TALLOC_CTX *tmp_ctx;
        NTSTATUS status;
        WERROR result;
+       WERROR ignore;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
-       }
-
-       path = winreg_printer_data_keyname(tmp_ctx, sharename);
-       if (path == NULL) {
-               talloc_free(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        /*
@@ -1815,10 +1807,11 @@ WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
                struct security_acl *dacl, *sacl;
                size_t size;
 
-               result = winreg_get_printer_secdesc(tmp_ctx,
-                                                   winreg_handle,
-                                                   sharename,
-                                                   &old_secdesc);
+               result = winreg_get_secdesc(tmp_ctx,
+                                           winreg_handle,
+                                           path,
+                                           attribute,
+                                           &old_secdesc);
                if (!W_ERROR_IS_OK(result)) {
                        talloc_free(tmp_ctx);
                        return result;
@@ -1852,7 +1845,7 @@ WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
                                            &size);
                if (new_secdesc == NULL) {
                        talloc_free(tmp_ctx);
-                       return WERR_NOMEM;
+                       return WERR_NOT_ENOUGH_MEMORY;
                }
        }
 
@@ -1874,7 +1867,7 @@ WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
        status = dcerpc_winreg_set_sd(tmp_ctx,
                                      winreg_handle,
                                      &key_hnd,
-                                     "Security",
+                                     attribute,
                                      new_secdesc,
                                      &result);
        if (!NT_STATUS_IS_OK(status)) {
@@ -1882,21 +1875,48 @@ WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        talloc_free(tmp_ctx);
        return result;
 }
 
+WERROR winreg_set_printer_secdesc(TALLOC_CTX *mem_ctx,
+                                 struct dcerpc_binding_handle *winreg_handle,
+                                 const char *sharename,
+                                 const struct spoolss_security_descriptor *secdesc)
+{
+       char *path;
+       WERROR result;
+
+       path = winreg_printer_data_keyname(mem_ctx, sharename);
+       if (path == NULL) {
+               return WERR_NOT_ENOUGH_MEMORY;
+       }
+
+       result = winreg_set_secdesc(mem_ctx, winreg_handle,
+                                   path,
+                                   "Security", secdesc);
+       talloc_free(path);
+
+       return result;
+}
+
+WERROR winreg_set_printserver_secdesc(TALLOC_CTX *mem_ctx,
+                                     struct dcerpc_binding_handle *winreg_handle,
+                                     const struct spoolss_security_descriptor *secdesc)
+{
+       return winreg_set_secdesc(mem_ctx, winreg_handle,
+                                 TOP_LEVEL_CONTROL_KEY,
+                                 "ServerSecurityDescriptor",
+                                 secdesc);
+}
+
 /* Set printer data over the winreg pipe. */
 WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
                                 struct dcerpc_binding_handle *winreg_handle,
@@ -1912,18 +1932,19 @@ WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
        struct winreg_String wvalue = { 0, };
        char *path;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -1961,15 +1982,11 @@ WERROR winreg_set_printer_dataex(TALLOC_CTX *mem_ctx,
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -1995,18 +2012,19 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
        uint32_t data_in_size = 0;
        uint32_t value_len = 0;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2049,12 +2067,14 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
                goto done;
        }
        if (!W_ERROR_IS_OK(result)) {
+               DEBUG(2, ("winreg_get_printer_dataex: Could not query value %s: %s\n",
+                         value, win_errstr(result)));
                goto done;
        }
 
        data_in = (uint8_t *) TALLOC(tmp_ctx, data_in_size);
        if (data_in == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
        value_len = 0;
@@ -2075,6 +2095,8 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
                goto done;
        }
        if (!W_ERROR_IS_OK(result)) {
+               DEBUG(2, ("winreg_get_printer_dataex: Could not query value %s: %s\n",
+                         value, win_errstr(result)));
                goto done;
        }
 
@@ -2086,15 +2108,11 @@ WERROR winreg_get_printer_dataex(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2117,6 +2135,7 @@ WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
        uint32_t num_values = 0;
        char *path;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
        const char **enum_names = NULL;
        enum winreg_Type *enum_types = NULL;
@@ -2126,13 +2145,13 @@ WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        result = winreg_printer_openkey(tmp_ctx,
@@ -2169,7 +2188,7 @@ WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
 
        enum_values = talloc_array(tmp_ctx, struct spoolss_PrinterEnumValues, num_values);
        if (enum_values == NULL){
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                DEBUG(0, ("winreg_enum_printer_dataex: Could not enumerate values in %s: %s\n",
                          key, win_errstr(result)));
                goto done;
@@ -2187,9 +2206,8 @@ WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
                }
        }
 
-       enum_names = talloc_move(mem_ctx, &enum_names);
-       enum_types = talloc_move(mem_ctx, &enum_types);
-       enum_data_blobs = talloc_move(mem_ctx, &enum_data_blobs);
+       talloc_steal(enum_values, enum_names);
+       talloc_steal(enum_values, enum_data_blobs);
 
        *pnum_values = num_values;
        if (penum_values) {
@@ -2198,15 +2216,11 @@ WERROR winreg_enum_printer_dataex(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2225,19 +2239,20 @@ WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
        struct winreg_String wvalue = { 0, };
        char *path;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
 
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2270,15 +2285,11 @@ WERROR winreg_delete_printer_dataex(TALLOC_CTX *mem_ctx,
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2300,19 +2311,20 @@ WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
        uint32_t num_subkeys = -1;
 
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
 
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2354,15 +2366,11 @@ WERROR winreg_enum_printer_key(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2380,18 +2388,19 @@ WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
        char *keyname;
        char *path;
        WERROR result;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        result = winreg_printer_openkey(tmp_ctx,
@@ -2404,7 +2413,7 @@ WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
                                        &key_hnd);
        if (!W_ERROR_IS_OK(result)) {
                /* key doesn't exist */
-               if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+               if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                        result = WERR_OK;
                        goto done;
                }
@@ -2426,7 +2435,7 @@ WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
                                          path,
                                          key);
                if (keyname == NULL) {
-                       result = WERR_NOMEM;
+                       result = WERR_NOT_ENOUGH_MEMORY;
                        goto done;
                }
        }
@@ -2452,15 +2461,11 @@ WERROR winreg_delete_printer_key(TALLOC_CTX *mem_ctx,
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2476,17 +2481,18 @@ WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
        char *path;
        NTSTATUS status;
        WERROR result;
+       WERROR ignore;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2521,15 +2527,11 @@ WERROR winreg_printer_update_changeid(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2547,17 +2549,18 @@ WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
        char *path;
        NTSTATUS status;
        WERROR result;
+       WERROR ignore;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        path = winreg_printer_data_keyname(tmp_ctx, printer);
        if (path == NULL) {
                TALLOC_FREE(tmp_ctx);
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2598,15 +2601,11 @@ WERROR winreg_printer_get_changeid(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2632,12 +2631,13 @@ WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
        union spoolss_FormInfo *info = NULL;
        uint32_t i;
        WERROR result;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2700,15 +2700,11 @@ WERROR winreg_printer_addform1(TALLOC_CTX *mem_ctx,
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(info);
@@ -2729,6 +2725,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
        uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
        uint32_t i;
        WERROR result;
+       WERROR ignore;
        NTSTATUS status;
        const char **enum_names = NULL;
        enum winreg_Type *enum_types = NULL;
@@ -2737,7 +2734,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2753,7 +2750,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
                                        &key_hnd);
        if (!W_ERROR_IS_OK(result)) {
                /* key doesn't exist */
-               if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+               if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                        result = WERR_OK;
                        goto done;
                }
@@ -2785,7 +2782,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
                                        struct spoolss_PrinterEnumValues,
                                        num_values);
        if (enum_values == NULL){
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -2808,7 +2805,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
 
        info = talloc_array(tmp_ctx, union spoolss_FormInfo, num_builtin + num_values);
        if (info == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -2828,7 +2825,7 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
 
                val.info1.form_name = talloc_strdup(info, enum_values[i].value_name);
                if (val.info1.form_name == NULL) {
-                       result = WERR_NOMEM;
+                       result = WERR_NOT_ENOUGH_MEMORY;
                        goto done;
                }
 
@@ -2850,15 +2847,11 @@ WERROR winreg_printer_enumforms1(TALLOC_CTX *mem_ctx,
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(enum_values);
@@ -2876,6 +2869,7 @@ WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
        uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
        uint32_t i;
        WERROR result = WERR_OK;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
@@ -2887,7 +2881,7 @@ WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -2904,7 +2898,7 @@ WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
        if (!W_ERROR_IS_OK(result)) {
                DEBUG(0, ("winreg_printer_deleteform1: Could not open key %s: %s\n",
                          TOP_LEVEL_CONTROL_FORMS_KEY, win_errstr(result)));
-               if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+               if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                        result = WERR_INVALID_FORM_NAME;
                }
                goto done;
@@ -2924,20 +2918,16 @@ WERROR winreg_printer_deleteform1(TALLOC_CTX *mem_ctx,
                goto done;
        }
 
-       if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+       if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                result = WERR_INVALID_FORM_NAME;
        }
 
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -2950,7 +2940,8 @@ WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
                               struct spoolss_AddFormInfo1 *form)
 {
        uint32_t access_mask = SEC_FLAG_MAXIMUM_ALLOWED;
-       struct policy_handle hive_hnd, key_hnd;
+       struct policy_handle hive_hnd = { 0, };
+       struct policy_handle key_hnd = { 0, };
        struct winreg_String wvalue = { 0, };
        DATA_BLOB blob;
        uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
@@ -2961,14 +2952,14 @@ WERROR winreg_printer_setform1(TALLOC_CTX *mem_ctx,
 
        for (i = 0; i < num_builtin; i++) {
                if (strequal(builtin_forms1[i].form_name, form->form_name)) {
-                       result = WERR_INVALID_PARAM;
+                       result = WERR_INVALID_PARAMETER;
                        goto done;
                }
        }
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -3056,6 +3047,7 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
        uint32_t num_builtin = ARRAY_SIZE(builtin_forms1);
        uint32_t i;
        WERROR result;
+       WERROR ignore;
        NTSTATUS status;
        TALLOC_CTX *tmp_ctx;
 
@@ -3069,7 +3061,7 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        ZERO_STRUCT(hive_hnd);
@@ -3117,7 +3109,7 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
 
        data_in = (uint8_t *) TALLOC(tmp_ctx, data_in_size);
        if (data_in == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
        value_len = 0;
@@ -3143,7 +3135,7 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
 
        r->form_name = talloc_strdup(mem_ctx, form_name);
        if (r->form_name == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -3158,15 +3150,11 @@ WERROR winreg_printer_getform1(TALLOC_CTX *mem_ctx,
 
        result = WERR_OK;
 done:
-       if (winreg_handle != NULL) {
-               WERROR ignore;
-
-               if (is_valid_policy_hnd(&key_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
-               }
-               if (is_valid_policy_hnd(&hive_hnd)) {
-                       dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
-               }
+       if (is_valid_policy_hnd(&key_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &key_hnd, &ignore);
+       }
+       if (is_valid_policy_hnd(&hive_hnd)) {
+               dcerpc_winreg_CloseKey(winreg_handle, tmp_ctx, &hive_hnd, &ignore);
        }
 
        TALLOC_FREE(tmp_ctx);
@@ -3197,7 +3185,7 @@ WERROR winreg_add_driver(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        result = winreg_printer_opendriver(tmp_ctx,
@@ -3538,7 +3526,7 @@ WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        if (driver_version == DRIVER_ANY_VERSION) {
@@ -3604,7 +3592,7 @@ WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
                                        struct spoolss_PrinterEnumValues,
                                        num_values);
        if (enum_values == NULL){
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -3621,19 +3609,19 @@ WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
 
        info8 = talloc_zero(tmp_ctx, struct spoolss_DriverInfo8);
        if (info8 == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
        info8->driver_name = talloc_strdup(info8, driver_name);
        if (info8->driver_name == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
        info8->architecture = talloc_strdup(info8, architecture);
        if (info8->architecture == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -3648,7 +3636,7 @@ WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
                result = winreg_enumval_to_dword(info8, v,
                                                 "Version",
                                                 &tmp);
-               if (NT_STATUS_IS_OK(result)) {
+               if (W_ERROR_IS_OK(result)) {
                        info8->version = (enum spoolss_DriverOSVersion) tmp;
                }
                CHECK_ERROR(result);
@@ -3706,7 +3694,7 @@ WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
                                              "DriverVersion",
                                              &tmp_str);
                if (W_ERROR_IS_OK(result)) {
-                       result = winreg_printer_ver_to_dword(tmp_str,
+                       result = winreg_printer_ver_to_qword(tmp_str,
                                                &info8->driver_version);
                }
                CHECK_ERROR(result);
@@ -3774,7 +3762,7 @@ WERROR winreg_get_driver(TALLOC_CTX *mem_ctx,
                                              "MinInboxDriverVerVersion",
                                              &tmp_str);
                if (W_ERROR_IS_OK(result)) {
-                       result = winreg_printer_ver_to_dword(tmp_str,
+                       result = winreg_printer_ver_to_qword(tmp_str,
                                        &info8->min_inbox_driver_ver_version);
                }
                CHECK_ERROR(result);
@@ -3822,7 +3810,7 @@ WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        /* test that the key exists */
@@ -3836,7 +3824,7 @@ WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
                                           &key_hnd);
        if (!W_ERROR_IS_OK(result)) {
                /* key doesn't exist */
-               if (W_ERROR_EQUAL(result, WERR_BADFILE)) {
+               if (W_ERROR_EQUAL(result, WERR_FILE_NOT_FOUND)) {
                        result = WERR_OK;
                        goto done;
                }
@@ -3859,7 +3847,7 @@ WERROR winreg_del_driver(TALLOC_CTX *mem_ctx,
                                   info8->architecture, version,
                                   info8->driver_name);
        if (key_name == NULL) {
-               result = WERR_NOMEM;
+               result = WERR_NOT_ENOUGH_MEMORY;
                goto done;
        }
 
@@ -3925,7 +3913,7 @@ WERROR winreg_get_driver_list(TALLOC_CTX *mem_ctx,
 
        tmp_ctx = talloc_stackframe();
        if (tmp_ctx == NULL) {
-               return WERR_NOMEM;
+               return WERR_NOT_ENOUGH_MEMORY;
        }
 
        /* use NULL for the driver name so we open the key that is