Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 228121
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T19:39:20+00:00 2026-05-11T19:39:20+00:00

Buffer overrun problems are well known. Thus we were blessed with standard library functions

  • 0

Buffer overrun problems are well known. Thus we were blessed with standard library functions such as wcscat_s(). And the kind folks at Microsoft have created similar safe string functions such as as StringCbCat().

But I have a problem where I need to search a bit of memory for a string. The Standard library function:

wcsstr( wchar_t* pMem, wchar_t* pStr ) 

seems great, but…
Sometimes my memory contains garbage, sometimes strings. And when it is garbage I sometimes run off an allocated memory page, [=Access Violation]. I can write my own function yes. But my question is if there is any “standard” function to do safe string search such as:

"wcsstr_s( wchar_t* pMem, size_t uiSize, wchar_t* pStr )" ?

Thanx

[EDIT]
Thanks and kudos to Charles Bailey for a perfect answer to my question. Thanks to others for their efforts too.

And to those of you who doubted the saneness of my scenario: Yes of course it would be good to not ever have garbage in my memory. But I can imagine several scenarios where this situation could occur. In my particular case it is reverse-engineering, and the memory I am serching is in fact not “my memory”, it belongs to another process which I cannot control.

(One other hypothetical scenario could be a tricky debugging situation where corrupted memory needs to be tracked down.)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T19:39:20+00:00Added an answer on May 11, 2026 at 7:39 pm

    Assuming that your pStr is null terminated and that uiSize is the number of wchar_t of readable memory at pMem:

    wchar_t* pSubStr = std::search( pMem, pMem + uiSize, pStr, pStr + std::wcslen( pStr ) );
    
    // Optionally, change to the 'conventional' strstr return value
    if( pSubStr == pMem + uiSize)
        pSubStr = 0;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 120k
  • Answers 120k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Place the row in a grid and set it's height… May 12, 2026 at 12:07 am
  • Editorial Team
    Editorial Team added an answer The best practice, at least for the moment, is to… May 12, 2026 at 12:07 am
  • Editorial Team
    Editorial Team added an answer In general, use a test data file only when it's… May 12, 2026 at 12:07 am

Related Questions

I have a COM interface with a following method definition (IDL notation): SCODE GetText( [in,
My friend produced a small proof-of-concept assembler that worked on x86. I decided to
I'm looking for a way to convert a preprocessor token to a string. Specifically,
Can there be buffer overflow/overrun vulnerabilities in completely managed asp.net web portal.If yes how

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.