Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Trying to use OpenThread [modified]

Trying to use OpenThread [modified]

Scheduled Pinned Locked Moved C / C++ / MFC
announcementc++question
6 Posts 3 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    capricious_001
    wrote on last edited by
    #1

    Hey guys, I'm trying to use OpenThread however I get errors that its an undeclared identifier. I have included windows.h. I know OpenThread is defined in winbase.h however when looking within the header file I can see that the only close resembelence to this is OpenThreadToken which is not what I need. I am also using VC++ 6.0 btw. Does that mean I would have to update my header files? If thats the case would anyone know where the most recent version If I dont have to update my files, would anyone know a way to implement a function similar to OpenThread? Thanks, Robbie -- modified at 0:50 Monday 3rd July, 2006

    H M 2 Replies Last reply
    0
    • C capricious_001

      Hey guys, I'm trying to use OpenThread however I get errors that its an undeclared identifier. I have included windows.h. I know OpenThread is defined in winbase.h however when looking within the header file I can see that the only close resembelence to this is OpenThreadToken which is not what I need. I am also using VC++ 6.0 btw. Does that mean I would have to update my header files? If thats the case would anyone know where the most recent version If I dont have to update my files, would anyone know a way to implement a function similar to OpenThread? Thanks, Robbie -- modified at 0:50 Monday 3rd July, 2006

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Whats application type?_**


      **_

      whitesky


      C 1 Reply Last reply
      0
      • H Hamid Taebi

        Whats application type?_**


        **_

        whitesky


        C Offline
        C Offline
        capricious_001
        wrote on last edited by
        #3

        Oh its a DLL Injector. It injects a DLL into an Open process. Here is a piece of the code for the DLL Injector. If there are some functions that appear unfamiliar like GetProcessThreads its because they are ones that creator defined.

        bool DLLInject(DWORD pid, const char *path)
        {
        	//this will go through all TIDs of a process
        	//and get one we can use
            DWORD tid[20];
        	int inbytes = 20;
        	GetProcessThreads(pid, &tid[0], &inbytes);
        
        	if(pid == GetCurrentProcessId())
        	{
                NumOut("Process will suspend itself and lock");
        		return 0;
        	}
        
        	DWORD tiduse=0;
        	for(int i=0; i 0x400000)
        			{
        				tiduse = tid[i];
        				break; //one thread is good, break the loop
        			}
        			//NumOut("%d %X", tid[i], ctx.Eip);
        		}
        	}
        
        	//do we have a good tid?
        	if(!tiduse)
        	{
        		NumOut("No usable tid found");
        		return 0;
        	}
        
        	//found a good tid already, now patch
        	//excelent patching method
        
        	HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
        	if(!proc)
        		proc = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, pid);
        
        	HANDLE thread = OpenThread(THREAD_ALL_ACCESS, FALSE, tiduse);
        
        	bool ret = WriteMemPatch(proc, thread, path);
        	CloseHandle(proc);
        	CloseHandle(thread);
        	return ret;
        }
        
        H 1 Reply Last reply
        0
        • C capricious_001

          Oh its a DLL Injector. It injects a DLL into an Open process. Here is a piece of the code for the DLL Injector. If there are some functions that appear unfamiliar like GetProcessThreads its because they are ones that creator defined.

          bool DLLInject(DWORD pid, const char *path)
          {
          	//this will go through all TIDs of a process
          	//and get one we can use
              DWORD tid[20];
          	int inbytes = 20;
          	GetProcessThreads(pid, &tid[0], &inbytes);
          
          	if(pid == GetCurrentProcessId())
          	{
                  NumOut("Process will suspend itself and lock");
          		return 0;
          	}
          
          	DWORD tiduse=0;
          	for(int i=0; i 0x400000)
          			{
          				tiduse = tid[i];
          				break; //one thread is good, break the loop
          			}
          			//NumOut("%d %X", tid[i], ctx.Eip);
          		}
          	}
          
          	//do we have a good tid?
          	if(!tiduse)
          	{
          		NumOut("No usable tid found");
          		return 0;
          	}
          
          	//found a good tid already, now patch
          	//excelent patching method
          
          	HANDLE proc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
          	if(!proc)
          		proc = OpenProcess(PROCESS_VM_READ | PROCESS_VM_WRITE, FALSE, pid);
          
          	HANDLE thread = OpenThread(THREAD_ALL_ACCESS, FALSE, tiduse);
          
          	bool ret = WriteMemPatch(proc, thread, path);
          	CloseHandle(proc);
          	CloseHandle(thread);
          	return ret;
          }
          
          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Im not sure its good for you but maybe it is some helpful to you i dont have vc6 ////header file typedef HANDLE (WINAPI *OPENTHREAD)(DWORD ,BOOL,DWORD); OPENTHREAD m_OpenThread ; HMODULE kernel32; kernel32=LoadLibrary(_T("kernel32.dll")); m_OpenThread =(OPENTHREAD)GetProcAddress(kernel32, "OpenThread"); HANDLE h=m_OpenThread(THREAD_ALL_ACCESS,false,GetCurrentThreadId());_**


          **_

          whitesky


          1 Reply Last reply
          0
          • C capricious_001

            Hey guys, I'm trying to use OpenThread however I get errors that its an undeclared identifier. I have included windows.h. I know OpenThread is defined in winbase.h however when looking within the header file I can see that the only close resembelence to this is OpenThreadToken which is not what I need. I am also using VC++ 6.0 btw. Does that mean I would have to update my header files? If thats the case would anyone know where the most recent version If I dont have to update my files, would anyone know a way to implement a function similar to OpenThread? Thanks, Robbie -- modified at 0:50 Monday 3rd July, 2006

            M Offline
            M Offline
            Michael Dunn
            wrote on last edited by
            #5

            2.2 I'm trying to call a Windows API, but the compiler gives an undeclared identifier error (C2065). Why?[^]

            --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer

            C 1 Reply Last reply
            0
            • M Michael Dunn

              2.2 I'm trying to call a Windows API, but the compiler gives an undeclared identifier error (C2065). Why?[^]

              --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ VB > soccer

              C Offline
              C Offline
              capricious_001
              wrote on last edited by
              #6

              Nice, that fixed it. Thanks for input guys!

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups