News:

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

Problems with creating a Struct in MASM32.

Started by Shooter, February 15, 2011, 09:08:59 PM

Previous topic - Next topic

Shooter

Quote from: dedndave on February 21, 2011, 04:41:07 PM
well - that's not a very good fix - lol
you might try assembling with the /X switch (ML)

(after restoring the paths in masm32rt.inc)

I'm not all that up to speed on that... what does the /X switch do?
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

well - i am thinking you have INCLUDE and LIB environment variables set up for some compiler
the /X switch forces MASM to ignore the environment variable for includes

the problem with modifying the masm32rt.inc file is that it makes your installation different from everyone elses

Shooter

Quote from: dedndave on February 21, 2011, 05:00:23 PM
the problem with modifying the masm32rt.inc file is that it makes your installation different from everyone elses

This is true, but I'm not the one that designed the environmental features of RadASM. This goes back to what I was trying to ask about in the RadASM bug find posts... are they relative to the root, or are they relative to the project file? (On that particular case I had an .RC file with a relative path set, but I never got the real answer if it was in relation to the root folder or to the .RC folder.)

By the way, has anyone ever messed around with the DNS API set of functions? I was debugging ipconfig.exe and saw it used several times. So far, however, I'm only finding it as part of the MS Visual Studio set of SDKs, which I don't have with me on the road.

-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

well - another way to go....

in the assembly batch file, SET LIB= and SET INCLUDE=
these are applied on a per-session basis, so do not permanently modify the variables
maybe use the SETLOCAL batch command - i.e., they are only applied during the batch run

Shooter

OK, I 'm confused on what this is for:
        push [edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwAddr
        pop  IPAddr.S_un.S_addr
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

it's a memory to memory move
they are taking the IP address from one structure and placing it into another

might be an unnecessary step, too - lol
they could probably convert it where is sits

Shooter

Quote from: dedndave on February 21, 2011, 07:43:49 PM
it's a memory to memory move
they are taking the IP address from one structure and placing it into another

might be an unnecessary step, too - lol
they could probably convert it where is sits

That's what I was wondering. Is it not possible to do this:
        invoke inet_ntoa,[edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwMask
(I haven't tried it yet... just wondering though.)
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.

MichaelW

Quote from: Shooter on February 21, 2011, 06:53:06 PM
OK, I 'm confused on what this is for:
        push [edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwAddr
        pop  IPAddr.S_un.S_addr


The push instruction effectively uses the structures as a template, with the:

.MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwAddr

Resolved to the value 4 at assembly time, so the source operand is effectively [edi+4].

Quote
Is it not possible to do this:
Code:
invoke inet_ntoa,[edi].MIB_IPADDRTABLE.table.MIB_IPADDRROW.dwMask

That will work, without any need for the DWORD PTR, but I was translating a C source, where to do it that way you would probably have to resort to some messy code to satisfy the compiler.
eschew obfuscation

Shooter

Michael,
That makes sense now.

I'm still trying to find a means of extracting the Default Gateway. I've read through some of the stuff on MSDN about GetHostByName and GetIpAddrTable, but no joy so far, unless like their tables it's buried somewhere.

-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

there are a few functions...
GetNetworkParams
GetAdaptersAddresses
GetAdaptersInfo
GetPerAdapterInfo

searching around a bit, i have found a number of solutions that involve shelling an "ipconfig /all>temp.txt" command and parsing the output text

after looking at the functions, that sounds a lot easier   :P

dedndave


Shooter

Quote from: dedndave on February 21, 2011, 09:19:44 PM
searching around a bit, i have found a number of solutions that involve shelling an "ipconfig /all>temp.txt" command and parsing the output text

after looking at the functions, that sounds a lot easier   :P

I think I'm in agreement with you on that. Shoot, looking at the registry shows just how messed up the network stuff is.
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 February 21, 2011, 09:53:15 PM
i found this code that may be of interest...

http://www.koders.com/c/fidE8769D7EC08E6C2F7D9D0A2E16E43E8F5A199529.aspx

I dunno... it's sort of looking like that's how I originally wanted to go, examine the system registry, but in this case it appears as though the coder is looking for one specific type of 'control', or NIC... I'm dealing with a variety of them.
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.

MichaelW

The attachment contains the Microsoft example from here, in C and in assembly. The example source contains some components that Visual C++ Toolkit 2003 could not handle (mostly the LeaseObtained and LeaseExpired code with the _s ("secure") functions), so I took the lazy route and simply removed these components.

The GetAdaptersAddresses function for XP and later returns more information, but since I can't test it I didn't try to translate the example.
eschew obfuscation

Shooter

Quote from: MichaelW on February 22, 2011, 07:50:58 AM
The attachment contains the Microsoft example from here, in C and in assembly. The example source contains some components that Visual C++ Toolkit 2003 could not handle (mostly the LeaseObtained and LeaseExpired code with the _s ("secure") functions), so I took the lazy route and simply removed these components.

Michael,
That's exactly what I'm looking for! Thank you so very much. I'll have to delve into the code later on and see how you did it, but you nailed it on this one (test.exe). Thank you so very much!

-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.