Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    help with using something in file

    what i want to do is in a file called settings.ini there 3 lines of things
    a dll
    a process
    and a delay

    well what i want it to do is use the name of the dll in a sentance so i can say something like
    the thing you are injecting is (the name of dll in the settings.ini file) i hope you have fun
    but what i want it to do is when someone puts another dll into there it will say that name instead but i dont know how
    well here's the code so far

    Code:
    #include <windows.h>
    #include <iostream>
    #include <string>
    #include <fstream>
    using namespace std;
    
    #include "Injector.h"
    
    string process, dll, delay;
    int rsult = -1;
    
    int main() {
    	ifstream file ("Settings.ini");
    	getline (file,dll);
    	getline (file,process);
    	getline (file,delay);
    	file.close();
        dll = file
    
    
    	cout << "----------------loopy Injector---------------"
    	     << endl
    	     << "----------------Made By loopylukas----------------"
    	     << endl
    	     << endl
    	     << "Waiting for " << process << "...";
    
    	for (;;) {
    		if (IsRunning(process.c_str())) {
    			cout << endl << "Waiting " << delay << " ms" << endl;
    			Sleep (atoi(delay.c_str()));
    			rsult = InjectDll(GetPid(process.c_str()), dll.c_str());
    			break;
    		}
    		cout << ".";
    		Sleep (50);
    	}
    
    	if (rsult == 0) 
    		cout << endl << "Injection Sucess!" << endl;
    	else
    		cout << endl << "Injection Failed!" << endl;
    
    	Sleep (1000);
    	return 0;
    }
    if anyone could help that would be nice
    Last edited by loopylukas; 04-06-2009 at 01:35 AM.

  • #2
    Regular Coder
    Join Date
    May 2004
    Location
    New Hampshire, America
    Posts
    246
    Thanks
    0
    Thanked 2 Times in 2 Posts
    If you mean you just want to take that line from the string and put it into a sentence it's easy with sprintf_s().

    An example would be:
    Code:
    char someMsg[255] = "";
    char theDLLName[255] = "SomeDLL.dll";
    
    sprintf_s(someMsg, 255, "You have injected %s into the process!", theDLLName);
    Now of course you would have to adjust for your use with the string class, and replace theDLLName with the string you read from the file. Not sure if that's what you meant or not.

  • #3
    New to the CF scene
    Join Date
    Apr 2009
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts
    hey could you help me place it into my code please?

  • #4
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    Quote Originally Posted by Dunna View Post
    If you mean you just want to take that line from the string and put it into a sentence it's easy with sprintf_s().

    An example would be:
    Code:
    char someMsg[255] = "";
    char theDLLName[255] = "SomeDLL.dll";
    
    sprintf_s(someMsg, 255, "You have injected %s into the process!", theDLLName);
    Now of course you would have to adjust for your use with the string class, and replace theDLLName with the string you read from the file. Not sure if that's what you meant or not.
    I believe the string class has an overload for the insertion operator so you could use that to build the string.
    OracleGuy


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •