News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Everybody, please help to change the below ISAPI Extention for the MASM32 source

Started by haoren108, March 09, 2013, 02:00:25 PM

Previous topic - Next topic

haoren108

My thanks for you is beyond i can say.It can't be better!But there is still an error:
AsmIsapi.asm(13) : fatal error A1000: cannot open file : HttpExt.inc

japheth

Quote from: haoren108 on March 10, 2013, 11:30:20 PM
AsmIsapi.asm(13) : fatal error A1000: cannot open file : HttpExt.inc

The sample is supposed to be assembled using WinInc, not Masm32 - file httpext.inc is contained in WinInc.

The readme of the sample talks about Win32Inc - which was the former name of WinInc.

For an experienced assembly code it's trivial to adjust the sample so it assembles with Masm32, but if you aren't, it might be real work.


haoren108

With the help of japheth and qWord,i got the below code after countless tries. Show it here to help who in need.

;
;   Program Name: isa2.asm
;   Author: Haoren108
;   Date:  2013.03.13
;   Email: Haoren108@tom.com
;   This is an example of ISAPI extension in assembly.
;   Once built with WinInc or MASM32.
;   Thanks for help from japheth,qWord,...
.386
.model flat,stdcall
option casemap:none
;
include windows.inc
;include user32.inc ;Needed in MASM32
;include kernel32.inc ;Needed in MASM32
;
include HTTPEXT.inc
;
includelib user32.lib
includelib kernel32.lib
;
;
CStr macro sText:VARARG
local xxx
   .const
xxx db sText,0
   .code
   exitm <offset xxx>
   endm
;
;
;
.const
sConBody db "Hello World %s",13,10,0
sConHead db "Content-Type: text/html",13,10
      db "Content-Length: %u",13,10,13,10,0
;
;
.data
;
;
.data?
;
;
;
.code
DllMain proc hInstDLL:HINSTANCE, reason:DWORD,resrvd:DWORD
   mov eax,TRUE
   ret
DllMain Endp
;
;
;
GetExtensionVersion proc pVer:ptr HSE_VERSION_INFO
   mov ecx,pVer
   ;mov [ecx].HSE_VERSION_INFO.dwExtensionVersion,HSE_VERSION ;To be solved in MASM32
   mov [ecx].HSE_VERSION_INFO.dwExtensionVersion,262144
   invoke wsprintf,addr [ecx].HSE_VERSION_INFO.lpszExtensionDesc,CStr("ASM ISAPI Extension")
   mov eax,TRUE
   ret
GetExtensionVersion endp
;
HttpExtensionProc proc pECB:ptr EXTENSION_CONTROL_BLOCK
   local dwLen:DWORD
   local sHead[128]:byte
   local sBody[256]:byte

   mov ebx,pECB
   assume ebx:ptr EXTENSION_CONTROL_BLOCK

   invoke wsprintf,addr sBody,addr sConBody,CStr("ISAPI in Asm")
   invoke lstrlen,addr sBody
   mov dwLen,eax

   invoke wsprintf,addr sHead,addr sConHead,dwLen
   invoke [ebx].ServerSupportFunction,[ebx].ConnID,HSE_REQ_SEND_RESPONSE_HEADER,0, 0, addr sHead

   invoke [ebx].WriteClient, [ebx].ConnID,addr sBody,addr dwLen,HSE_IO_SYNC

   ;invoke   MessageBox,NULL,addr sBody,NULL,MB_OK ;For debug,popup tips in WebServer

   assume ebx:nothing
   mov eax,HSE_STATUS_SUCCESS_AND_KEEP_CONN
   ret
HttpExtensionProc endp
;
TerminateExtension proc dwFlags:DWORD
   ret
TerminateExtension endp

End DllMain

dedndave