| 1 | ; $Id: fakea.asm,v 1.6 2001-07-10 05:26:52 bird Exp $
|
|---|
| 2 | ;
|
|---|
| 3 | ; Fake assembly imports.
|
|---|
| 4 | ;
|
|---|
| 5 | ; Copyright (c) 2000 knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 6 | ;
|
|---|
| 7 | ; Project Odin Software License can be found in LICENSE.TXT
|
|---|
| 8 | ;
|
|---|
| 9 |
|
|---|
| 10 | .386
|
|---|
| 11 |
|
|---|
| 12 | ;
|
|---|
| 13 | ; Defined Constants And Macros
|
|---|
| 14 | ;
|
|---|
| 15 | INCL_BASE EQU 1
|
|---|
| 16 |
|
|---|
| 17 | ;
|
|---|
| 18 | ; Include files
|
|---|
| 19 | ;
|
|---|
| 20 | include devsegdf.inc
|
|---|
| 21 | include devhlp.inc
|
|---|
| 22 | include os2.inc
|
|---|
| 23 | include options.inc
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 | ;
|
|---|
| 27 | ; Exported symbols
|
|---|
| 28 | ;
|
|---|
| 29 | public fakepTCBCur
|
|---|
| 30 | public fakepPTDACur
|
|---|
| 31 | public fakeptda_start
|
|---|
| 32 | public fakeptda_environ
|
|---|
| 33 | public fakeptda_handle
|
|---|
| 34 | public fakeptda_module
|
|---|
| 35 | public fakeptda_ptdasem
|
|---|
| 36 | public fakeptda_pBeginLIBPATH
|
|---|
| 37 | public fakef_FuStrLenZ
|
|---|
| 38 | public fakef_FuStrLen
|
|---|
| 39 | public fakef_FuBuff
|
|---|
| 40 | public fakeg_tkExecPgm
|
|---|
| 41 | public faketkStartProcess
|
|---|
| 42 | public CalltkExecPgm
|
|---|
| 43 | public _fakeldrOpenPath@20
|
|---|
| 44 | public fakeKMEnterKmodeSEF
|
|---|
| 45 | public fakeKMExitKmodeSEF8
|
|---|
| 46 | public fakeRASRST
|
|---|
| 47 | public fakedh_SendEvent
|
|---|
| 48 | public fakeh_POST_SIGNAL
|
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 | ;
|
|---|
| 52 | ; Imported Functions and Variables.
|
|---|
| 53 | ;
|
|---|
| 54 | extrn tkExecPgmWorker:PROC ; fake.c
|
|---|
| 55 | extrn _fakeLDRClearSem@0:PROC ; fake.c
|
|---|
| 56 | extrn _fakeKSEMRequestMutex@8:PROC ; fake.c
|
|---|
| 57 | extrn _fakeldrOpenPath_old@16:PROC ; fake.c
|
|---|
| 58 | extrn _fakeldrOpenPath_new@20:PROC ; fake.c
|
|---|
| 59 | extrn _options:options ; d16globl.c
|
|---|
| 60 |
|
|---|
| 61 |
|
|---|
| 62 | DATA16 SEGMENT
|
|---|
| 63 | ; Fake data in 16-bit segment.
|
|---|
| 64 | fakepTCBCur dd offset FLAT:fakeTCB
|
|---|
| 65 | fakepPTDACur dd offset FLAT:fakeptda_start
|
|---|
| 66 |
|
|---|
| 67 | ; PTDA - Only use environ and ExecChild.
|
|---|
| 68 | fakeptda_start LABEL DWORD
|
|---|
| 69 | fakeptda_pPTDAParent dd 0
|
|---|
| 70 | fakeptda_pPTDASelf dd offset FLAT:fakeptda_start
|
|---|
| 71 | fakeptda_pPTDAFirstChild dd 0
|
|---|
| 72 | fakeptda_pPTDAExecChild dd offset FLAT:fakeptda_start
|
|---|
| 73 | fakeptda_dummy db 123 dup (0)
|
|---|
| 74 | fakeptda_environ dw 1 ; 1 is the hardcoded HOB of the win32ktst.exe's environment.
|
|---|
| 75 | fakeptda_ptdasem db 20 dup (0) ; PTDA semaphore - Intra-Process serialisation mutex KSEM (sg244640).
|
|---|
| 76 | fakeptda_handle dw 2 ; 2 is the hardcoded HPTDA of the current process.
|
|---|
| 77 | fakeptda_module dw 1 ; 1 is the hardcoded HMTE of the current executable module.
|
|---|
| 78 | fakeptda_pBeginLIBPATH dd 0 ; BEGINLIBPATH not implemented.
|
|---|
| 79 | dd 0 ; ENDLIBPATH not implemented.
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | ; TCB - just needs some dummy data for reading and writing to the TCBFailErr.
|
|---|
| 83 | fakeTCB db 220h dup (0CCh)
|
|---|
| 84 |
|
|---|
| 85 | DATA16 ENDS
|
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 | CODE16 SEGMENT
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 | ; Scans strings until empy-string is reached.
|
|---|
| 92 | ; input: bx:di
|
|---|
| 93 | ; uses: nearly all (save bp)
|
|---|
| 94 | ; return: cx size - CF clear
|
|---|
| 95 | ; ax error- CF set
|
|---|
| 96 | fakef_FuStrLenZ PROC FAR
|
|---|
| 97 | push 2 ; required by all 16-bit far procedures.
|
|---|
| 98 | push 2 ; dummy code.
|
|---|
| 99 | push 2 ; dummy code.
|
|---|
| 100 | push 2 ; dummy code.
|
|---|
| 101 | push es
|
|---|
| 102 |
|
|---|
| 103 | mov dx, di ; save di pointer.
|
|---|
| 104 | cmp bx, 7 ; check if NULL ptr.
|
|---|
| 105 | jle ffslz_badselector
|
|---|
| 106 |
|
|---|
| 107 | mov es, bx ; es:di -> string
|
|---|
| 108 | mov cx, di
|
|---|
| 109 | not cx ; maximum length is to segment end.
|
|---|
| 110 | xor ax, ax ; test against zero (scasb uses al to cmp with).
|
|---|
| 111 |
|
|---|
| 112 | ffslz_loop:
|
|---|
| 113 | repnz scasb
|
|---|
| 114 | jnz ffslz_no_term ; jump if cx = 0
|
|---|
| 115 | dec cx ; check if next is NULL too
|
|---|
| 116 | scasb
|
|---|
| 117 | jnz ffslz_loop
|
|---|
| 118 |
|
|---|
| 119 | ffslz_retok:
|
|---|
| 120 | mov cx, di
|
|---|
| 121 | sub cx, dx ; cx <- size (end ptr - start ptr)
|
|---|
| 122 | pop es
|
|---|
| 123 | add sp, 8
|
|---|
| 124 | clc
|
|---|
| 125 | db 66h
|
|---|
| 126 | retf
|
|---|
| 127 |
|
|---|
| 128 | ffslz_badselector:
|
|---|
| 129 | mov ax, ERROR_INVALID_SELECTOR
|
|---|
| 130 | jmp ffslz_reterr
|
|---|
| 131 |
|
|---|
| 132 | ;ffslz_invalidptr:
|
|---|
| 133 | ; mov ax, ERROR_INVALID_ACCESS
|
|---|
| 134 | ; jmp ffslz_reterr
|
|---|
| 135 |
|
|---|
| 136 | ffslz_no_term:
|
|---|
| 137 | mov ax, ERROR_TERMINATOR_NOT_FOUND
|
|---|
| 138 | ffslz_reterr:
|
|---|
| 139 | pop es
|
|---|
| 140 | add sp, 8
|
|---|
| 141 | stc
|
|---|
| 142 | db 66h
|
|---|
| 143 | retf
|
|---|
| 144 | fakef_FuStrLenZ ENDP
|
|---|
| 145 |
|
|---|
| 146 |
|
|---|
| 147 | ;
|
|---|
| 148 | ; Stringlength - Fake
|
|---|
| 149 | ; input: bx:di
|
|---|
| 150 | ; uses: nearly all (save bp)
|
|---|
| 151 | ; return: cx size - CF clear
|
|---|
| 152 | ; ax error- CF set
|
|---|
| 153 | fakef_FuStrLen PROC FAR
|
|---|
| 154 | push 2 ; required by all 16-bit far procedures.
|
|---|
| 155 | push 2 ; dummy code.
|
|---|
| 156 | push 2 ; dummy code.
|
|---|
| 157 | push 2 ; dummy code.
|
|---|
| 158 | push es
|
|---|
| 159 |
|
|---|
| 160 | mov dx, di ; save di pointer.
|
|---|
| 161 | cmp bx, 7 ; check if NULL ptr.
|
|---|
| 162 | jle ffslz_badselector
|
|---|
| 163 |
|
|---|
| 164 | mov es, bx ; es:di -> string
|
|---|
| 165 | mov cx, di
|
|---|
| 166 | not cx ; maximum length is to segment end.
|
|---|
| 167 | xor ax, ax ; test against zero (scasb uses al to cmp with).
|
|---|
| 168 |
|
|---|
| 169 | repnz scasb
|
|---|
| 170 | jnz ffslz_no_term ; jump if cx = 0
|
|---|
| 171 |
|
|---|
| 172 | ffslz_retok:
|
|---|
| 173 | mov cx, di
|
|---|
| 174 | sub cx, dx ; cx <- size (end ptr - start ptr)
|
|---|
| 175 | pop es
|
|---|
| 176 | add sp, 8
|
|---|
| 177 | clc
|
|---|
| 178 | db 66h
|
|---|
| 179 | retf
|
|---|
| 180 |
|
|---|
| 181 | ffslz_badselector:
|
|---|
| 182 | mov ax, ERROR_INVALID_SELECTOR
|
|---|
| 183 | jmp ffslz_reterr
|
|---|
| 184 |
|
|---|
| 185 | ;ffslz_invalidptr:
|
|---|
| 186 | ; mov ax, ERROR_INVALID_ACCESS
|
|---|
| 187 | ; jmp ffslz_reterr
|
|---|
| 188 |
|
|---|
| 189 | ffslz_no_term:
|
|---|
| 190 | mov ax, ERROR_TERMINATOR_NOT_FOUND
|
|---|
| 191 | ffslz_reterr:
|
|---|
| 192 | pop es
|
|---|
| 193 | add sp, 8
|
|---|
| 194 | stc
|
|---|
| 195 | db 66h
|
|---|
| 196 | retf
|
|---|
| 197 | fakef_FuStrLen ENDP
|
|---|
| 198 |
|
|---|
| 199 |
|
|---|
| 200 | ;memcpy
|
|---|
| 201 | ;input: bx:si pointer to source
|
|---|
| 202 | ; es:di pointer to target
|
|---|
| 203 | ; cx count of bytes to copy
|
|---|
| 204 | ;uses: nearly all (save bp), es, ds
|
|---|
| 205 | ;return: success CF clear
|
|---|
| 206 | ; failure CF set
|
|---|
| 207 | fakef_FuBuff PROC FAR
|
|---|
| 208 | push 2 ; required by all 16-bit far procedures.
|
|---|
| 209 | push 2 ; dummy code.
|
|---|
| 210 | push 2 ; dummy code.
|
|---|
| 211 | push 2 ; dummy code.
|
|---|
| 212 | push es
|
|---|
| 213 |
|
|---|
| 214 | cmp bx, 7 ; check if NULL ptr.
|
|---|
| 215 | jle ffslz_badselector
|
|---|
| 216 | mov ax, es
|
|---|
| 217 | cmp bx, 7 ; check if NULL ptr.
|
|---|
| 218 | jle ffslz_badselector
|
|---|
| 219 |
|
|---|
| 220 | mov ds, bx ; ds:si -> string
|
|---|
| 221 | mov ax, di
|
|---|
| 222 | not ax
|
|---|
| 223 | cmp ax, cx ; crosses segment boundrary...
|
|---|
| 224 | jb ffslz_invalidptr
|
|---|
| 225 | mov ax, si
|
|---|
| 226 | not ax
|
|---|
| 227 | cmp ax, cx ; crosses segment boundrary...
|
|---|
| 228 | jb ffslz_invalidptr
|
|---|
| 229 |
|
|---|
| 230 | ; movzx esi, si
|
|---|
| 231 | ; movzx edi, di
|
|---|
| 232 | ; movzx ecx, cx
|
|---|
| 233 | ; db 66h ; force it use extended registers.
|
|---|
| 234 | rep movsb
|
|---|
| 235 |
|
|---|
| 236 | ffslz_retok:
|
|---|
| 237 | xor ax, ax
|
|---|
| 238 | mov cx, di
|
|---|
| 239 | sub cx, dx ; cx <- size (end ptr - start ptr)
|
|---|
| 240 | pop es
|
|---|
| 241 | add sp, 8
|
|---|
| 242 | clc
|
|---|
| 243 | db 66h
|
|---|
| 244 | retf
|
|---|
| 245 |
|
|---|
| 246 | ffslz_badselector:
|
|---|
| 247 | mov ax, ERROR_INVALID_SELECTOR
|
|---|
| 248 | jmp ffslz_reterr
|
|---|
| 249 |
|
|---|
| 250 | ffslz_invalidptr:
|
|---|
| 251 | int 3
|
|---|
| 252 | mov ax, ERROR_INVALID_ACCESS
|
|---|
| 253 | jmp ffslz_reterr
|
|---|
| 254 |
|
|---|
| 255 | ffslz_no_term:
|
|---|
| 256 | mov ax, ERROR_TERMINATOR_NOT_FOUND
|
|---|
| 257 | ffslz_reterr:
|
|---|
| 258 | pop es
|
|---|
| 259 | add sp, 8
|
|---|
| 260 | stc
|
|---|
| 261 | db 66h
|
|---|
| 262 | retf
|
|---|
| 263 | fakef_FuBuff ENDP
|
|---|
| 264 |
|
|---|
| 265 |
|
|---|
| 266 | ;;
|
|---|
| 267 | ; RASRST faker.
|
|---|
| 268 | ; @status stupid stub.
|
|---|
| 269 | fakeRASRST proc near
|
|---|
| 270 | mov ax, ds
|
|---|
| 271 | mov ax, ds
|
|---|
| 272 | mov ax, ds
|
|---|
| 273 | mov ax, ds
|
|---|
| 274 | int 3
|
|---|
| 275 | fakeRASRST endp
|
|---|
| 276 |
|
|---|
| 277 |
|
|---|
| 278 | ;;
|
|---|
| 279 | ; dh_SendEvent faker.
|
|---|
| 280 | ; @status stupid stub.
|
|---|
| 281 | fakedh_SendEvent proc near
|
|---|
| 282 | mov ax, ds
|
|---|
| 283 | mov ax, ds
|
|---|
| 284 | mov ax, ds
|
|---|
| 285 | mov ax, ds
|
|---|
| 286 | int 3
|
|---|
| 287 | fakedh_SendEvent endp
|
|---|
| 288 |
|
|---|
| 289 |
|
|---|
| 290 | ;;
|
|---|
| 291 | ; POST_SIGNAL faker
|
|---|
| 292 | fakeh_POST_SIGNAL proc near
|
|---|
| 293 | ; dummy prolog.
|
|---|
| 294 | mov ax, ds
|
|---|
| 295 | mov ax, ds
|
|---|
| 296 | mov ax, ds
|
|---|
| 297 | mov ax, ds
|
|---|
| 298 | int 3
|
|---|
| 299 | fakeh_POST_SIGNAL endp
|
|---|
| 300 |
|
|---|
| 301 |
|
|---|
| 302 | CODE16 ENDS
|
|---|
| 303 |
|
|---|
| 304 |
|
|---|
| 305 |
|
|---|
| 306 | CODE32 SEGMENT
|
|---|
| 307 | ;;
|
|---|
| 308 | ; Faker of which simply clears the loader semaphore.
|
|---|
| 309 | ; @cproto none! (void _Optlink faketkStartProcess(void))
|
|---|
| 310 | ; @returns
|
|---|
| 311 | ; @param
|
|---|
| 312 | ; @uses
|
|---|
| 313 | ; @equiv
|
|---|
| 314 | ; @time
|
|---|
| 315 | ; @sketch
|
|---|
| 316 | ; @status
|
|---|
| 317 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 318 | ; @remark
|
|---|
| 319 | faketkStartProcess PROC NEAR
|
|---|
| 320 | push ebp
|
|---|
| 321 | mov ebp, esp
|
|---|
| 322 |
|
|---|
| 323 | push ebx
|
|---|
| 324 | push ecx
|
|---|
| 325 |
|
|---|
| 326 | call _fakeLDRClearSem@0
|
|---|
| 327 |
|
|---|
| 328 | pop ecx
|
|---|
| 329 | pop ebx
|
|---|
| 330 |
|
|---|
| 331 | xor eax, eax
|
|---|
| 332 | leave
|
|---|
| 333 | ret
|
|---|
| 334 | faketkStartProcess ENDP
|
|---|
| 335 |
|
|---|
| 336 |
|
|---|
| 337 | ;;
|
|---|
| 338 | ; Fake g_tkExecPgm implementation.
|
|---|
| 339 | ; @proto none. (void _Optlink fakeg_tkExecPgm(void);)
|
|---|
| 340 | ; @returns same as tkExecPgm: eax, edx and carry flag
|
|---|
| 341 | ; @param ax Exec flag
|
|---|
| 342 | ; ds:dx Filename address. (String)
|
|---|
| 343 | ; es:bx Environment address. (String)
|
|---|
| 344 | ; di:si Argument address. (String)
|
|---|
| 345 | ; @uses all - bp
|
|---|
| 346 | ; @sketch Copy the filename and arguments into a buffer we
|
|---|
| 347 | ; may modify later if this is a UNIX shellscript or
|
|---|
| 348 | ; a PE-file started by pe.exe.
|
|---|
| 349 | ; @status completely implemented.
|
|---|
| 350 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 351 | ;
|
|---|
| 352 | ;
|
|---|
| 353 | fakeg_tkExecPgm PROC NEAR
|
|---|
| 354 | push ebp
|
|---|
| 355 | mov ebp, esp
|
|---|
| 356 |
|
|---|
| 357 | ;
|
|---|
| 358 | ; Call C worker
|
|---|
| 359 | ;
|
|---|
| 360 | sub esp, 10h
|
|---|
| 361 | movzx eax, ax
|
|---|
| 362 | mov [esp + 00h], eax ; ExecFlag DWORD
|
|---|
| 363 |
|
|---|
| 364 | mov ax, es
|
|---|
| 365 | SelToFlat
|
|---|
| 366 | mov [esp + 08h], eax ; Environment ptr.
|
|---|
| 367 | mov ecx, eax
|
|---|
| 368 |
|
|---|
| 369 | mov ax, ds
|
|---|
| 370 | mov bx, dx
|
|---|
| 371 | SelToFlat
|
|---|
| 372 | mov [esp + 0ch], eax ; Filename ptr
|
|---|
| 373 |
|
|---|
| 374 | mov ax, di
|
|---|
| 375 | mov bx, si
|
|---|
| 376 | SelToFlat
|
|---|
| 377 | mov [esp + 04h], eax ; Argument ptr
|
|---|
| 378 | mov edx, eax
|
|---|
| 379 |
|
|---|
| 380 | mov eax, [esp + 00h] ; ExecFlag DWORD in eax
|
|---|
| 381 |
|
|---|
| 382 | mov bx, seg FLAT:DATA32
|
|---|
| 383 | mov ds, bx ; Make ds flat
|
|---|
| 384 | mov es, bx ; Make es flat
|
|---|
| 385 |
|
|---|
| 386 | call tkExecPgmWorker ;(ULONG flags, arg, env, prog)
|
|---|
| 387 | add esp, 10 ; eax, edx, ecx,
|
|---|
| 388 | ; ebp+8, ebp+c, ebp+10, ebp+14
|
|---|
| 389 | ; esp+0, esp+4, esp+08, esp+0c
|
|---|
| 390 | or eax, eax
|
|---|
| 391 | jnz ftkep_ret
|
|---|
| 392 | call faketkStartProcess ; If succesfully so far. call start process.
|
|---|
| 393 | jmp ftkep_ret2 ; <Currently no parameters are implemented.>
|
|---|
| 394 |
|
|---|
| 395 | ftkep_ret:
|
|---|
| 396 | push eax
|
|---|
| 397 | call _fakeLDRClearSem@0 ; clear the semaphore.
|
|---|
| 398 | pop eax
|
|---|
| 399 |
|
|---|
| 400 | ftkep_ret2:
|
|---|
| 401 | leave
|
|---|
| 402 | ret
|
|---|
| 403 | fakeg_tkExecPgm ENDP
|
|---|
| 404 |
|
|---|
| 405 |
|
|---|
| 406 | ;;
|
|---|
| 407 | ; Calls the fakeg_tkExecPgm procedure.
|
|---|
| 408 | ; @cproto ULONG _Optlink CalltkExecPgm(
|
|---|
| 409 | ; ULONG execFlags,
|
|---|
| 410 | ; PCSZ pArg,
|
|---|
| 411 | ; PCSZ pEnv,
|
|---|
| 412 | ; PCSZ pExecName);
|
|---|
| 413 | ; @returns
|
|---|
| 414 | ; @param eax (ebp +08h) execFlags
|
|---|
| 415 | ; @param edx (ebp +0ch) pArg
|
|---|
| 416 | ; @param ecx (ebp +10h) pEnv
|
|---|
| 417 | ; @param ebp + 14h pExecName
|
|---|
| 418 | ; @uses eax, ecx, edx
|
|---|
| 419 | ; @status completely implemented.
|
|---|
| 420 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 421 | ; @remark
|
|---|
| 422 | CalltkExecPgm PROC NEAR
|
|---|
| 423 | push ebp
|
|---|
| 424 | mov ebp, esp
|
|---|
| 425 | push ebx
|
|---|
| 426 | push edi
|
|---|
| 427 | push esi
|
|---|
| 428 | push es
|
|---|
| 429 | push ds
|
|---|
| 430 |
|
|---|
| 431 | ; Save parameters
|
|---|
| 432 | mov [ebp+08h], eax
|
|---|
| 433 |
|
|---|
| 434 | ;
|
|---|
| 435 | ; create input for fakeg_tkExecPgm
|
|---|
| 436 | ;
|
|---|
| 437 | mov eax, edx
|
|---|
| 438 | xor edi, edi
|
|---|
| 439 | xor esi, esi
|
|---|
| 440 | or eax, eax
|
|---|
| 441 | jz ctkep1
|
|---|
| 442 | FlatToSel
|
|---|
| 443 | mov di, ax
|
|---|
| 444 | mov esi, ebx ; di:si -> arguments
|
|---|
| 445 | ctkep1:
|
|---|
| 446 |
|
|---|
| 447 | mov eax, [ebp + 14h]
|
|---|
| 448 | xor edx, edx
|
|---|
| 449 | mov ds, dx
|
|---|
| 450 | or eax, eax
|
|---|
| 451 | jz ctkep2
|
|---|
| 452 | FlatToSel
|
|---|
| 453 | mov ds, ax
|
|---|
| 454 | mov edx, ebx ; ds:dx -> executable filename
|
|---|
| 455 | ctkep2:
|
|---|
| 456 |
|
|---|
| 457 | mov eax, ecx
|
|---|
| 458 | xor ebx, ebx
|
|---|
| 459 | mov es, bx
|
|---|
| 460 | or eax, eax
|
|---|
| 461 | jz ctkep3
|
|---|
| 462 | FlatToSel
|
|---|
| 463 | mov es, ax
|
|---|
| 464 | mov eax, ebx ; es:bx -> environment.
|
|---|
| 465 | ctkep3:
|
|---|
| 466 |
|
|---|
| 467 | mov eax, [ebp+08h] ; ax = exec flags.
|
|---|
| 468 |
|
|---|
| 469 | call far ptr FLAT:fakeg_tkExecPgm
|
|---|
| 470 |
|
|---|
| 471 | ;
|
|---|
| 472 | ; Restore and return.
|
|---|
| 473 | ;
|
|---|
| 474 | pop ds
|
|---|
| 475 | pop es
|
|---|
| 476 | pop esi
|
|---|
| 477 | pop edi
|
|---|
| 478 | pop ebx
|
|---|
| 479 | leave
|
|---|
| 480 | ret
|
|---|
| 481 | CalltkExecPgm ENDP
|
|---|
| 482 |
|
|---|
| 483 |
|
|---|
| 484 | ;;
|
|---|
| 485 | ; Gets the selector for the CODE16 segment.
|
|---|
| 486 | ; @cproto USHORT _Optlink GetSelectorCODE16(void)
|
|---|
| 487 | ; @returns Selector for the CODE16 segment.
|
|---|
| 488 | ; @uses eax
|
|---|
| 489 | ; @status completely implemented.
|
|---|
| 490 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 491 | GetSelectorCODE16 PROC NEAR
|
|---|
| 492 | xor eax, eax
|
|---|
| 493 | mov ax, seg CODE16
|
|---|
| 494 | ret
|
|---|
| 495 | GetSelectorCODE16 ENDP
|
|---|
| 496 |
|
|---|
| 497 |
|
|---|
| 498 | ;;
|
|---|
| 499 | ; Gets the selector for the DATA16 segment.
|
|---|
| 500 | ; @cproto USHORT _Optlink GetSelectorDATA16(void)
|
|---|
| 501 | ; @returns Selector for the DATA16 segment.
|
|---|
| 502 | ; @uses eax
|
|---|
| 503 | ; @status completely implemented.
|
|---|
| 504 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 505 | GetSelectorDATA16 PROC NEAR
|
|---|
| 506 | xor eax, eax
|
|---|
| 507 | mov ax, seg DATA16
|
|---|
| 508 | ret
|
|---|
| 509 | GetSelectorDATA16 ENDP
|
|---|
| 510 |
|
|---|
| 511 |
|
|---|
| 512 | ;;
|
|---|
| 513 | ; Gets the selector for the CODE32 segment.
|
|---|
| 514 | ; @cproto USHORT _Optlink GetSelectorCODE32(void)
|
|---|
| 515 | ; @returns Selector for the CODE32 segment.
|
|---|
| 516 | ; @uses eax
|
|---|
| 517 | ; @status completely implemented.
|
|---|
| 518 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 519 | GetSelectorCODE32 PROC NEAR
|
|---|
| 520 | xor eax, eax
|
|---|
| 521 | mov ax, seg FLAT:CODE32
|
|---|
| 522 | ret
|
|---|
| 523 | GetSelectorCODE32 ENDP
|
|---|
| 524 |
|
|---|
| 525 | ;;
|
|---|
| 526 | ; Gets the selector for the DATA32 segment.
|
|---|
| 527 | ; @cproto USHORT _Optlink GetSelectorDATA32(void)
|
|---|
| 528 | ; @returns Selector for the DATA32 segment.
|
|---|
| 529 | ; @uses eax
|
|---|
| 530 | ; @status completely implemented.
|
|---|
| 531 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 532 | GetSelectorDATA32 PROC NEAR
|
|---|
| 533 | xor eax, eax
|
|---|
| 534 | mov ax, seg FLAT:DATA32
|
|---|
| 535 | ret
|
|---|
| 536 | GetSelectorDATA32 ENDP
|
|---|
| 537 |
|
|---|
| 538 |
|
|---|
| 539 | ;;
|
|---|
| 540 | ; Wrapper for fakeldrOpenPath.
|
|---|
| 541 | ; @cproto ULONG LDRCALL fakeldrOpenPath(PCHAR pachFilename, USHORT cchFilename, ldrlv_t *plv, PULONG pful, ULONG lLibPath);
|
|---|
| 542 | ; @returns Return of the current fakeldrOpenPath
|
|---|
| 543 | ; @param pachFilename Pointer to modulename. Not zero terminated!
|
|---|
| 544 | ; @param cchFilename Modulename length.
|
|---|
| 545 | ; @param plv Loader local variables? (Struct from KERNEL.SDF)
|
|---|
| 546 | ; @param pful Pointer to flags which are passed on to ldrOpen.
|
|---|
| 547 | ; @param lLibPath New parameter in build 14053.
|
|---|
| 548 | ; ldrGetMte calls with 1
|
|---|
| 549 | ; ldrOpenNewExe calls with 3
|
|---|
| 550 | ; This is compared to the initial libpath index.
|
|---|
| 551 | ; The libpath index is:
|
|---|
| 552 | ; BEGINLIBPATH 1
|
|---|
| 553 | ; LIBPATH 2
|
|---|
| 554 | ; ENDLIBPATH 3
|
|---|
| 555 | ; The initial libpath index is either 1 or 2.
|
|---|
| 556 | ; - ignored -
|
|---|
| 557 | ; @uses ecx, eax, edx
|
|---|
| 558 | ; @sketch
|
|---|
| 559 | ; @status
|
|---|
| 560 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 561 | ; @remark
|
|---|
| 562 | _fakeldrOpenPath@20 PROC NEAR
|
|---|
| 563 | ASSUME ds:FLAT
|
|---|
| 564 | ; dummy prolog.
|
|---|
| 565 | push ebp
|
|---|
| 566 | mov ebp, esp
|
|---|
| 567 | sub esp, 10h
|
|---|
| 568 | add esp, 10h
|
|---|
| 569 | pop ebp
|
|---|
| 570 | ; real code
|
|---|
| 571 | cmp FLAT:DATA16:_options.ulBuild, 14053
|
|---|
| 572 | jge new
|
|---|
| 573 | jmp near ptr FLAT:CODE32:_fakeldrOpenPath_old@16
|
|---|
| 574 | new:
|
|---|
| 575 | jmp near ptr FLAT:CODE32:_fakeldrOpenPath_new@20
|
|---|
| 576 | _fakeldrOpenPath@20 ENDP
|
|---|
| 577 |
|
|---|
| 578 |
|
|---|
| 579 |
|
|---|
| 580 | ;;
|
|---|
| 581 | ; This is called at kernel entry.
|
|---|
| 582 | ; @cproto none
|
|---|
| 583 | ; @returns nothing
|
|---|
| 584 | ; @param none
|
|---|
| 585 | ; @uses nothing
|
|---|
| 586 | ; @status stub.
|
|---|
| 587 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 588 | fakeKMEnterKmodeSEF proc near
|
|---|
| 589 | ; dummy prolog.
|
|---|
| 590 | push ebp
|
|---|
| 591 | mov ebp, esp
|
|---|
| 592 | sub esp, 10h
|
|---|
| 593 | leave
|
|---|
| 594 | ret
|
|---|
| 595 | fakeKMEnterKmodeSEF endp
|
|---|
| 596 |
|
|---|
| 597 |
|
|---|
| 598 | ;;
|
|---|
| 599 | ; This is called at kernel exit.
|
|---|
| 600 | ; @cproto none
|
|---|
| 601 | ; @returns nothing
|
|---|
| 602 | ; @param none
|
|---|
| 603 | ; @uses nothing
|
|---|
| 604 | ; @status stub.
|
|---|
| 605 | ; @author knut st. osmundsen (knut.stange.osmundsen@mynd.no)
|
|---|
| 606 | fakeKMExitKmodeSEF8 proc near
|
|---|
| 607 | ; dummy prolog.
|
|---|
| 608 | push ebp
|
|---|
| 609 | mov ebp, esp
|
|---|
| 610 | sub esp, 10h
|
|---|
| 611 | leave
|
|---|
| 612 | ret
|
|---|
| 613 | fakeKMExitKmodeSEF8 endp
|
|---|
| 614 |
|
|---|
| 615 | CODE32 ENDS
|
|---|
| 616 |
|
|---|
| 617 | END
|
|---|