DWORD _RpcEnumPrinters(DWORD Flags, WINSPOOL_HANDLE Name, DWORD Level, BYTE* pPrinterEnum, DWORD cbBuf, DWORD* pcbNeeded, DWORD* pcReturned) { DWORD dwErrorCode; PBYTE pPrinterEnumAligned; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) { ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); return dwErrorCode; } pPrinterEnumAligned = AlignRpcPtr(pPrinterEnum, &cbBuf); if (EnumPrintersW(Flags, Name, Level, pPrinterEnumAligned, cbBuf, pcbNeeded, pcReturned)) { // Replace absolute pointer addresses in the output by relative offsets. ASSERT(Level <= 9); MarshallDownStructuresArray(pPrinterEnumAligned, *pcReturned, pPrinterInfoMarshalling[Level]->pInfo, pPrinterInfoMarshalling[Level]->cbStructureSize, TRUE); } else { dwErrorCode = GetLastError(); } RpcRevertToSelf(); UndoAlignRpcPtr(pPrinterEnum, pPrinterEnumAligned, cbBuf, pcbNeeded); return dwErrorCode; }
DWORD _RpcEndPagePrinter(WINSPOOL_PRINTER_HANDLE hPrinter) { DWORD dwErrorCode; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) { ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); return dwErrorCode; } if (!EndPagePrinter(hPrinter)) dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; }
DWORD _RpcWritePrinter(WINSPOOL_PRINTER_HANDLE hPrinter, BYTE* pBuf, DWORD cbBuf, DWORD* pcWritten) { DWORD dwErrorCode; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) { ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); return dwErrorCode; } if (!WritePrinter(hPrinter, pBuf, cbBuf, pcWritten)) dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; }
DWORD _RpcStartDocPrinter(WINSPOOL_PRINTER_HANDLE hPrinter, WINSPOOL_DOC_INFO_CONTAINER* pDocInfoContainer, DWORD* pJobId) { DWORD dwErrorCode; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) { ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); return dwErrorCode; } *pJobId = StartDocPrinterW(hPrinter, pDocInfoContainer->Level, (PBYTE)pDocInfoContainer->DocInfo.pDocInfo1); dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; }
DWORD _RpcOpenPrinter(WINSPOOL_HANDLE pPrinterName, WINSPOOL_PRINTER_HANDLE* phPrinter, WCHAR* pDatatype, WINSPOOL_DEVMODE_CONTAINER* pDevModeContainer, DWORD AccessRequired) { DWORD dwErrorCode; PRINTER_DEFAULTSW Default; dwErrorCode = RpcImpersonateClient(NULL); if (dwErrorCode != ERROR_SUCCESS) { ERR("RpcImpersonateClient failed with error %lu!\n", dwErrorCode); return dwErrorCode; } Default.DesiredAccess = AccessRequired; Default.pDatatype = pDatatype; Default.pDevMode = (PDEVMODEW)pDevModeContainer->pDevMode; if (!OpenPrinterW(pPrinterName, phPrinter, &Default)) dwErrorCode = GetLastError(); RpcRevertToSelf(); return dwErrorCode; }
void s_authinfo_test(unsigned int protseq, int secure) { RPC_BINDING_HANDLE binding; RPC_STATUS status; ULONG level, authnsvc; RPC_AUTHZ_HANDLE privs; unsigned char *principal; binding = I_RpcGetCurrentCallHandle(); ok(binding != NULL, "I_RpcGetCurrentCallHandle returned NULL\n"); level = authnsvc = 0xdeadbeef; privs = (RPC_AUTHZ_HANDLE)0xdeadbeef; principal = (unsigned char *)0xdeadbeef; if (secure || protseq == RPC_PROTSEQ_LRPC) { status = RpcBindingInqAuthClientA(binding, &privs, &principal, &level, &authnsvc, NULL); if (status == RPC_S_CANNOT_SUPPORT) { win_skip("RpcBindingInqAuthClientA not supported\n"); return; } ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); ok(privs != (RPC_AUTHZ_HANDLE)0xdeadbeef, "privs unchanged\n"); ok(principal != (unsigned char *)0xdeadbeef, "principal unchanged\n"); if (protseq != RPC_PROTSEQ_LRPC) { todo_wine ok(principal != NULL, "NULL principal\n"); } if (protseq == RPC_PROTSEQ_LRPC && principal && pGetUserNameExA) { int len; char *spn; len = WideCharToMultiByte(CP_ACP, 0, (const WCHAR *)privs, -1, NULL, 0, NULL, NULL); spn = HeapAlloc( GetProcessHeap(), 0, len ); WideCharToMultiByte(CP_ACP, 0, (const WCHAR *)privs, -1, spn, len, NULL, NULL); ok(!strcmp(domain_and_user, spn), "expected %s got %s\n", domain_and_user, spn); HeapFree( GetProcessHeap(), 0, spn ); } ok(level == RPC_C_AUTHN_LEVEL_PKT_PRIVACY, "level unchanged\n"); ok(authnsvc == RPC_C_AUTHN_WINNT, "authnsvc unchanged\n"); status = RpcImpersonateClient(NULL); ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); status = RpcRevertToSelf(); ok(status == RPC_S_OK, "expected RPC_S_OK got %u\n", status); } else { status = RpcBindingInqAuthClientA(binding, &privs, &principal, &level, &authnsvc, NULL); ok(status == RPC_S_BINDING_HAS_NO_AUTH, "expected RPC_S_BINDING_HAS_NO_AUTH got %u\n", status); ok(privs == (RPC_AUTHZ_HANDLE)0xdeadbeef, "got %p\n", privs); ok(principal == (unsigned char *)0xdeadbeef, "got %s\n", principal); ok(level == 0xdeadbeef, "got %u\n", level); ok(authnsvc == 0xdeadbeef, "got %u\n", authnsvc); } }