FX_BOOL CPDF_SecurityHandler::OnInit(CPDF_Parser* pParser, CPDF_Dictionary* pEncryptDict) { m_pParser = pParser; if (!LoadDict(pEncryptDict)) { return FALSE; } if (m_Cipher == FXCIPHER_NONE) { return TRUE; } return CheckSecurity(m_KeyLen); }
// // FUNCTION: DoTimings // // PURPOSE: Calls and times various RPC calls. // (Avoid cluttering up main()) // // PARAMETERS: // Binding - Binding to the server. // iIterations - Number of times to make each call. // // RETURN VALUE: // n/a // // void DoTimings(RPC_BINDING_HANDLE Binding, UINT iIterations) { ULONG mseconds; UINT i; RPC_STATUS status; byte bBuffer[4096]; ULONG lBufferLength; ULONG lBufferSize; // Time Pings() (void calls) StartTime(); for(i = iIterations; i; i--) { status = Ping(Binding); if (status != RPC_S_OK) goto Cleanup; } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - void calls.\n", iIterations, mseconds); // Time [in] buffer's // lBufferLength = BUFFER_SIZE; lBufferSize = BUFFER_SIZE; StartTime(); for(i = iIterations; i; i--) { status = BufferIn1(Binding, bBuffer, lBufferLength, lBufferSize); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer in (1).\n", iIterations, mseconds); lBufferLength = BUFFER_SIZE; StartTime(); for(i = iIterations; i; i--) { status = BufferIn3(Binding, bBuffer, lBufferLength); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer in (2).\n", iIterations, mseconds); lBufferLength = BUFFER_SIZE; StartTime(); for(i = iIterations; i; i--) { status = BufferIn3(Binding, bBuffer, lBufferLength); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer in (3).\n", iIterations, mseconds); // Time [out] buffer's lBufferLength = BUFFER_SIZE; StartTime(); for(i = iIterations; i; i--) { status = BufferOut1(Binding, bBuffer, &lBufferLength); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer out (1).\n", iIterations, mseconds); lBufferLength = BUFFER_SIZE; lBufferSize = BUFFER_SIZE; StartTime(); for(i = iIterations; i; i--) { status = BufferOut2(Binding, bBuffer, lBufferSize, &lBufferLength); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer out (2).\n", iIterations, mseconds); StartTime(); for(i = iIterations; i; i--) { BUFFER Buffer; Buffer.BufferLength = 0; Buffer.Buffer = 0; status = BufferOut3(Binding, &Buffer); if (status != RPC_S_OK) { goto Cleanup; } MIDL_user_free(Buffer.Buffer); } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer out (3).\n", iIterations, mseconds); lBufferLength = BUFFER_SIZE; StartTime(); for(i = iIterations; i; i--) { status = BufferOut4(Binding, bBuffer, &lBufferLength); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 100 byte buffer out (4).\n", iIterations, mseconds); // Time arrays of structures { struct BAD1 abad1[50]; struct BAD2 abad2[50]; struct GOOD agood[50]; for (i = 0; i < 50; i++) { abad2[i].e = (BAD_ENUM)i % 4 + 1; agood[i].e = (GOOD_ENUM)i % 4 + 5; } StartTime(); for(i = iIterations; i; i--) { status = StructsIn1(Binding, &abad1[0]); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - 2 mod 4 aligned structs.\n", iIterations, mseconds); StartTime(); for(i = iIterations; i; i--) { status = StructsIn2(Binding, &abad2[0]); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - structs with an enum.\n", iIterations, mseconds); StartTime(); for(i = iIterations; i; i--) { status = StructsIn3(Binding, &agood[0]); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - structs with v1_enum.\n", iIterations, mseconds); } // Linked lists { LIST list; PLIST plist = &list; for (i = 0; i < LIST_SIZE - 1; i++) { plist->pNext = MIDL_user_allocate(sizeof(LIST)); plist->data = i; if (plist->pNext == 0) { status = RPC_S_OUT_OF_MEMORY; goto Cleanup; } plist = plist->pNext; } plist->data = i; plist->pNext = 0; StartTime(); for(i = iIterations; i; i--) { status = ListIn(Binding, &list); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - [in] linked list.\n", iIterations, mseconds); StartTime(); for(i = iIterations; i; i--) { status = ListOut1(Binding, &list); if (status != RPC_S_OK) { goto Cleanup; } // Freeing the list here would cause all the elements // to be allocated again on the next call. } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - [out] linked list (1).\n", iIterations, mseconds); StartTime(); for(i = iIterations; i; i--) { status = ListOut2(Binding, &list); if (status != RPC_S_OK) { goto Cleanup; } // Freeing the list here would cause all the elements // to be allocated again on the next call. } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - [out] linked list (2).\n", iIterations, mseconds); // Free allocated elements of the list. plist = list.pNext; while(plist) { PLIST tmp = plist; plist = plist->pNext; MIDL_user_free(tmp); } } // Unions { BAD_UNION badunionArray[UNION_ARRAY_LEN]; GOOD_UNION goodunion; ARM_ONE armone; ULONG ulArray[UNION_ARRAY_LEN]; goodunion.Tag = 1; goodunion.u.pOne = &armone; armone.DataLength = UNION_ARRAY_LEN; armone.Data = ulArray; for(i = 0; i < UNION_ARRAY_LEN; i++) { ulArray[i] = i; badunionArray[i].Tag = 1; badunionArray[i].u.ulData = i; } StartTime(); for(i = iIterations; i; i--) { status = UnionCall1(Binding, UNION_ARRAY_LEN, badunionArray); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - [in] array of unions.\n", iIterations, mseconds); StartTime(); for(i = iIterations; i; i--) { status = UnionCall2(Binding, &goodunion); if (status != RPC_S_OK) { goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - [in] union of arrays.\n", iIterations, mseconds); } // Time pings() (null calls) which impersonate the client. StartTime(); for(i = iIterations; i; i--) { status = CheckSecurity(Binding); if (status != RPC_S_OK) { if (status == RPC_S_ACCESS_DENIED) { printf("Access denied, try -s 2 or higher.\n"); return; } goto Cleanup; } } mseconds = EndTime(); printf("%4d calls in %8d milliseconds - void call w/ impersonation\n", iIterations, mseconds); Cleanup: if (status != RPC_S_OK) { printf("Call failed - %d\n", status); } return; }