Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


GetCompuerName error
Goto page 1, 2  Next
 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 22, 2008 10:20 am    Post subject: GetCompuerName error Reply with quote

Solved...new problem time =)

oib111 wrote:
Got it working, just had to change the structure, guess MSDN was wrong. Anyway, I have a different problem, I cant get my computer name. It says:

VC++ wrote:

lpBuffer is being used without being initialized.


Then when I initialize it(=NULL or ="") I get this error:

VC++ wrote:

First-chance exception at 0x7c8216b7 in COMPINFO.exe: 0xC0000005: Access violation reading location 0x00000013.
Unhandled exception at 0x7c8216b7 in COMPINFO.exe: 0xC0000005: Access violation reading location 0x00000013.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing


Last edited by oib111 on Sun Jun 22, 2008 10:47 am; edited 1 time in total
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun Jun 22, 2008 10:37 am    Post subject: Reply with quote

Try
Code:
GetVersionEx(&osverinfo);

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 22, 2008 10:40 am    Post subject: Reply with quote

Got it working, just had to change the structure, guess MSDN was wrong. Anyway, I have a different problem, I cant get my computer name. It says:

VC++ wrote:

lpBuffer is being used without being initialized.


Then when I initialize it(=NULL or ="") I get this error:

VC++ wrote:

First-chance exception at 0x7c8216b7 in COMPINFO.exe: 0xC0000005: Access violation reading location 0x00000013.
Unhandled exception at 0x7c8216b7 in COMPINFO.exe: 0xC0000005: Access violation reading location 0x00000013.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun Jun 22, 2008 10:55 am    Post subject: Reply with quote

is buffer big enough and is size the size of the buffer?
It should be something like
Code:
TCHAR buffer[64];
GetComputerName(buffer, 64/sizeof(TCHAR));

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 22, 2008 11:04 am    Post subject: Reply with quote

I did this:

Code:

LPSTR lpBuffer = NULL;
GetComputerName(lpBuffer, (PDWORD)MAX_COMPUTERNAME_LENGTH+1);
cout<<"Computer Name: "<<lpBuffer<<"\n\n";


What if I did this:

Code:

char lpBuffer[MAX_COMPUTERNAME_LENGTH];
GetComputerName(lpBuffer, MAX_COMPUTERNAME_LENGTH/sizeof(char));
cout<<"Computer Name: "<<lpBuffer<<"\n\n";


EDIT:

The second code doesn't work Razz Btw, isn't TCHARs for Unicode (I do everything MBCS)

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun Jun 22, 2008 11:10 am    Post subject: Reply with quote

http://msdn.microsoft.com/en-us/library/ms724426(VS.85).aspx
Might help lol

_________________
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 22, 2008 11:27 am    Post subject: Reply with quote

MSDN does everything in Unicode while I do everything in MBCS, and I don't know the equivalent to INFO_BUFFER_SIZE.
_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Jun 22, 2008 11:27 am    Post subject: Reply with quote

Talking about GetComputerName, i need help with GetUserName API, any ideas ? -.-" (C)
Back to top
View user's profile Send private message
HalfPrime
Grandmaster Cheater
Reputation: 0

Joined: 12 Mar 2008
Posts: 532
Location: Right there...On your monitor

PostPosted: Sun Jun 22, 2008 12:03 pm    Post subject: Reply with quote

If the API uses unicode, you're forced to use unicode, too. If you really don't want to do that, you can try grabbing the name from the registry yourself.
Or try GetComputerNameA(). It takes the sameparameters as GetComputerName().

_________________
Back to top
View user's profile Send private message
Noz3001
I'm a spammer
Reputation: 26

Joined: 29 May 2006
Posts: 6220
Location: /dev/null

PostPosted: Sun Jun 22, 2008 12:24 pm    Post subject: Reply with quote

Rot1 wrote:
Talking about GetComputerName, i need help with GetUserName API, any ideas ? -.-" (C)


I already told you.
Back to top
View user's profile Send private message MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Jun 22, 2008 12:43 pm    Post subject: Reply with quote

oib111 wrote:
The second code doesn't work Razz Btw, isn't TCHARs for Unicode (I do everything MBCS)


No, TCHAR is a macro that works for both unicode and MB depending on the compiler setting for which character set to use.

If the compiler is told to compile in Unicode, TCHAR will be the same as using wchar_t, if the compiler is told to compile in multibyte, TCHAR will be the same as char.

Using TCHAR you can do:

Code:
   TCHAR tszComputerName[ MAX_COMPUTERNAME_LENGTH ];
   DWORD dwSize = MAX_COMPUTERNAME_LENGTH+1;
   GetComputerName( tszComputerName, &dwSize );

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
DeletedUser14087
I post too much
Reputation: 2

Joined: 21 Jun 2006
Posts: 3069

PostPosted: Sun Jun 22, 2008 12:46 pm    Post subject: Reply with quote

noz3001 wrote:
Rot1 wrote:
Talking about GetComputerName, i need help with GetUserName API, any ideas ? -.-" (C)


I already told you.


Didn't compile well, any ideas lol ?
Back to top
View user's profile Send private message
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 22, 2008 12:50 pm    Post subject: Reply with quote

Hehe. I got it working. Here's a snipped Rot:

Code:

LPSTR *lpBuffer = new LPSTR;
DWORD size = 32767;
GetWindowsDirectory((LPSTR)lpBuffer, MAX_PATH);
cout<<"Windows Directory: "<<lpBuffer<<"\n";
*lpBuffer = NULL;
GetSystemDirectory((LPSTR)lpBuffer, MAX_PATH);
cout<<"System Directory: "<<lpBuffer<<"\n";
*lpBuffer = NULL;
GetUserName((LPSTR)lpBuffer, &size);
cout<<"User Currently Logged In: "<<lpBuffer<<"\n\n";
lpBuffer = NULL;
delete lpBuffer;


Reason I'm using dynamic memory is because this is in a switch case statement and I didn't want it to declare a new variable in memory each time someone chose this option.

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 205

Joined: 25 Jan 2006
Posts: 8587
Location: 127.0.0.1

PostPosted: Sun Jun 22, 2008 1:03 pm    Post subject: Reply with quote

GetUserName:
http://msdn.microsoft.com/en-us/library/ms724432(VS.85).aspx

Using TCHAR:
Code:
#include <windows.h>
#include <lmcons.h> // For UNLEN (As described on MSDN.)
#include <tchar.h>
#include <stdio.h>

int main( int argc, TCHAR* argcv[] )
{
   TCHAR tszUser[ UNLEN+1 ];
   DWORD dwSize = UNLEN+1;
   GetUserName( tszUser, &dwSize );
   _tprintf( tszUser );
   return 0;
}


Edit: Oib your code wont work as you are trying to output to the pointer not the actual contents. All yours will do is output the pointer to the string.

_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
oib111
I post too much
Reputation: 0

Joined: 02 Apr 2007
Posts: 2947
Location: you wanna know why?

PostPosted: Sun Jun 22, 2008 1:45 pm    Post subject: Reply with quote

When I try outputting the value I get an error. Here's my code:

Code:

cout<<"User Currently Logged In: "<<*lpBuffer<<"\n\n";

_________________


8D wrote:

cigs dont make people high, which weed does, which causes them to do bad stuff. like killing
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming All times are GMT - 6 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites