Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change
.386
.Model Flat, StdCall
Option CaseMap :None
AsigText Macro Name, Text:VarArg
Local lbl
Jmp lbl
Name DB Text, 0
lbl:
EndM
coinvoke Macro ppv:Req,interface:Req,member:Req,p1,p2,p3,p4,p5,p6,p7,p8,p9,p10,p11,p12,p13,p14,p15,p16
FOR arg,<p16,p15,p14,p13,p12,p11,p10,p9,p8,p7,p6,p5,p4,p3,p2,p1>
IFNB <arg>
Push arg
ENDIF
EndM
Mov Eax,ppv
Push Eax
Mov Eax,DWord Ptr [Eax]
Call @CatStr(interface,<.>,member)[Eax]
EndM
.Const
GuiPolicy TextEqu <{098325047H, 0C671H, 04174H, {08DH, 081H, 0DEH, 0FCH, 0D3H, 0F0H, 031H, 086H}}>
IID_FwRule TextEqu <{0AF230D27H, 0BABAH, 04E42H, {0ACH, 0EDH, 0F5H, 024H, 0F2H, 02CH, 0FCH, 0E2H}}>
NET_FW_ACTION_BLOCK Equ 0
NET_FW_RULE_DIR_IN Equ 1
.Data?
IShellDispatch Struct
QueryInterface DD ?
AddRef DD ?
Release DD ?
GetTypeInfoCount DD ?
GetTypeInfo DD ?
GetIDsOfNames DD ?
_Invoke DD ?
get_Name DD ?
put_Name DD ?
get_Description DD ?
put_Description DD ?
get_ApplicationName DD ?
put_ApplicationName DD ?
get_serviceName DD ?
put_serviceName DD ?
get_Protocol DD ?
put_Protocol DD ?
get_LocalPorts DD ?
put_LocalPorts DD ?
get_RemotePorts DD ?
put_RemotePorts DD ?
get_LocalAddresses DD ?
put_LocalAddresses DD ?
get_RemoteAddresses DD ?
put_RemoteAddresses DD ?
get_IcmpTypesAndCodes DD ?
put_IcmpTypesAndCodes DD ?
get_Direction DD ?
put_Direction DD ?
get_Interfaces DD ?
put_Interfaces DD ?
get_InterfaceTypes DD ?
put_InterfaceTypes DD ?
get_Enabled DD ?
put_Enabled DD ?
get_Grouping DD ?
put_Grouping DD ?
get_Profiles DD ?
put_Profiles DD ?
get_EdgeTraversal DD ?
put_EdgeTraversal DD ?
get_Action DD ?
put_Action DD ?
IShellDispatch EndS
INetFwRules Struct
QueryInterface DD ?
AddRef DD ?
Release DD ?
GetTypeInfoCount DD ?
GetTypeInfo DD ?
GetIDsOfNames DD ?
_Invoke DD ?
get_Count DD ?
_Add DD ?
Remove DD ?
Item DD ?
get__NewEnum DD ?
INetFwRules EndS
INetFwPolicy2 Struct
QueryInterface DD ?
AddRef DD ?
Release DD ?
GetTypeInfoCount DD ?
GetTypeInfo DD ?
GetIDsOfNames DD ?
_invoke DD ?
get_CurrentProfileTypes DD ?
get_FirewallEnabled DD ?
put_FirewallEnabled DD ?
get_ExcludedInterfaces DD ?
put_ExcludedInterfaces DD ?
get_BlockAllInboundTraffic DD ?
put_BlockAllInboundTraffic DD ?
get_NotificationsDisabled DD ?
put_NotificationsDisabled DD ?
get_UnicastRTMDisabled DD ?
put_UnicastRTMBDisabled DD ?
get_Rules DD ?
get_ServiceRestriction DD ?
EnableRuleGroup DD ?
IsRuleGroupEnabled DD ?
RestoreLocalFirewallDefaults DD ?
get_DefaultInboundAction DD ?
put_DefaultInboundAction DD ?
get_DefaultOutboundAction DD ?
put_DefaultOutboundAction DD ?
get_IsRuleGroupCurrentlyEnabled DD ?
get_LocalPolicyModifyState DD ?
INetFwPolicy2 EndS
pFwPolicy2 DD ?
pFwRules DD ?
pFwRule DD ?
.Data
HandleConsola DD 0
CarroDeRetorno DB 13 ; Código ASCII para retorno de carro
NuevaLinea DB 10 ; Código ASCII para nueva línea
ProgID_HNetCfg_FwPolicy2 DW 'H', 'N', 'e', 't', 'C', 'f', 'g', '.', 'F', 'w', 'P', 'o', 'l', 'i', 'c', 'y', '2', 0
ProgID_HNetCfg_Fwrule DW 'H', 'N', 'e', 't', 'C', 'f', 'g', '.', 'F', 'W', 'R', 'u', 'l', 'e', 0
CLSIDFw GUID <>
IID_INetFwPolicy2 GUID GuiPolicy
CLSID_NetFwRule GUID <>
IID_INetFwRule GUID IID_FwRule
ruleName DW 'B', 'l', 'o', 'c', 'k', 'S', 'p', 'e', 'c', 'i', 'f', 'i', 'c', 'I', 'P', 0
ruleDescription DW 'B', 'l', 'o', 'c', 'k', ' ', 't', 'r', 'a', 'f', 'f', 'i', 'c', ' ', 'f', 'r', 'o', 'm', ' ', 's', 'p', 'e', 'c', 'i', 'f', 'i', 'c', ' ', 'I', 'P', 0
remoteAddresses DW '1', '9', '2', '.', '1', '6', '8', '.', '1', '.', '1', 0 ; Cambia esta IP a la que deseas bloquear
; ruleName DB "BlockSpecificIP", 0
; ruleDescription DB "Block traffic from specific IP", 0
; remoteAddresses DB "192.168.1.1", 0 ; Cambia esta IP a la que deseas bloquear
.Code
start:
Invoke GetStdHandle, STD_OUTPUT_HANDLE
Mov HandleConsola, Eax
;=====================
AsigText Cabecera0, "----------------------------------"
Invoke WriteConsoleA, HandleConsola, Addr Cabecera0, 25, 0, 0
Invoke ImprimirSaltoDeLinea
AsigText Cabecera1, "FraiFRW by Fraile - 2024."
Invoke WriteConsoleA, HandleConsola, Addr Cabecera1, 25, 0, 0
Invoke ImprimirSaltoDeLinea
AsigText Cabecera2, "----------------------------------"
Invoke WriteConsoleA, HandleConsola, Addr Cabecera2, 25, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke ImprimirSaltoDeLinea
;=====================
; Initialize COM library
Invoke CoInitialize, NULL
Cmp Eax, S_OK
Jne ErrorInicializacionCOM
Invoke CLSIDFromProgID, Addr ProgID_HNetCfg_FwPolicy2, Addr CLSIDFw
Cmp Eax, S_OK
Jne ErrorCLIDIdentifi
Invoke CoCreateInstance, Addr CLSIDFw, NULL, CLSCTX_LOCAL_SERVER, Addr IID_INetFwPolicy2, Addr pFwPolicy2
; Check if the instance was created successfully
Cmp Eax, S_OK
Jne ErrorCoCrea
Invoke CLSIDFromProgID, Addr ProgID_HNetCfg_Fwrule, Addr CLSID_NetFwRule
Cmp Eax, S_OK
Jne ErrorCLIDIdentifi
; Crear una instancia de la interfaz INetFwRule
Invoke CoCreateInstance, Addr CLSID_NetFwRule, NULL, CLSCTX_INPROC_SERVER, Addr IID_INetFwRule, Addr pFwRule
Cmp Eax, S_OK
Jne ErrorCoCreaRule
; Obtener la colección de reglas del firewall
;********************************************
coinvoke pFwPolicy2, INetFwPolicy2, get_Rules
Mov pFwRules, Eax
;********************************************
; Establecer las propiedades de la regla
Invoke SysAllocString, Addr ruleName
Cmp Eax, 0
Je ErrorSysAlloc
coinvoke pFwRule, IShellDispatch, put_Name, Eax
Invoke SysAllocString, Addr ruleDescription
Cmp Eax, 0
Je ErrorSysAlloc
coinvoke pFwRule, IShellDispatch, put_Description, Eax
Invoke SysAllocString, Addr remoteAddresses
Cmp Eax, 0
Je ErrorSysAlloc
coinvoke pFwRule, IShellDispatch, put_RemoteAddresses, Eax
; Establecer la acción de la regla (bloquear)
Mov Eax, NET_FW_ACTION_BLOCK
coinvoke pFwRule, IShellDispatch, put_Action, Eax
; Habilitar la regla
Mov Eax, 1 ; TRUE
coinvoke pFwRule, IShellDispatch, put_Enabled, Eax
; Agregar la regla al firewall
; Mensaje de éxito
AsigText ReglaCreada, "Regla Creada!."
Invoke WriteConsoleA, HandleConsola, Addr ReglaCreada, 14, 0, 0
Invoke ImprimirSaltoDeLinea
; Cerrar la biblioteca COM
Invoke CoUninitialize
Invoke ExitProcess, 0
ErrorInicializacionCOM:
AsigText Error0, "Error Ini COM."
Invoke WriteConsoleA, HandleConsola, Addr Error0, 14, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke CoUninitialize
Invoke ExitProcess, 1
ErrorCLIDIdentifi:
AsigText Error1, "Error Identifi Clid."
Invoke WriteConsoleA, HandleConsola, Addr Error1, 20, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke CoUninitialize
Invoke ExitProcess, 1
ErrorClsID:
AsigText Error2, "Error Clid."
Invoke WriteConsoleA, HandleConsola, Addr Error2, 11, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke CoUninitialize
Invoke ExitProcess, 1
ErrorCoCrea:
AsigText Error3, "Error al instanciar Obj."
Invoke WriteConsoleA, HandleConsola, Addr Error3, 25, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke CoUninitialize
Invoke ExitProcess, 1
ErrorCoCreaRule:
AsigText Error4, "Error al instanciar regla."
Invoke WriteConsoleA, HandleConsola, Addr Error4, 27, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke CoUninitialize
Invoke ExitProcess, 1
ErrorSysAlloc:
AsigText Error5, "Error SysAlloc."
Invoke WriteConsoleA, HandleConsola, Addr Error5, 15, 0, 0
Invoke ImprimirSaltoDeLinea
Invoke CoUninitialize
Invoke ExitProcess, 1
ImprimirSaltoDeLinea Proc
; Imprime un retorno de carro (CR) y una nueva línea (LF) en la consola
Invoke WriteConsole, HandleConsola, Addr CarroDeRetorno, 1, 0, 0
Invoke WriteConsole, HandleConsola, Addr NuevaLinea, 1, 0, 0
Ret
ImprimirSaltoDeLinea EndP
End start
Quote from: tda0626 on June 14, 2024, 05:04:32 AMIs that good for a line draw routine? Never benchmarked it. I am sure it could use a little bit of optimization.
Quote from: tda0626 on June 14, 2024, 05:04:32 AMWhen drawing a filled in rectangle or square, is there a preferred method? The way I draw it now is line by line, top to bottom.Well, assuming you've drawn a contiguous border, you could use a flood-fill routine, I guess, but that might actually be slower, as well as requiring recursion.
Quote from: _japheth on June 13, 2024, 08:38:09 PMQuote from: tda0626 on June 13, 2024, 04:11:48 AMThank you. Is the technique you are describing called double buffering?
No - I guess double buffering is closely related to "page flipping" ( changing the start address of the "visible" video memory ).QuoteWhen you allocate memory with DOS function AH=48, you specify the number of pages of memory needed as 1000h. Why did you specify that and not 4000 decimal, which is 64k/16?
You're right, 4000 would have been the exact value - 1000h wastes 1536 bytes.
Btw., I made some timing tests: your code, with the vsync wait deactivated, needs 86 ms for 600 loops - so < 150 microsecs for one loop - for my understanding that's far too fast to cause "flickering" troubles. Would be interesting to see what's displayed with a true CRT monitor attached - regrettably I don't have one.
Quote from: tda0626 on June 13, 2024, 04:11:48 AMThank you. Is the technique you are describing called double buffering?
QuoteWhen you allocate memory with DOS function AH=48, you specify the number of pages of memory needed as 1000h. Why did you specify that and not 4000 decimal, which is 64k/16?
QuoteZig is an effort to create a general-purpose programming language with program-level memory controls that outperforms C, while offering a more powerful and less error-prone syntax.
The goal is nothing less than supplanting C as the baseline language of the programming ecosystem.
Because C is ubiquitous (i.e., the most common component in systems and devices everywhere), success for Zig could mean widespread improvements in performance and stability.
That's something we should all hope for.
Plus, Zig is a good, old-fashioned grass-roots project with a huge ambition and an open-source ethos.