can someone show me an example on how to use this? I can't find it anywhere
CreateObject( "HNetCfg.NATUPnP")
want something like to interface it via com, for upnp so i can temporarly open my router up while gaming. Thankyou for your time
heres the masm code I wrote, I don't know com very well nor where to go from herer
.386
.model flat, stdcall
option casemap:none
include \masm32\include\windows.inc
include \masm32\include\user32.inc
include \masm32\include\kernel32.inc
include \masm32\include\ole32.inc
include \masm32\com\include\oaidl.inc
include \masm32\com\include\shlobj.inc
include \masm32\include\uuid.inc
includelib \masm32\lib\user32.lib
includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\ole32.lib
includelib \masm32\lib\uuid.lib
.data
CLSID_UPnPNAT GUID {0AA001EAEH, 0D53FH, 3C40H, \
{8AH, 27H, 2BH, 0BDH, 0C3H, 0CH, 0D0H, 0E1H}}
IID_IUPnPNAT GUID {12C871B1H, 76CCH, 5A48H,\
{94H, 0D8H,0B6H, 0B3H, 0A2H, 79H, 4EH, 99H}}
IID_IStaticPortMappingCollection GUID {773E1FCDH, 0D666H, 6446H, \
{82H, 0C7H, 36H, 0DBH, 0B6H, 41H, 0D0H, 0F1H}}
;c++ def
;const IID CLSID_UPnPNAT = {0xAA001EAE, 0xD53F, 0x3C40, [0x8A, 0x27, 0x2B, 0xBD, 0xC3, 0x0C, 0xD0, 0xE1]};
;const IID IID_IUPnPNAT = {0x12C871B1, 0x76CC, 0x5A48, [0x94, 0xD8, 0xB6, 0xB3, 0xA2, 0x79, 0x4E, 0x99]};
;const IID IID_IStaticPortMappingCollection = {0x773E1FCD, 0xD666, 0x6446, [0x82, 0xC7, 0x36, 0xDB, 0xB6, 0x41, 0xD0, 0xF1]};
.data?
psl dd ?
hResult dd ?
.code
start:
invoke CoInitialize, NULL
invoke CoCreateInstance, ADDR CLSID_UPnPNAT, NULL,CLSCTX_INPROC_SERVER,ADDR IID_IUPnPNAT, ADDR psl
mov hResult, eax
invoke CoUninitialize
invoke ExitProcess,0
end start
also i attached natupnp.h which apparently defines everything, and lastly heres somthing http://msdn2.microsoft.com/en-us/library/aa366182.aspx
if anyone would be so kind to help, i'd really appreciate it
[attachment deleted by admin]
Hello,
First you have to translate your header files
see http://www.masm32.com/board/index.php?topic=5428.msg40500#msg40500
When it is done , all is clear and simple for me.
The more important is to find the documentation on the com function.
First little help , the translate of natupnp.h.Many line can be removed.Just keep the define of the interfaces (a structure and a macro)
ToutEnMasm
Quote
; this ALWAYS GENERATED file contains the definitions for the interfaces
; File created by MIDL compiler version 6.00.0366
; Compiler settings for natupnp.idl:
;Oicf, W1, Zp8, env=Win32 (32b run)
;protocol : dce , ms_ext, c_ext, robust
;error checks: allocation ref bounds_check enum stub_data
;VC __declspec() decoration level:
;__declspec(uuid()), __declspec(selectany), __declspec(novtable)
;DECLSPEC_UUID(), MIDL_INTERFACE()
;*/
;@@MIDL_FILE_HEADING( )
;ECHO warning( disable: 4049 ) ; more than 64k source lines
; verify that the <rpcndr.h> version is high enough to compile this file
IFNDEF __REQUIRED_RPCNDR_H_VERSION__
__REQUIRED_RPCNDR_H_VERSION__ equ <475>
ENDIF
Include \masm32\sdk\rpc.SDK
Include \masm32\sdk\rpcndr.SDK
IFNDEF __RPCNDR_H_VERSION__
.ERR <this stub requires an updated version of <rpcndr.h>>
ENDIF ; __RPCNDR_H_VERSION__
IFNDEF COM_NO_WINDOWS_H
Include \masm32\sdk\windows.SDK
Include \masm32\sdk\ole2.SDK
ENDIF ;COM_NO_WINDOWS_H
IFNDEF __natupnp_h__
IF DEFINED (_MSC_VER) AND (COMPARE (_MSC_VER,GE,1020))
;ECHO once
ENDIF
; Forward Declarations
IFNDEF __IUPnPNAT_FWD_DEFINED__
ENDIF ; __IUPnPNAT_FWD_DEFINED__
IFNDEF __INATEventManager_FWD_DEFINED__
ENDIF ; __INATEventManager_FWD_DEFINED__
IFNDEF __INATExternalIPAddressCallback_FWD_DEFINED__
ENDIF ; __INATExternalIPAddressCallback_FWD_DEFINED__
IFNDEF __INATNumberOfEntriesCallback_FWD_DEFINED__
ENDIF ; __INATNumberOfEntriesCallback_FWD_DEFINED__
IFNDEF __IDynamicPortMappingCollection_FWD_DEFINED__
ENDIF ; __IDynamicPortMappingCollection_FWD_DEFINED__
IFNDEF __IDynamicPortMapping_FWD_DEFINED__
ENDIF ; __IDynamicPortMapping_FWD_DEFINED__
IFNDEF __IStaticPortMappingCollection_FWD_DEFINED__
ENDIF ; __IStaticPortMappingCollection_FWD_DEFINED__
IFNDEF __IStaticPortMapping_FWD_DEFINED__
ENDIF ; __IStaticPortMapping_FWD_DEFINED__
IFNDEF __UPnPNAT_FWD_DEFINED__
IFDEF __cplusplus
ELSE
ENDIF ; __cplusplus
ENDIF ; __UPnPNAT_FWD_DEFINED__
; header files for imported files
Include \masm32\sdk\oaidl.SDK
Include \masm32\sdk\ocidl.SDK
IFDEF __cplusplus
ENDIF
; interface __MIDL_itf_natupnp_0000
; [local]
;+-------------------------------------------------------------------------
;
; Microsoft Windows
; Copyright (C) Microsoft Corporation, 1992-2001.
;
;--------------------------------------------------------------------------
; MODULE: natupnp.h
;
IFNDEF __IUPnPNAT_INTERFACE_DEFINED__
; interface IUPnPNAT
; [unique][helpstring][dual][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STIUPnPNAT STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
GetTypeInfoCount comethod2 ?
GetTypeInfo comethod4 ?
GetIDsOfNames comethod6 ?
Invoke comethod9 ?
get_StaticPortMappingCollection comethod2 ?
get_DynamicPortMappingCollection comethod2 ?
get_NATEventManager comethod2 ?
STIUPnPNAT ENDS
IUPnPNAT MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STIUPnPNAT PTR[edx]).>,<&Function,ppvIUPnPNAT>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvIUPnPNAT
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __IUPnPNAT_INTERFACE_DEFINED__
IFNDEF __INATEventManager_INTERFACE_DEFINED__
; interface INATEventManager
; [unique][helpstring][dual][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STINATEventManager STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
GetTypeInfoCount comethod2 ?
GetTypeInfo comethod4 ?
GetIDsOfNames comethod6 ?
Invoke comethod9 ?
put_ExternalIPAddressCallback comethod2 ?
put_NumberOfEntriesCallback comethod2 ?
STINATEventManager ENDS
INATEventManager MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STINATEventManager PTR[edx]).>,<&Function,ppvINATEventManager>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvINATEventManager
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __INATEventManager_INTERFACE_DEFINED__
IFNDEF __INATExternalIPAddressCallback_INTERFACE_DEFINED__
; interface INATExternalIPAddressCallback
; [unique][helpstring][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STINATExternalIPAddressCallback STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
NewExternalIPAddress comethod2 ?
STINATExternalIPAddressCallback ENDS
INATExternalIPAddressCallback MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STINATExternalIPAddressCallback PTR[edx]).>,<&Function,ppvINATExternalIPAddressCallback>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvINATExternalIPAddressCallback
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __INATExternalIPAddressCallback_INTERFACE_DEFINED__
IFNDEF __INATNumberOfEntriesCallback_INTERFACE_DEFINED__
; interface INATNumberOfEntriesCallback
; [unique][helpstring][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STINATNumberOfEntriesCallback STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
NewNumberOfEntries comethod2 ?
STINATNumberOfEntriesCallback ENDS
INATNumberOfEntriesCallback MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STINATNumberOfEntriesCallback PTR[edx]).>,<&Function,ppvINATNumberOfEntriesCallback>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvINATNumberOfEntriesCallback
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __INATNumberOfEntriesCallback_INTERFACE_DEFINED__
IFNDEF __IDynamicPortMappingCollection_INTERFACE_DEFINED__
; interface IDynamicPortMappingCollection
; [unique][helpstring][dual][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STIDynamicPortMappingCollection STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
GetTypeInfoCount comethod2 ?
GetTypeInfo comethod4 ?
GetIDsOfNames comethod6 ?
Invoke comethod9 ?
get__NewEnum comethod2 ?
get_Item comethod5 ?
get_Count comethod2 ?
Remove comethod4 ?
Add comethod10 ?
STIDynamicPortMappingCollection ENDS
IDynamicPortMappingCollection MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STIDynamicPortMappingCollection PTR[edx]).>,<&Function,ppvIDynamicPortMappingCollection>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvIDynamicPortMappingCollection
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __IDynamicPortMappingCollection_INTERFACE_DEFINED__
IFNDEF __IDynamicPortMapping_INTERFACE_DEFINED__
; interface IDynamicPortMapping
; [unique][helpstring][dual][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STIDynamicPortMapping STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
GetTypeInfoCount comethod2 ?
GetTypeInfo comethod4 ?
GetIDsOfNames comethod6 ?
Invoke comethod9 ?
get_ExternalIPAddress comethod2 ?
get_RemoteHost comethod2 ?
get_ExternalPort comethod2 ?
get_Protocol comethod2 ?
get_InternalPort comethod2 ?
get_InternalClient comethod2 ?
get_Enabled comethod2 ?
get_Description comethod2 ?
get_LeaseDuration comethod2 ?
RenewLease comethod3 ?
EditInternalClient comethod2 ?
Enable comethod2 ?
EditDescription comethod2 ?
EditInternalPort comethod2 ?
STIDynamicPortMapping ENDS
IDynamicPortMapping MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STIDynamicPortMapping PTR[edx]).>,<&Function,ppvIDynamicPortMapping>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvIDynamicPortMapping
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __IDynamicPortMapping_INTERFACE_DEFINED__
IFNDEF __IStaticPortMappingCollection_INTERFACE_DEFINED__
; interface IStaticPortMappingCollection
; [unique][helpstring][dual][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STIStaticPortMappingCollection STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
GetTypeInfoCount comethod2 ?
GetTypeInfo comethod4 ?
GetIDsOfNames comethod6 ?
Invoke comethod9 ?
get__NewEnum comethod2 ?
get_Item comethod4 ?
get_Count comethod2 ?
Remove comethod3 ?
Add comethod8 ?
STIStaticPortMappingCollection ENDS
IStaticPortMappingCollection MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STIStaticPortMappingCollection PTR[edx]).>,<&Function,ppvIStaticPortMappingCollection>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvIStaticPortMappingCollection
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __IStaticPortMappingCollection_INTERFACE_DEFINED__
IFNDEF __IStaticPortMapping_INTERFACE_DEFINED__
; interface IStaticPortMapping
; [unique][helpstring][dual][uuid][object]
IF DEFINED (__cplusplus) AND NOTDEFINED (CINTERFACE)
ELSE
STIStaticPortMapping STRUCT
QueryInterface comethod3 ?
AddRef comethod1 ?
Release comethod1 ?
GetTypeInfoCount comethod2 ?
GetTypeInfo comethod4 ?
GetIDsOfNames comethod6 ?
Invoke comethod9 ?
get_ExternalIPAddress comethod2 ?
get_ExternalPort comethod2 ?
get_InternalPort comethod2 ?
get_Protocol comethod2 ?
get_InternalClient comethod2 ?
get_Enabled comethod2 ?
get_Description comethod2 ?
EditInternalClient comethod2 ?
Enable comethod2 ?
EditDescription comethod2 ?
EditInternalPort comethod2 ?
STIStaticPortMapping ENDS
IStaticPortMapping MACRO Function:REQ, args:VARARG
; definition de la macro locale InvokeInterface
LOCAL InvokeInterface, arg
FOR arg, <args> ;verifier que edx n'est pas dans la liste d'arguments args
IFIDNI <&arg>, <edx> ;
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
ENDM
IFIDNI <&pInterface>, <edx>
.ERR <edx is not allowed as a coinvoke parameter>
ENDIF
;InvokeInterface = concatene ...CATSTR(concatene) MACRO instruction MASM32
;---------- on doit mettre ppv en premier argument -----------------------------------
InvokeInterface CATSTR <invoke (STIStaticPortMapping PTR[edx]).>,<&Function,ppvIStaticPortMapping>
IFNB <args> ; add the list of parameter arguments if any
InvokeInterface CATSTR InvokeInterface, <, >, <&args>
ENDIF
; forme les lignes de codes
mov edx, ppvIStaticPortMapping
mov edx, [edx]
InvokeInterface
ENDM
IFDEF COBJMACROS
ENDIF ; COBJMACROS
ENDIF ; C style interface
ENDIF ; __IStaticPortMapping_INTERFACE_DEFINED__
IFNDEF __NATUPNPLib_LIBRARY_DEFINED__
; library NATUPNPLib
; [helpstring][version][uuid]
IFDEF __cplusplus
ENDIF
ENDIF ; __NATUPNPLib_LIBRARY_DEFINED__
; Additional Prototypes for ALL interfaces
; end of Additional Prototypes
IFDEF __cplusplus
ENDIF
ENDIF