Page 1 of 2 12 LastLast
Results 1 to 15 of 17

Thread: My program

  1. #1
    Registered User
    Join Date
    Apr 2002
    Posts
    151

    My program

    Here's what I came up with, heavily based on the previous post about writing a sniffer for the key.

    Basically, it scans for eqgame in a loop.

    Once it finds the pid, it goes to a loop that checks the key area of memory.

    Once the key is != 0, it beeps and fires off "keymove.bat" (in hidden mode), which is a script I wrote that uses scp to copy the dat file over to my linux box. You can write one that uses tftp or ftp or whatever you want. Or, you can just make an empty batch file if you're keeping an active share between your machines.

    After that, it keeps looping until the key changes, then fires the script off again (and beeps).

    This should work without EQW.

    Note: this compiles and works on XP using vc6.

    Code:
    #include <stdio.h>
    #include <string.h>
    #include <windows.h>
    #include <tlhelp32.h>
    #include <fstream.h>
    
    char argkey[256]="773b90";
    ULONGLONG oldkey=0;
    
    void readkey (HANDLE hProcess)
    {
    FILE *fp;
    
    
    	while (1)
    	{
    		unsigned long addr;
    		ULONGLONG key;
    
    		Sleep(1000);
    
    		if (sscanf (argkey, "%08x", &addr) == 1)
    		{
    			if (ReadProcessMemory (hProcess, (void *)addr, &key, 8, NULL) == 0)
    			{
    				printf ("ReadProcessMemory on 8 bytes at 0x%08x failed: %u\n", addr, GetLastError());
    			} else {
    
    				if (oldkey == key)
    				{
    					// key hasn't changed
    				}
    				else
    				{
    					printf ("New key found: 0x%016I64x\n", key);
    					Beep(500,500);
    					oldkey = key;
    
    					fp = fopen("\\mydirectory\\keyfile.dat", "wb");
    					fwrite(&key, sizeof(key), 1, fp);
    					fclose(fp);
    
    					WinExec("C:\\mydirectory\\keymove.bat", SW_HIDE);
    				}
    			}
    		}
    		fflush (stdin);
    	}
    }
    
    
    void scanproclist () 
    { 
        HANDLE         hProcessSnap = NULL; 
        PROCESSENTRY32 pe32      = {0}; 
     
        //  Take a snapshot of all processes in the system. 
        hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); 
    
        if (hProcessSnap == INVALID_HANDLE_VALUE) 
            return; 
     
        //  Fill in the size of the structure before using it. 
        pe32.dwSize = sizeof(PROCESSENTRY32); 
    
        if (Process32First(hProcessSnap, &pe32))
        { 
    		HANDLE hProcess;
    
            do 
            { 
                LPSTR pCurChar;
    			char pName[512];
    
                // strip path and leave exe filename 
                for (pCurChar = (pe32.szExeFile + strlen (pe32.szExeFile)); 
                     *pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;  
                     --pCurChar) 
    
                strcpy(pName, pCurChar); 
    			strlwr(pName);
    
    			if ( (strncmp (pName, "testeqgame", 10) == 0) || (strncmp (pName, "eqgame", 6) == 0) )
    			{
    				printf ("found eqgame - pid = %u\n\n", pe32.th32ProcessID);
    				// hProcess = OpenProcess (PROCESS_ALL_ACCESS, FALSE, pe32.th32ProcessID);
    				hProcess = OpenProcess (PROCESS_VM_READ, FALSE, pe32.th32ProcessID);
    				if (hProcess == NULL)
    				{
    					DWORD dw;
    					dw = GetLastError();
    					printf ("OpenProcess failed, error: %u\n", dw);
    					return;
    				}
    				readkey (hProcess);
    			}
    	  } 
            while (Process32Next(hProcessSnap, &pe32)); 
        } 
    
        CloseHandle (hProcessSnap);
        return; 
    }
    
    
    
    void main(int argc, char **argv)
    {
    	while (1) {
    		Sleep(10000); // Scan for EQGame only every 10 seconds, since it slows the system down.  Makes loading slow.
    		scanproclist();
    	}
    }

  2. #2
    Registered User
    Join Date
    Nov 2002
    Posts
    13
    Could you make the Linux box look for this file in a shared directory on your EQ machine? IE..sniffer Updates file on EQ machine, and Showeq opens that file over the network?

  3. #3
    Registered User
    Join Date
    Dec 2001
    Posts
    246
    ShowEQ is open source so you can do ANYTHING you want.

    the best way to do it like this is have a mounted drive on your Windows box(easy but I never tried) and have ShowEQ look at a TXT file on that share every X-Secs and when updated add new key.

    What I would do if I could code is, have ShowEQ kick off on or a few secs after the opcode for Zoning is detected, or even a trigger added to the KeyGen when new key is found(Instead of the Beep) to trigger ShowEQ to load a new key.

    Just a few Ideas, for anyone to try if they can code in C

  4. #4
    Registered User
    Join Date
    Sep 2002
    Posts
    231
    Code:
    WinExec("C:\\mydirectory\\keymove.bat", SW_HIDE);
    That little line is a gem I always forget how to run things hidden like that ... too much usage of System() in my life /sigh

  5. #5
    Registered User
    Join Date
    Mar 2002
    Posts
    42
    I'm getting this when i try to compile any suggestions

    C:\cygwin\bin>gcc -c key.c
    key.c:5:21: fstream.h: No such file or directory
    key.c: In function `main':
    key.c:108: warning: return type of `main' is not `int'

  6. #6
    Registered User Mr. Suspicious's Avatar
    Join Date
    May 2002
    Posts
    667
    I'm getting this when i try to compile any suggestions

    C:\cygwin\bin>gcc -c key.c
    key.c:5:21: fstream.h: No such file or directory
    key.c: In function `main':
    key.c:108: warning: return type of `main' is not `int'
    This isn't a "Cygwin" related messageboard (realy, you will be helped much better if you actually ask questions about an app at a relevant messageboard, asking questions about your faulty kitchensink won't result you a lot of helpfull posts at this board either).

    Altho this isn't the "Cygwin" help board, you will still find the answer to your question if you use the searchfeature of this board.

    from: http://seq.sourceforge.net/showthrea...5&pagenumber=5

    5) Compile the code with "gcc -c keyscan.c"

    C:\Program Files\MinGW\bin>gcc -c keyscan.c
    keyscan.c: In function `main':
    keyscan.c:89: warning: return type of `main' is not `int'

    Ignore these errors.
    Last edited by Mr. Suspicious; 11-02-2002 at 07:58 PM.
    Before asking anything read the pre-face section of http://www.smoothwall.org/download/p....9/doc.faq.pdf

    after you've read it, you know what to do next...




    "Stay alert! Trust noone! Keep your Lazers Handy! Have a nice day." -- Provided courtesy of the Computer. The Computer never lies.

  7. #7
    Registered User
    Join Date
    Dec 2001
    Posts
    160
    Mister S.

    the problem he is having is that fstream.h is not an include file that comes with Cygwin or MinGW. I am running into the same error and trying to track down an alternate include to fstreams but not having much luck.

    Monster

  8. #8
    Registered User
    Join Date
    Mar 2002
    Posts
    42
    Thank you Mr. suspicious not sure how your link helped. The fstream.h error and I knew to ignore the other readout.
    If you you have any other helpful information please do not be shy.

    monster let me know if you find out how to resovle the Fstream error. I will do the same so far i have a somewhat working version, just by removing that part of the codethe #include<fstream.h> another words i just deleted line 5 but not sure how that will effect the overall proggie.

  9. #9
    Registered User
    Join Date
    Dec 2001
    Posts
    160
    Okay nursling, heres how I fixed it.

    Goto the keycode example thread and get wxyz's code and use it instead. :P

    Monster

  10. #10
    Registered User
    Join Date
    Nov 2002
    Posts
    1
    Originally posted by Nurseling

    C:\cygwin\bin>gcc -c key.c
    key.c:5:21: fstream.h: No such file or directory
    key.c: In function `main':
    key.c:108: warning: return type of `main' is not `int'
    I'm not sure about cygwin, but fstream.h is included in MinGw, it is a c++ header, so you need to compile using g++ not gcc. then you also need to change the line:
    *pCurChar != '\' && pCurChar != pe32.szExeFile - 1;
    to
    *pCurChar != '\\' && pCurChar != pe32.szExeFile - 1;

    and change:
    void main(int argc, char **argv)
    to
    int main(int argc, char **argv)

    it should then compile for you with no errors in MinGw

  11. #11
    Registered User
    Join Date
    Dec 2001
    Posts
    10

    Not quite sure whats wrong

    I get your code compiled when i input a numerical value 2.. where it errors..
    I get code when i start EQ.. and everytime I zone.. I put the code. on SEQ where the Decoder drop down is.. Is this correct.. Cuz when I do . only 1 mob <dread collective> decodes.. rest stay unknown.?
    Also. Do I need to input new codes.. every time I zone..

    Don't mean to be stupid.. But trying to figure this all out..

    I updated CVS as of 11/1/02 and Have the libEQ.a as of 11/1/02

    Any help would be greatly appreciated..
    Thanks

    P.S. EDIT..
    As of 1am 11/3/02 got new CVS and new libEQ.a and input the key .. everytime I zone.. and it decodes.. YOU ROCK. thanks.. Hope I'm doing it right
    Last edited by Cali; 11-03-2002 at 02:48 AM.

  12. #12
    Registered User
    Join Date
    Dec 2001
    Posts
    144
    Ah, too sweet. SAMBA mounted my box onto my main system. Did a set copy over and it works like a champ.

    Only two things:

    One: Maps aren't centered. My guess is there might be something missing?

    Two: Now, only if SEQ can load the keydat file when ever it changes automatically!
    (or does it and I've just been to impatient)

  13. #13
    Registered User
    Join Date
    Oct 2002
    Posts
    32
    While compiling the above I get an error Running Win XP - VC++6

    Compiling...
    getkey.cpp
    c:\program files\microsoft visual studio\myprojects\getkey\getkey.cpp(109) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    getkey.exe - 1 error(s), 0 warning(s)


    I tested the "hello world" application and it compiled ok

    Yes I used the search feature - I came up with one other person getting the cl.exe error - but it doesnt seem to be the same error

    Thanks for any ideas/suggestions

  14. #14
    Registered User
    Join Date
    Oct 2002
    Posts
    32

    error with c++

    Havent been able to find a fix for this - have found many posts on other forums about the error - and tried everything suggested - still no worky

    This is VC++6 Ent.

    Compiling...
    getkey.cpp
    c:\program files\microsoft visual studio\myprojects\getkey\getkey.cpp(109) : fatal error C1010: unexpected end of file while looking for precompiled header directive
    Error executing cl.exe.

    getkey.exe - 1 error(s), 0 warning(s)


    I tested the "hello world" application and it compiled ok and worked. It seems w hen I compile anything else - its broke.

    Any suggestions?

    I posted this here so that others might benefit from it with their future searches.... since there is only one other with the problem on the board at this time - and it is unrelated.

    Thanks!

  15. #15
    Registered User
    Join Date
    Apr 2002
    Posts
    151
    /shrug, try one of the other examples.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

You may post new threads
You may post replies
You may post attachments
You may edit your posts
HTML code is Off
vB code is On
Smilies are On
[IMG] code is Off