VOID NTAPI LsaIFree_LSAPR_REFERENCED_DOMAIN_LIST( IN PLSAPR_REFERENCED_DOMAIN_LIST Ptr) { ULONG i; if (Ptr != NULL) { if (Ptr->Domains != NULL) { for (i = 0; i < Ptr->Entries; i++) { if (Ptr->Domains[i].Name.Buffer != NULL) midl_user_free(Ptr->Domains[i].Name.Buffer); if (Ptr->Domains[i].Sid != NULL) midl_user_free(Ptr->Domains[i].Sid); } midl_user_free(Ptr->Domains); } midl_user_free(Ptr); } }
NTSTATUS SampRemoveAllMembersFromAlias(IN PSAM_DB_OBJECT AliasObject) { HANDLE MembersKeyHandle = NULL; PSAMPR_SID_INFORMATION MemberArray = NULL; ULONG MemberCount = 0; ULONG Index; NTSTATUS Status; TRACE("(%p)\n", AliasObject); /* Open the members key of the alias object */ Status = SampRegOpenKey(AliasObject->KeyHandle, L"Members", KEY_READ, &MembersKeyHandle); if (!NT_SUCCESS(Status)) { ERR("SampRegOpenKey failed (Status 0x%08lx)\n", Status); goto done; } /* Get a list of all members of the alias */ Status = SampGetMembersInAlias(AliasObject, &MemberCount, &MemberArray); if (!NT_SUCCESS(Status)) { ERR("SampGetMembersInAlias failed (Status 0x%08lx)\n", Status); goto done; } /* Remove all members from the alias */ for (Index = 0; Index < MemberCount; Index++) { Status = SampRemoveMemberFromAlias(AliasObject, MemberArray[Index].SidPointer); if (!NT_SUCCESS(Status)) goto done; } done: if (MemberArray != NULL) { for (Index = 0; Index < MemberCount; Index++) { if (MemberArray[Index].SidPointer != NULL) midl_user_free(MemberArray[Index].SidPointer); } midl_user_free(MemberArray); } SampRegCloseKey(&MembersKeyHandle); return Status; }
void XProcNumberPageSegmentManager::GetFreeSegment(XProcNumberPageSegment * seg) { AutoCriticalSection autoCS(&cs); if (segmentsList == nullptr) { new (seg) XProcNumberPageSegmentImpl(); return; } auto temp = segmentsList; auto prev = &segmentsList; while (temp) { if (temp->allocEndAddress != temp->pageAddress + (int)(XProcNumberPageSegmentImpl::PageCount*AutoSystemInfo::PageSize)) // not full { *prev = (XProcNumberPageSegmentImpl*)temp->nextSegment; // remove from the list memcpy(seg, temp, sizeof(XProcNumberPageSegment)); midl_user_free(temp); return; } prev = (XProcNumberPageSegmentImpl**)&temp->nextSegment; temp = (XProcNumberPageSegmentImpl*)temp->nextSegment; } }
VOID NTAPI LsaIFree_LSAPR_CR_CIPHER_VALUE( IN PLSAPR_CR_CIPHER_VALUE Ptr) { if (Ptr != NULL) midl_user_free(Ptr); }
VOID NTAPI LsaIFree_LSAPR_PRIVILEGE_SET(IN PLSAPR_PRIVILEGE_SET Ptr) { if (Ptr != NULL) { midl_user_free(Ptr); } }
XProcNumberPageSegmentManager::~XProcNumberPageSegmentManager() { auto temp = segmentsList; while (temp) { auto next = temp->nextSegment; midl_user_free(temp); temp = (XProcNumberPageSegmentImpl*)next; } }
VOID NTAPI LsaIFree_LSAPR_ACCOUNT_ENUM_BUFFER( IN PLSAPR_ACCOUNT_ENUM_BUFFER Ptr) { ULONG i; if (Ptr == NULL) return; if (Ptr->Information != NULL) { for (i = 0; i < Ptr->EntriesRead; i++) midl_user_free(Ptr->Information[i].Sid); midl_user_free(Ptr->Information); } midl_user_free(Ptr); }
VOID NTAPI LsaIFree_LSAPR_PRIVILEGE_ENUM_BUFFER( IN PLSAPR_PRIVILEGE_ENUM_BUFFER Ptr) { ULONG i; if (Ptr != NULL) { if (Ptr->Privileges != NULL) { for (i = 0; i < Ptr->Entries; i++) { if (Ptr->Privileges[i].Name.Buffer != NULL) midl_user_free(Ptr->Privileges[i].Name.Buffer); } midl_user_free(Ptr->Privileges); } } }
/* The rundown routine is associated with the context handle type. */ void __RPC_USER PCONTEXT_HANDLE_TYPE_rundown(PCONTEXT_HANDLE_TYPE phContext) { FILE_CONTEXT_TYPE *pFileContext; printf_s("Context rundown routine\n"); if ( phContext ) { pFileContext = (FILE_CONTEXT_TYPE *) phContext; if (pFileContext->hFile != NULL) fclose(pFileContext->hFile); midl_user_free( phContext ); } }
/* This remote procedure closes a file on the server. */ short RemoteClose(PCONTEXT_HANDLE_TYPE *pphContext) { FILE_CONTEXT_TYPE *pFileContext; printf_s("in RemoteClose\n"); pFileContext = (FILE_CONTEXT_TYPE *) *pphContext; if ( fclose( pFileContext->hFile ) == 0) { midl_user_free( *pphContext ); *pphContext = NULL; return(0); } else /* Context Rundown routine will attempt to close it again */ return(-1); }
void XProcNumberPageSegmentManager::Integrate() { AutoCriticalSection autoCS(&cs); auto temp = this->segmentsList; auto prev = &this->segmentsList; while (temp) { if (temp->pageSegment == 0) { auto leafPageAllocator = recycler->GetRecyclerLeafPageAllocator(); DListBase<PageSegment> segmentList; temp->pageSegment = (intptr_t)leafPageAllocator->AllocPageSegment(segmentList, leafPageAllocator, (void*)temp->pageAddress, XProcNumberPageSegmentImpl::PageCount, temp->committedEnd / AutoSystemInfo::PageSize); leafPageAllocator->IntegrateSegments(segmentList, 1, XProcNumberPageSegmentImpl::PageCount); this->integratedSegmentCount++; } unsigned int minIntegrateSize = XProcNumberPageSegmentImpl::BlockSize; for (; temp->pageAddress + temp->blockIntegratedSize + minIntegrateSize < (unsigned int)temp->allocEndAddress; temp->blockIntegratedSize += minIntegrateSize) { TRACK_ALLOC_INFO(recycler, Js::JavascriptNumber, Recycler, 0, (size_t)-1); if (!recycler->IntegrateBlock<LeafBit>((char*)temp->pageAddress + temp->blockIntegratedSize, (PageSegment*)temp->pageSegment, XProcNumberPageSegmentImpl::GetSizeCat(), sizeof(Js::JavascriptNumber))) { Js::Throw::OutOfMemory(); } } *prev = (XProcNumberPageSegmentImpl*)temp->nextSegment; midl_user_free(temp); temp = *prev; } }
VOID NTAPI LsaIFree_LSAPR_POLICY_INFORMATION(IN POLICY_INFORMATION_CLASS InformationClass, IN PLSAPR_POLICY_INFORMATION PolicyInformation) { if (PolicyInformation != NULL) { switch (InformationClass) { case PolicyAuditLogInformation: /* 1 */ break; case PolicyAuditEventsInformation: /* 2 */ if (PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions != NULL) midl_user_free(PolicyInformation->PolicyAuditEventsInfo.EventAuditingOptions); break; case PolicyPrimaryDomainInformation: /* 3 */ if (PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer != NULL) midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Name.Buffer); if (PolicyInformation->PolicyPrimaryDomInfo.Sid != NULL) midl_user_free(PolicyInformation->PolicyPrimaryDomInfo.Sid); break; case PolicyPdAccountInformation: /* 4 */ if (PolicyInformation->PolicyPdAccountInfo.Name.Buffer != NULL) midl_user_free(PolicyInformation->PolicyPdAccountInfo.Name.Buffer); break; case PolicyAccountDomainInformation: /* 5 */ if (PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyAccountDomainInfo.DomainName.Buffer); if (PolicyInformation->PolicyAccountDomainInfo.Sid != NULL) midl_user_free(PolicyInformation->PolicyAccountDomainInfo.Sid); break; case PolicyLsaServerRoleInformation: /* 6 */ break; case PolicyReplicaSourceInformation: /* 7 */ if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer != NULL) midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaSource.Buffer); if (PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyReplicaSourceInfo.ReplicaAccountName.Buffer); break; case PolicyDefaultQuotaInformation: /* 8 */ break; case PolicyModificationInformation: /* 9 */ break; case PolicyAuditFullSetInformation: /* 10 (0xA) */ break; case PolicyAuditFullQueryInformation: /* 11 (0xB) */ break; case PolicyDnsDomainInformation: /* 12 (0xC) */ if (PolicyInformation->PolicyDnsDomainInfo.Name.Buffer != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Name.Buffer); if (PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsDomainName.Buffer); if (PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfo.DnsForestName.Buffer); if (PolicyInformation->PolicyDnsDomainInfo.Sid != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfo.Sid); break; case PolicyDnsDomainInformationInt: /* 13 (0xD) */ if (PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Name.Buffer); if (PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsDomainName.Buffer); if (PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.DnsForestName.Buffer); if (PolicyInformation->PolicyDnsDomainInfoInt.Sid != NULL) midl_user_free(PolicyInformation->PolicyDnsDomainInfoInt.Sid); break; case PolicyLocalAccountDomainInformation: /* 14 (0xE) */ if (PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer != NULL) midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.DomainName.Buffer); if (PolicyInformation->PolicyLocalAccountDomainInfo.Sid != NULL) midl_user_free(PolicyInformation->PolicyLocalAccountDomainInfo.Sid); break; default: ERR("Invalid InformationClass: %lu\n", InformationClass); break; } midl_user_free(PolicyInformation); } }
void __cdecl main(int argc, char **argv) { RPC_STATUS status; unsigned char * pbPicklingBuffer = NULL; char * pszStyle = NULL; char * pszFileName = "pickle.dat"; int i; int fEncode = 1; int fFixedStyle = 1; /* allow the user to override settings with command line switches */ for (i = 1; i < argc; i++) { if ((*argv[i] == '-') || (*argv[i] == '/')) { switch (tolower(*(argv[i]+1))) { case 'd': fEncode = 0; break; case 'e': fEncode = 1; break; case 'i': fFixedStyle = 0; break; case 'f': pszFileName = argv[i] + 2; break; case 'h': case '?': default: Usage(argv[0]); } } else Usage(argv[0]); } /* Fixed buffer style: the buffer should be big enough. */ /* Please note that the buffer has to be aligned at 8. */ pbPicklingBuffer = (unsigned char *) midl_user_allocate( BUFSIZE * sizeof(unsigned char)); if ( pbPicklingBuffer == NULL ) { printf_s("Cannot allocate the pickling buffer\n"); exit(1); } else memset( pbPicklingBuffer, 0xdd, BUFSIZE ); /* Set the pickling handle that will be used for data serialization. The global ImplicitPicHandle is used, but it has to be set up. */ if ( fEncode ) { unsigned char * pszNameId; OBJECT1 Object1; OBJECT2 * pObject2; unsigned long ulEncodedSize = 0; printf_s("\nEncoding run: use -d for decoding\n\n"); if ( fFixedStyle ) { printf_s("Creating a fixed buffer encoding handle\n"); status = MesEncodeFixedBufferHandleCreate( pbPicklingBuffer, BUFSIZE, & ulEncodedSize, & ImplicitPicHandle ); printf_s("MesEncodeFixedBufferHandleCreate returned 0x%x\n", status); if (status) { exit(status); } } else { pUserState->LastSize = 0; pUserState->pMemBuffer = (char *)pbPicklingBuffer; pUserState->pBufferStart = (char *)pbPicklingBuffer; printf_s("Creating an incremental encoding handle\n"); status = MesEncodeIncrementalHandleCreate( pUserState, PicAlloc, PicWrite, & ImplicitPicHandle ); printf_s("MesEncodeIncrementalHandleCreate returned 0x%x\n", status); if (status) { exit(status); } } /* Creating objects to manipulate */ pszNameId = "Procedure pickling sample"; for (i = 0; i < ARR_SIZE; i++) Object1.al[i] = 0x37370000 + i; Object1.s = 0x4646; pObject2 = midl_user_allocate( sizeof(OBJECT2) + ARR_SIZE*sizeof(short) ); if (pObject2 == NULL ) { printf_s("Out of memory for Object2\n"); exit(1); } pObject2->sSize = ARR_SIZE; for (i = 0; i < ARR_SIZE; i++) pObject2->as[i] = 0x7700 + i; DumpData( "Data to be encoded", pszNameId, &Object1, pObject2 ); printf_s("\nEncoding all the arguments to the buffer\n\n"); ProcPickle( pszNameId, & Object1, pObject2 ); printf_s("Writing the data to the file: %s\n", pszFileName); WriteDataToFile( pszFileName, pbPicklingBuffer, fFixedStyle ? ulEncodedSize : pUserState->LastSize); midl_user_free( pObject2 ); } else { char acNameBuffer[50]; OBJECT1 Object1; OBJECT2 * pObject2; printf_s("\nDecoding run: use -e for encoding\n\n"); printf_s("Reading the data from the file: %s\n\n", pszFileName ); ReadDataFromFile( pszFileName, pbPicklingBuffer, BUFSIZE ); if ( fFixedStyle ) { printf_s("Creating a decoding handle\n"); status = MesDecodeBufferHandleCreate( pbPicklingBuffer, BUFSIZE, & ImplicitPicHandle ); printf_s("MesDecodeFixedBufferHandleCreate returned 0x%x\n", status); if (status) { exit(status); } } else { pUserState->LastSize = 0; pUserState->pMemBuffer = (char *)pbPicklingBuffer; pUserState->pBufferStart = (char *)pbPicklingBuffer; printf_s("Creating an incremental decoding handle\n"); status = MesDecodeIncrementalHandleCreate( pUserState, PicRead, & ImplicitPicHandle ); printf_s("MesDecodeIncrementalHandleCreate returned 0x%x\n", status); if (status) { exit(status); } } /* Creating objects to manipulate */ pObject2 = midl_user_allocate( sizeof(OBJECT2) + ARR_SIZE*sizeof(short)); if (pObject2 == NULL ) { printf_s("Out of memory for Object2\n"); exit(1); } printf_s("\nDecoding all the arguments from the buffer\n"); ProcPickle( acNameBuffer, & Object1, pObject2 ); DumpData( "Decoded data", acNameBuffer, &Object1, pObject2 ); midl_user_free( pObject2 ); } printf_s("\nData serialization done.\n"); midl_user_free( pbPicklingBuffer ); printf_s("\nFreeing the serialization handle.\n"); status = MesHandleFree( ImplicitPicHandle ); printf_s("MesHandleFree returned 0x%x\n", status); exit(0); } // end main()
static void basic_tests(void) { char string[] = "I am a string"; WCHAR wstring[] = {'I',' ','a','m',' ','a',' ','w','s','t','r','i','n','g', 0}; int f[5] = {1, 3, 0, -2, -4}; vector_t a = {1, 3, 7}; vector_t vec1 = {4, -2, 1}, vec2 = {-5, 2, 3}, *pvec2 = &vec2; pvectors_t pvecs = {&vec1, &pvec2}; sp_inner_t spi = {42}; sp_t sp = {-13, &spi}; aligns_t aligns; pints_t pints; ptypes_t ptypes; padded_t padded; padded_t padded2[2]; bogus_t bogus; int i1, i2, i3, *pi2, *pi3, **ppi3; double u, v; float s, t; LONG q, r; short h; char c; int x; str_struct_t ss = {string}; wstr_struct_t ws = {wstring}; str_t str; se_t se; renum_t re; ok(int_return() == INT_CODE, "RPC int_return\n"); ok(square(7) == 49, "RPC square\n"); ok(sum(23, -4) == 19, "RPC sum\n"); x = 0; square_out(11, &x); ok(x == 121, "RPC square_out\n"); x = 5; square_ref(&x); ok(x == 25, "RPC square_ref\n"); ok(str_length(string) == strlen(string), "RPC str_length\n"); ok(str_t_length(string) == strlen(string), "RPC str_length\n"); ok(dot_self(&a) == 59, "RPC dot_self\n"); ok(str_struct_len(&ss) == lstrlenA(string), "RPC str_struct_len\n"); ok(wstr_struct_len(&ws) == lstrlenW(wstring), "RPC str_struct_len\n"); v = 0.0; u = square_half(3.0, &v); ok(u == 9.0, "RPC square_half\n"); ok(v == 1.5, "RPC square_half\n"); t = 0.0f; s = square_half_float(3.0f, &t); ok(s == 9.0f, "RPC square_half_float\n"); ok(t == 1.5f, "RPC square_half_float\n"); r = 0; q = square_half_long(3, &r); ok(q == 9, "RPC square_half_long\n"); ok(r == 1, "RPC square_half_long\n"); i1 = 19; i2 = -3; i3 = -29; pi2 = &i2; pi3 = &i3; ppi3 = &pi3; pints.pi = &i1; pints.ppi = &pi2; pints.pppi = &ppi3; ok(pints_sum(&pints) == -13, "RPC pints_sum\n"); c = 10; h = 3; q = 14; s = -5.0f; u = 11.0; ptypes.pc = &c; ptypes.ps = &h; ptypes.pl = &q; ptypes.pf = &s; ptypes.pd = &u; ok(ptypes_sum(&ptypes) == 33.0, "RPC ptypes_sum\n"); ok(dot_pvectors(&pvecs) == -21, "RPC dot_pvectors\n"); ok(dot_copy_vectors(vec1, vec2) == -21, "RPC dot_copy_vectors\n"); ok(sum_fixed_array(f) == -2, "RPC sum_fixed_array\n"); ok(sum_sp(&sp) == 29, "RPC sum_sp\n"); ok(enum_ord(E1) == 1, "RPC enum_ord\n"); ok(enum_ord(E2) == 2, "RPC enum_ord\n"); ok(enum_ord(E3) == 3, "RPC enum_ord\n"); ok(enum_ord(E4) == 4, "RPC enum_ord\n"); se.f = E2; check_se2(&se); memset(&aligns, 0, sizeof(aligns)); aligns.c = 3; aligns.i = 4; aligns.s = 5; aligns.d = 6.0; ok(sum_aligns(&aligns) == 18.0, "RPC sum_aligns\n"); padded.i = -3; padded.c = 8; ok(sum_padded(&padded) == 5, "RPC sum_padded\n"); padded2[0].i = -5; padded2[0].c = 1; padded2[1].i = 3; padded2[1].c = 7; ok(sum_padded2(padded2) == 6, "RPC sum_padded2\n"); padded2[0].i = -5; padded2[0].c = 1; padded2[1].i = 3; padded2[1].c = 7; ok(sum_padded_conf(padded2, 2) == 6, "RPC sum_padded_conf\n"); i1 = 14; i2 = -7; i3 = -4; bogus.h.p1 = &i1; bogus.p2 = &i2; bogus.p3 = &i3; bogus.c = 9; ok(sum_bogus(&bogus) == 12, "RPC sum_bogus\n"); check_null(NULL); str = get_filename(); ok(!strcmp(str, __FILE__), "get_filename() returned %s instead of %s\n", str, __FILE__); midl_user_free(str); x = echo_ranged_int(0); ok(x == 0, "echo_ranged_int() returned %d instead of 0\n", x); x = echo_ranged_int(100); ok(x == 100, "echo_ranged_int() returned %d instead of 100\n", x); if (!old_windows_version) { get_ranged_enum(&re); ok(re == RE3, "get_ranged_enum() returned %d instead of RE3\n", re); } }
LRESULT RemoteKeyboard::OnUpdateStatus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandle) { static bool _last_enabled = true; bool _enable = (wParam != 0); unsigned int _check_value = (unsigned int)(lParam); TCHAR name[32]; if (_last_enabled != _enable) { _last_enabled = _enable; for (int i = 1;; ++i) { _stprintf_s(name, sizeof(name) / sizeof(TCHAR), _T("rkbc_%02d"), i); if (!EnableControl(name, _last_enabled)) break; } } if (_last_enabled) { unsigned int _recode_status = _check_value & 0x3; unsigned int _ch_status = (_check_value >> 2) & 0xf; unsigned int _director_status = (_check_value >> 6) & 0x3; for (int i = 1; i < 14; ++i) { _stprintf_s(name, sizeof(name) / sizeof(TCHAR), _T("rkbc_%02d"), i); if (i < 4) { EnableControl(name, _recode_status != i); } else if (i < 12) { EnableControl(name, _ch_status != i - 3); } else { EnableControl(name, _director_status != i - 11); } } } auto _GetExtendInfoWrap = [this](byte* &pBuf, long &nSize) -> boolean { boolean ret = false; RpcTryExcept ret = rkbc_GetExtendInfo(m_hwBinding, kExtendType_LessionInfo, __int64(m_lession_info_checksum), &pBuf, &nSize); RpcExcept(1) ret = false; RpcEndExcept return ret; }; /* 如果同步排课界面不处于显示状态,则不刷新 */ if (!m_PaintManager.FindControl(_T("sync_panel"))->IsVisible()) return 0; byte *pBuf = 0; long nSize = 0; if (_enable && _GetExtendInfoWrap(pBuf, nSize) && pBuf) { auto const &items = g_LessionMappingTable; pugi::xml_document doc; if (doc.load(LPCTSTR(pBuf))) { pugi::xml_node elem = doc.child(_T("lesson")); if (elem) { for (int i = 0; i < _countof(items); ++i) { DuiLib::CControlUI *ctrl; if (ctrl = m_PaintManager.FindControl(items[i].name)) ctrl->SetText(elem.attribute(items[i].attr).as_string()); } m_lession_info = LPCTSTR(pBuf); boost::crc_32_type result; result.process_bytes(reinterpret_cast<const byte *>(m_lession_info.data()), (m_lession_info.size() + 1) * sizeof(wchar_t)); m_lession_info_checksum = result.checksum(); } } midl_user_free(pBuf); } return LRESULT(); }