Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

32-bit function for wow64 #4

Open
scriptchildie opened this issue Jul 17, 2023 · 0 comments
Open

32-bit function for wow64 #4

scriptchildie opened this issue Jul 17, 2023 · 0 comments

Comments

@scriptchildie
Copy link

In case you would like to integrate this to your library.
Not exactly a syscall since it's calling ntdll!Wow64SystemServiceCall .
I will adapt to native x86 if there is any interest at all.

#include "textflag.h"
#define maxargs 16
//func Syscall(callid uint32,tramboline uintptr, argh ...uintptr) (uint32, error)
TEXT ·bpSyscall(SB),NOSPLIT,$0
	MOVL callid+0(FP), DX
	MOVL tramboline+4(FP), BX
	MOVL argh+8(FP), SI
	

	// SetLastError(0).
	MOVL	$0, 0x34(FS)
	
	// Copy args to the stack.
	MOVL	SP, BP
	PUSHL	AX
	MOVL	argh_len+0x0c(FP), CX	// words
	MOVL	CX, AX
	SALL	$2, AX
	SUBL	AX, SP			// room for args
	POPL 	AX
	MOVL	SP, DI
	CLD
	REP; MOVSL

	// Call stdcall or cdecl function.
	// DI SI BP BX are preserved, SP is not
	MOVL DX,AX
	CALL BX  

	// Return result.
	MOVL	AX, errcode+0x14(FP)

	RET

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant