News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

General question about accessing the system registry

Started by Shooter, December 19, 2010, 10:44:34 PM

Previous topic - Next topic

Shooter

Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

Shooter

Quote from: dedndave on December 23, 2010, 10:44:28 AM
for MASM...
        INCLUDE    \masm32\include\ws2_32.inc
        INCLUDELIB \masm32\lib\ws2_32.lib


Dave,
Since I'm using MASM this time, what's the difference between those and wsock32?

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

dedndave

if i am not mistaken, ws2_32 is an updated version of winsock32

dedndave


Shooter

Quote from: dedndave on December 26, 2010, 01:03:47 AM
i ran across this page and thought you may find it helpful...

Iczelion's Guide to Winsock Programming

Wow, that seems a little overwhelming for what I want to do, which is just to return my current LAN IP address and domain names.

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

dedndave

lol
it's only one page !!!   :P
at any rate, bookmark it - you may want it later

Shooter

Quote from: dedndave on December 26, 2010, 01:37:07 AM
it's only one page !!!   :P
Now THAT'S Funny! (Only one page. SHEESH!)  :lol It's bookmarked at any rate.

Well, I managed to muddle through it with the help of a few examples on the web and this forum.

One thing that is confusing the heck out of me is this bit of code:
    invoke gethostbyname,addr lpbData
    mov eax, DWORD PTR [eax+12]
    mov eax, DWORD PTR [eax] <------- (Confuses me)    
    mov eax, DWORD PTR [eax] <-------


It just doesn't make sense on the surface (to me) which tells me there's more going on behind the scenes than what was written in the help files. If it weren't for the examples I'd never of known to make that call twice back-to-back.

-Shooter

PS. Merry Christmas!
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.

dedndave

that's because it returns a pointer to a structure that has a pointer to a pointer to a pointer as a member   :lol
the function was OBVIOUSLY written by some C programmer who likes coffee   :bdg

Shooter

Quote from: dedndave on December 26, 2010, 03:03:17 AM
that's because it returns a pointer to a structure that has a pointer to a pointer to a pointer as a member   :lol
the function was OBVIOUSLY written by some C programmer who likes coffee   :bdg

So, um, is there a way of clearing it up some so that I can understand what's going on?
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.


dedndave

QuoteSo, um, is there a way of clearing it up some so that I can understand what's going on?

it is cleared up - lol - your code works   :U

keep in mind - i am not familiar with the function or the structure
but it looks to me as if....

1) gethostbyname returns the address of a structure
2) the 4th member of that structure is a pointer (pointers are addresses)
3) that address points to another pointer
4) that address points to the value you actually want to retrieve

Gunner

as Dave says, they are pointers to pointers. the return of gethostbyname returns a pointer to a hostent structure
hostent

The hostent structure is used by functions to store information about a given host, such as host name, IP address, and so forth. An application should never attempt to modify this structure or to free any of its components. Furthermore, only one copy of the hostent structure is allocated per thread, and an application should therefore copy any information that it needs before issuing any other Windows Sockets API calls.


typedef struct hostent {  char FAR* h_name;  char FAR  FAR** h_aliases;  short h_addrtype;  short h_length;  char FAR  FAR** h_addr_list;
} hostent;
Members
h_name
Official name of the host (PC). If using the DNS or similar resolution system, it is the Fully Qualified Domain Name (FQDN) that caused the server to return a reply. If using a local hosts file, it is the first entry after the IP address.
h_aliases
Null-terminated array of alternate names.
h_addrtype
Type of address being returned.
h_length
Length of each address, in bytes.
h_addr_list
Null-terminated list of addresses for the host. Addresses are returned in network byte order. The macro h_addr is defined to be h_addr_list[0] for compatibility with older software.


MSDN is your best friend!
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com

Shooter

Gunner,
I'll check into that 'hostent' thing and see about cleaning up my code a little more. BTW, good catch on that one. I didn't even realize there was a structure to it.  :clap:

So far I've achieved two of my five+ objectives. I still need to identify and retrieve the LAN domain name, which is going to be difficult to prove as currently my own computer is not a part of any domain (that I'm aware of).

The end result of all of this is to aid in my job replacing old computers on an existing network whereby the user input is via a touchscreen (no keyboard or mouse attached)... the REAL problem is that those computer networks are at very remote locations and I can't exactly drive off to one and check my program at will, and they are NOT available via the internet. This may take some time, like several months.

In the mean time I'll just be going into each computer and writing things down the old fashion way.

I still need to work on automatically turning off the screen saver for the default user, adding an autologin sequence to the registry (should be easy to do now that I know how to access the registry), and of course install drivers and software on the new machines (not sure how to automate that one yet except by batch files).

-Shooter
Never use direct references to anything ever. Bury everything in
macros. Bury the macros in include files. Reference those include
files indirectly from other include files. Use macros to reference
those include files.