-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcmdmode.asm
130 lines (125 loc) · 3.18 KB
/
cmdmode.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
.data
TW0 'script', szOptionScriptName
TW0 's', szOptionScriptNameS
TW0 'code1', szOptionCode1
TW0 'c1', szOptionCode1S
TW0 'code2', szOptionCode2
TW0 'c2', szOptionCode2S
TW0 'line', szOptionLine
TW0 'l', szOptionLineS
TW0 'plugin', szOptionPlugin
TW0 'p', szOptionPluginS
TW0 'filter', szOptionFilter
TW0 'f', szOptionFilterS
TW0 'import', szOptionImport
TW0 'i', szOptionImportS
TW0 'export', szOptionExport
TW0 'e', szOptionExportS
TW0 'scdir', szOptionScDir
TW0 'sd', szOptionScDirS
TW0 'txtdir', szOptionTxtDir
TW0 'td', szOptionTxtDirS
TW0 'newdir', szOptionNewDir
TW0 'nd', szOptionNewDirS
TW0 'con', szOptionConsole
TW0 'help', szOptionHelp
coCmdOptions\
_StCmdOption <offset szOptionScriptName,offset szOptionScriptNameS,0>
_StCmdOption <offset szOptionCode1,offset szOptionCode1S,0>
_StCmdOption <offset szOptionCode2,offset szOptionCode2S,0>
_StCmdOption <offset szOptionLine,offset szOptionLineS,0>
_StCmdOption <offset szOptionPlugin,offset szOptionPluginS,0>
_StCmdOption <offset szOptionFilter,offset szOptionFilterS,0>
_StCmdOption <offset szOptionImport,offset szOptionImportS,0>
_StCmdOption <offset szOptionExport,offset szOptionExportS,0>
_StCmdOption <offset szOptionScDir,offset szOptionScDirS,0>
_StCmdOption <offset szOptionTxtDir,offset szOptionTxtDirS,0>
_StCmdOption <offset szOptionNewDir,offset szOptionNewDirS,0>
.code
_GetCmdOption proc uses esi edi ebx _lpName
LOCAL @lpRslt
LOCAL @temp
LOCAL @nLen
mov edi,lpArgTbl
mov @lpRslt,0
.if _lpName
invoke lstrlenW,_lpName
shl eax,1
mov @nLen,eax
.else
mov @nLen,0
.endif
mov ebx,1
.while ebx<nArgc
mov esi,[edi+ebx*4]
.if @nLen==0
.if word ptr [esi]!='/'
mov @lpRslt,esi
.break
.endif
jmp _CtnGCO
.endif
cmp word ptr [esi],'/'
jne _CtnGCO
add esi,2
mov edx,esi
.while word ptr [edx]
.break .if word ptr [edx]=='='
add edx,2
.endw
mov @temp,edx
sub edx,esi
cmp edx,@nLen
jne _CtnGCO
invoke crt_memcmp,_lpName,esi,edx
.if !eax
mov eax,@temp
.if word ptr [eax]=='='
add eax,2
.endif
mov @lpRslt,eax
.break
.endif
_CtnGCO:
inc ebx
.endw
mov eax,@lpRslt
ret
_GetCmdOption endp
_GetCmdOptions proc uses edi ebx _lpOptions
mov edi,_lpOptions
assume edi:ptr _StCmdOption
xor ebx,ebx
.while ebx<sizeof( _StCmdOptions)/sizeof( _StCmdOption)
invoke _GetCmdOption,[edi].lpszName
.if !eax
invoke _GetCmdOption,[edi].lpszSName
.endif
mov [edi].lpszValue,eax
_CtnGCO:
add edi,sizeof(_StCmdOption)
inc ebx
.endw
assume edi:nothing
mov edi,_lpOptions
.if _StCmdOptions.ScriptName.lpszValue[edi]==0
invoke _GetCmdOption,0
mov _StCmdOptions.ScriptName.lpszValue[edi],eax
.endif
mov ebx,_StCmdOptions.ScriptName.lpszValue[edi]
.if ebx!=0
invoke HeapAlloc,hGlobalHeap,0,MAX_STRINGLEN
test eax,eax
jz _ExGCO
mov _StCmdOptions.ScriptName.lpszValue[edi],eax
invoke GetFullPathNameW,ebx,MAX_STRINGLEN/2,eax,0
.endif
_ExGCO:
ret
_GetCmdOptions endp
;
;_CmdMain proc
;; mov edi,_lpOptions
;; invoke _GetCmdOption,offset szOptionHelp
; ret
;_CmdMain endp