Like Tree12Likes
  • 1 Post By Neo1
  • 4 Post By Neo1
  • 2 Post By iMalc
  • 2 Post By grumpy
  • 1 Post By iMalc
  • 2 Post By laserlight

Extracting emails from a win32 process using regular expresions

This is a discussion on Extracting emails from a win32 process using regular expresions within the C++ Programming forums, part of the General Programming Boards category; Hello programmers, As you can see This is my first post. And, Yes I am a noob and i know ...

  1. #1
    Registered User
    Join Date
    Nov 2012
    Posts
    6

    Extracting emails from a win32 process using regular expresions

    Hello programmers,
    As you can see This is my first post. And, Yes I am a noob and i know it, I'm currently learning C/C++, compared to what i know (perl,php,phyton scripts) somewhat difficult and for me C documentation is very bad.

    I need to modify this code I've found that works similar to what i need.
    Code:
    #include <iostream>
    #include <vector>
    #include <string>
    #include <windows.h>
    #include <algorithm>
    #include <iterator>
    
    template <class outIter>
    void find_locs(HANDLE process, std::string const &pattern, outIter output) {
    
        unsigned char *p = NULL;
        MEMORY_BASIC_INFORMATION info;
    
        // VirtualQueryEx does the hard part, telling use about each
        // block in the target process.
    
        for ( p = NULL;
            VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info);
            p += info.RegionSize )
        {
            // buffer to hold copies of memory blocks from the target
            std::vector<char> buffer;
            std::vector<char>::iterator pos;
    
            // We only want committed memory that's mapped or private --
            // screens out things like the code in the target process.
            //
            if (info.State == MEM_COMMIT &&
                (info.Type == MEM_MAPPED || info.Type == MEM_PRIVATE))
            {
                DWORD bytes_read;
    
                // copy block from target to our buffer, search for pattern:
                buffer.resize(info.RegionSize);
                ReadProcessMemory(process, p, &buffer[0], info.RegionSize, &bytes_read);
                buffer.resize(bytes_read);
    
                // find all occurrences of pattern in buffer:
                for ( pos = buffer.begin();
                    buffer.end()!=(pos=std::search(pos, buffer.end(), pattern.begin(), pattern.end()));
                    ++pos)
                {
                    // record each address in target where pattern was found:
                    *output++ = p+(pos-buffer.begin());
                }
            }
        }
    }
    
    int main(int argc, char **argv) {
        if (argc != 3) {
            fprintf(stderr, "Usage: %s <process ID> <pattern>", argv[0]);
            return 1;
        }
    
        // Read the target PID and search pattern:
        int pid;
        sscanf(argv[1], "%i", &pid);
        std::string pattern(argv[2]);
    
        // Open the target process with rights to read its information and memory:
        HANDLE process = OpenProcess(
            PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
            false,
            pid);
    
        // Find the locations, and write them to standard output, one per line:
        find_locs(process, pattern,
            std::ostream_iterator<void *>(std::cout, "\n"));
    
        return 0;
    }
    This CLI code will search for pattern in a target process and print address of locations.

    My friends (I hope it is not presumptuous to use this informality), the thing is i want to search in the process for ALL emails (using a regular expression in C++ without using libraries like boost if possible)?? and then print all emails found or write them to a file. Can some lady or gentlemen sort this out for this noob writing here?

    Thanks =)

  2. #2
    Registered User
    Join Date
    Nov 2012
    Posts
    6
    UPDATE: This will help but I'm really a big newbie to understand it well, sorry.
    Getting started with regular expressions using C++ TR1 extensions
    Can i have a hand?

  3. #3
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    First things first, what do you hope to accomplish by this? You are reading the memory contents of another process and then extracting all email addresses? This sounds suspicious at best, and malicious and/or criminal at worst.

    Secondly, why don't you want to use boost? It's (mostly) header only and very easy to use, also its quite well documented. Anyways, the answer to your question is right there in the link you posted, it should be painfully easy for you to use this function if you know C/C++ well enough to have authored that piece of code right there. But since you are here, now, asking for help, im lead to believe that you are not in fact learning C++ but rather, trying to alter some source code without bothering to learn the language by making us hold your hand.

    You must excuse this rather blunt reply, but until you've made clear your intentions, i don't think you will get much help here.

    Edit:

    For comic relief, (and for the sake of actually contributing something to the thread) here is a regular expression that matches all valid E-mail addresses:
    Code:
    (?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:
    \r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(
    ?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ 
    \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\0
    31]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\
    ](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+
    (?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:
    (?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)
    ?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\
    r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[
     \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)
    ?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t]
    )*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[
     \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*
    )(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t]
    )+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)
    *:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+
    |\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r
    \n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:
    \r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t
    ]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031
    ]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](
    ?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?
    :(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?
    :\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)|(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?
    :(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?
    [ \t]))*"(?:(?:\r\n)?[ \t])*)*:(?:(?:\r\n)?[ \t])*(?:(?:(?:[^()<>@,;:\\".\[\] 
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|
    \\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>
    @,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"
    (?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?
    :[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[
    \]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:[^()<>@,;:\\".\[\] \000-
    \031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(
    ?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)?[ \t])*(?:@(?:[^()<>@,;
    :\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([
    ^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\"
    .\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\
    ]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\
    [\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\
    r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] 
    \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]
    |\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?(?:[^()<>@,;:\\".\[\] \0
    00-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\
    .|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,
    ;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|"(?
    :[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*))*@(?:(?:\r\n)?[ \t])*
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t])*(?:[
    ^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\]
    ]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(?:\r\n)?[ \t])*)(?:,\s*(
    ?:(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(
    ?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[
    \["()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t
    ])*))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t
    ])+|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?
    :\.(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|
    \Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*|(?:
    [^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".\[\
    ]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)*\<(?:(?:\r\n)
    ?[ \t])*(?:@(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["
    ()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)
    ?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>
    @,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*(?:,@(?:(?:\r\n)?[
     \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,
    ;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\.(?:(?:\r\n)?[ \t]
    )*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\
    ".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*)*:(?:(?:\r\n)?[ \t])*)?
    (?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\["()<>@,;:\\".
    \[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])*)(?:\.(?:(?:
    \r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z|(?=[\[
    "()<>@,;:\\".\[\]]))|"(?:[^\"\r\\]|\\.|(?:(?:\r\n)?[ \t]))*"(?:(?:\r\n)?[ \t])
    *))*@(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])
    +|\Z|(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*)(?:\
    .(?:(?:\r\n)?[ \t])*(?:[^()<>@,;:\\".\[\] \000-\031]+(?:(?:(?:\r\n)?[ \t])+|\Z
    |(?=[\["()<>@,;:\\".\[\]]))|\[([^\[\]\r\\]|\\.)*\](?:(?:\r\n)?[ \t])*))*\>(?:(
    ?:\r\n)?[ \t])*))*)?;\s*)
    Last edited by Neo1; 11-24-2012 at 05:05 PM.
    rogster001 likes this.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  4. #4
    Registered User
    Join Date
    Nov 2012
    Posts
    6
    Correct all i need is in my own reply, (almighty google) i'm going to try it now. I think i wrote very clear what I'm hoping to accomplish, extract all emails from a win32 process with a regex, I kindly ask you to add something useful not just humorous post for the next time, i don't understand why you try to label me as a criminal, is learning and extracting emails from a process malicious or criminal? At least not in my books, sorry my dear friend.

    And last thanks for remembering me again that I am a lazy idiot and a noob in C++ and windows programming, I just look for tips, advises and guidance to modify this. I was naive saying don't want to use boost when i never tested any of them i just know its external lib, and that TR1 regex is somehow ported from boost and included in VC++ 2010 and faster i read.

    So help me and post a mod, rather than judge me, this is a forum not a court XD

    PD: I'm lost with this vectors and iterators things, I have to read more i guess...

  5. #5
    Internet Superhero
    Join Date
    Sep 2006
    Location
    Denmark
    Posts
    964
    Quote Originally Posted by Hi++ View Post
    Correct all i need is in my own reply, (almighty google) i'm going to try it now. I think i wrote very clear what I'm hoping to accomplish, extract all emails from a win32 process with a regex, I kindly ask you to add something useful not just humorous post for the next time, i don't understand why you try to label me as a criminal, is learning and extracting emails from a process malicious or criminal? At least not in my books, sorry my dear friend.
    Yes, Google is quite a powerful tool.

    So let's summarize:

    You are trying to learn C++, you are doing this by using code that you didn't yourself write, and this code is meant to read the memory of a foreign process. To top it off, you are trying to extend this code by making it locate all email addresses in the memory of another program. And this is just a random exercise that you yourself came up with? And the resulting program is not to see any use because this is all for learning purposes?

    How stupid do you really think we are?

    And last thanks for remembering me again that I am a lazy idiot and a noob in C++ and windows programming
    I have no problem with people who are new to/bad at programming. What i do have a problem with is script kiddies trying to disguise their schemes as honest questions because they can't be bothered to do the work themselves. Even when confronted with the fact that your request is highly suspicious you keep claiming innocence and ignorance, instead of actually getting to work.
    With the time you've spent arguing here, you could be done, already cruising the criminal underworld with your newly found internet superpowers, harassing teenagers and old people by sending them shady ads and porn.
    How I need a drink, alcoholic in nature, after the heavy lectures involving quantum mechanics.

  6. #6
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    Quote Originally Posted by Hi++ View Post
    i don't understand why you try to label me as a criminal, is learning and extracting emails from a process malicious or criminal? At least not in my books, sorry my dear friend.
    Sorry, but when it comes to coding of questionable intent, you are guilty until proven innocent, and even then you may well find this being treated as unacceptable use of the forums anyway, because no matter what your intent may be, we cant very well go providing others the same knowledge for their own malicious intent.

    If there is a legitimate reason for this then really you should be stating it up-front, because that's what people who might have a legimate reason do. At the very least you will need to provide your reason in your very next post, but even then, you can probably expect this thread to just be closed shortly anyway.

    Quite frankly I hope that happens sooner rather than later, because I don't care what you say; I do not think that such a program should exist for any reason.
    Last edited by iMalc; 11-24-2012 at 09:24 PM.
    Salem and rags_to_riches like this.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  7. #7
    Registered User
    Join Date
    Nov 2012
    Posts
    6
    You guys can think what you want, my title said clear I'm not disguising anything and never said i wrote that code. I can tell you I'm not using for spam, are my emails and program, and you keep thinking what you want. The rest is bla bla bla... I'm not here siting and waiting for you to come and make it for me.

    iMalc In any case YOU are the one who might have to prove my guilty until then I'm innocent, think what you want.

    Now, let me alone if you are not going to help or to add something positive from where i can learn to reach my goal. //END thx

    I have this problems at compiling. I'm reading more about this but every time new problem. What im doing wrong?

    Code:
    #include <iostream>
    #include <vector>
    #include <string>
    #include <windows.h>
    #include <algorithm>
    #include <iterator>
    #include <regex>
    
    
    typedef match_results<const char*> cmatch; // //////////////////////// ERROR HERE
    //template <class outIter>
    void find_locs(HANDLE process) {
    
        unsigned char *p = NULL;
        MEMORY_BASIC_INFORMATION info;
    
        // VirtualQueryEx does the hard part, telling use about each
        // block in the target process.
    
        for ( p = NULL;
            VirtualQueryEx(process, p, &info, sizeof(info)) == sizeof(info);
            p += info.RegionSize )
        {
            // buffer to hold copies of memory blocks from the target
            std::vector<char> buffer;
            std::vector<char>::iterator pos;
     
            // We only want committed memory that's mapped or private --
            // screens out things like the code in the target process.
            //
            if (info.State == MEM_COMMIT &&
                (info.Type == MEM_MAPPED || info.Type == MEM_PRIVATE))
            {
                DWORD bytes_read;
    
                // copy block from target to our buffer, search for pattern:
                buffer.resize(info.RegionSize);
                ReadProcessMemory(process, p, &buffer[0], info.RegionSize, &bytes_read);
                buffer.resize(bytes_read);
                
                const std::tr1::regex rx("([\\w-+]+(?:\\.[\\w-+]+)*@(?:[\\w-]+\\.)+[a-zA-Z]{2,7})");
                std::tr1::cmatch res; // i tried here with wcmatch wsmatch // don't know
                std::tr1::regex_search(buffer, res, rx); // //////////////////////// ERROR HERE
         
    
               
                for ( int i=0; i<sizeof(res[0]); i++)
                {
                   
                    std::cout << res[i] << "\n" << endl ;
                }
            }
        }
    }
    
    int main(int argc, char **argv) {
        if (argc != 2) {
            fprintf(stderr, "Usage: %s <process ID>", argv[0]);
            return 1;
        }
    
        // Read the target PID and search pattern:
        int pid;
        sscanf_s(argv[1], "%i", &pid);
        //std::string pattern(argv[2]);
    
        // Open the target process with rights to read its information and memory:
        HANDLE process = OpenProcess(
            PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
            false,
            pid);
    
        
        find_locs(process);
    
        return 0;
    }
    Remember i am a noob...

    VC++2010 gives error:

    1> main.cpp
    1>main.cpp(10): error C2143: syntax error : missing ';' before '<'
    1>main.cpp(10): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2597) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2597) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2597) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,std::tr1::match_results<::std::basic_string<_Ele m,_StTraits,_StAlloc>::const_iterator,_Alloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2581) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,std::tr1::match_results<::std::basic_string<_Ele m,_StTraits,_StAlloc>::const_iterator,_Alloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2581) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const std::basic_string<_Elem,_StTraits,_StAlloc> &,std::tr1::match_results<::std::basic_string<_Ele m,_StTraits,_StAlloc>::const_iterator,_Alloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const std::basic_string<_Elem,_StTraits,_StAlloc> &' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2581) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const _Elem *,std::tr1::match_results<const _Elem*,_Alloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const _Elem *' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2566) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2784: 'bool std::tr1::regex_search(const _Elem *,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : could not deduce template argument for 'const _Elem *' from 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2552) : see declaration of 'std::tr1::regex_search'
    1>main.cpp(43): error C2782: 'bool std::tr1::regex_search(_BidIt,_BidIt,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : template parameter '_BidIt' is ambiguous
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2540) : see declaration of 'std::tr1::regex_search'
    1> could be 'std::tr1::cmatch'
    1> or 'std::vector<_Ty>'
    1> with
    1> [
    1> _Ty=char
    1> ]
    1>main.cpp(43): error C2780: 'bool std::tr1::regex_search(_BidIt,_BidIt,std::tr1::mat ch_results<_BidIt,_Alloc> &,const std::tr1::basic_regex<_Elem,_RxTraits> &,std::tr1::regex_constants::match_flag_type)' : expects 5 arguments - 3 provided
    1> C:\Program Files\Microsoft Visual Studio 10.0\VC\include\regex(2528) : see declaration of 'std::tr1::regex_search'
    1>
    1>Build FAILED.
    I search and search but nothing, tried many things. One nice guy teach a noob plz
    Last edited by Hi++; 11-24-2012 at 10:36 PM. Reason: add comments

  8. #8
    Registered User
    Join Date
    Jun 2005
    Posts
    6,245
    Quote Originally Posted by Hi++ View Post
    iMalc In any case YOU are the one who might have to prove my guilty until then I'm innocent, think what you want.
    That sort of logic might work in a court of law, if we were trying to imprison you for a crime. Then the onus of proof is (usually - there are exceptions in laws of most countries) on the prosecution, not the defendant.

    However, the circumstance here is that part of what you're doing is trying to extract data from the address space of another running process. That is, more often than not, done with malicious intent, and you are asking for help in a forum that has a stated policy of not helping or facilitating hacking, cracking, and other illegal or dubious practices. The onus is therefore on you to provide proof of your innocence.
    iMalc and Salem like this.
    Right 98% of the time, and don't care about the other 3%.

  9. #9
    Registered User
    Join Date
    Nov 2012
    Posts
    6
    grumpy, please why to continue? Proof are my words, i never sent unauthorized emails nor i will do, NOW think what you want but please dont continue, report my thread to the proper mod and they will see if break any rule, as long as i read, no rules broken. If they close then i go other forum more friendly and open minded.

    What template<class > should i use? Some body know?

    PD: Sorry for my english, not native.

  10. #10
    Algorithm Dissector iMalc's Avatar
    Join Date
    Dec 2005
    Location
    New Zealand
    Posts
    6,299
    I should probably clarify, when I said "you are guilty until proven innocent", I simply meant, in the eyes of those on this forum, and of doing something that most people are opposed to, that is all.

    Your last post was your one chance to make an attempt to show that this had a legimate reason. You have not done so. The fact that you claim that you did not try and hide anything, does not actually change anything either.

    We are all very aware that you did not write this code (not that you attempted to hide this fact), and we are all very aware that your primary focus here is on getting this code to do whatever unscropulous task it is that you want it to do. We can see that your primary focus is definitely not learning to program.
    I think you can pretty much give up now. Those that know enough to help you, generally are not stupid.
    Salem likes this.
    My homepage
    Advice: Take only as directed - If symptoms persist, please see your debugger

    Linus Torvalds: "But it clearly is the only right way. The fact that everybody else does it some other way only means that they are wrong"

  11. #11
    Registered User
    Join Date
    Nov 2012
    Posts
    6
    OMG! Stop if not going to help! In my first post i said: "I need to modify this code I've found that works similar to what i need." I've found!!! Maybe now i'm speaking chinese ? haha Never ..........ing said i wrote that code.
    I wont spend my time talking off topic anymore, will ignore. // haters gonna hate

    What is wrong in last modified code?

  12. #12
    Registered User
    Join Date
    Dec 2006
    Location
    Canada
    Posts
    3,170
    Haters also think there are enough spam in the world already and we don't need another 1239851925th spammer.

  13. #13
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    21,588
    Quote Originally Posted by Hi++
    Maybe now i'm speaking chinese ?
    If you did I might understand you.

    Quote Originally Posted by Hi++
    Stop if not going to help!
    Okay, thread stopped.
    Salem and nvoigt like this.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. LAN emails
    By lollobrigido in forum Linux Programming
    Replies: 0
    Last Post: 05-14-2008, 06:22 AM
  2. Help with Sending Emails
    By StrikerX in forum C# Programming
    Replies: 3
    Last Post: 04-25-2007, 10:43 AM
  3. Free emails
    By Victor in forum A Brief History of Cprogramming.com
    Replies: 12
    Last Post: 05-24-2004, 02:40 PM
  4. regular and non regular languages
    By metsman20 in forum Tech Board
    Replies: 1
    Last Post: 10-19-2003, 10:00 PM
  5. Child Process & Parent Process Data :: Win32
    By kuphryn in forum Windows Programming
    Replies: 5
    Last Post: 09-11-2002, 12:19 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21