Jeffrey Hutzelman
2011-Feb-18 13:34 UTC
[syslinux] [PATCH] core: Allow pasting from a VMware host by typing Ctrl-P
When Syslinux is running in a VMWare virtual machine and Ctrl-P is typed while editing the boot command line, insert the contents of VMware's clipboard. This allows text to be copied from the host (or wherever the console client is running) into Syslinux. Signed-off-by: Jeffrey Hutzelman <jhutz at cmu.edu> --- core/ui.inc | 72 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 72 insertions(+), 0 deletions(-) diff --git a/core/ui.inc b/core/ui.inc index 2d44447..0e82779 100644 --- a/core/ui.inc +++ b/core/ui.inc @@ -125,6 +125,8 @@ not_ascii: je print_version cmp al,'X' & 1Fh ; <Ctrl-X> je force_text_mode + cmp al,'P' & 1Fh ; <Ctrl-P> + je paste cmp al,08h ; Backspace jne get_char backspace: cmp di,command_line ; Make sure there is anything @@ -143,6 +145,10 @@ force_text_mode: call vgaclearmode jmp enter_command +paste: + call vmware_paste + jmp get_char + set_func_flag: mov byte [FuncFlag],1 jmp short get_char_2 @@ -568,6 +574,72 @@ getchar_timeout: call vgahidecursor ret +; Copy data from VMware's clipboard to the command-line buffer +VMwareMagic equ 564D5868h ; VMWare magic number +VMwarePort equ 5658h ; VMWare magic port +vmware_paste: + mov eax,VMwareMagic + mov ebx,0 + mov cx,000ah ; Get VMware version + mov dx,VMwarePort + in eax,dx + cmp ebx,VMwareMagic + jne vmware_done + + mov eax,VMwareMagic + mov cx,0006h ; Get clipboard length + mov dx,VMwarePort + in eax,dx + and eax,eax + jz vmware_done + cmp eax,0ffffffffh + jz vmware_done + mov ebx,eax + +vmware_get_data: + mov eax,VMwareMagic + mov cx,00007h ; Get clipboard data + mov dx,VMwarePort + in eax,dx + mov ecx,4 + +vmware_paste_char: + and al,al + je vmware_clear_buffer + cmp al,7Fh ; <DEL> == <BS> + je vmware_no_enter + cmp al,' ' ; ASCII? + jb vmware_no_enter ; don't paste no non-ASCII + ja vmware_enter + cmp di,command_line ; Space must not be first + je short vmware_no_enter +vmware_enter: cmp di,max_cmd_len+command_line ; Check there's space + jnb short vmware_no_enter + stosb ; Save it + call writechr ; Echo to screen +vmware_no_enter: + shr eax,8 + dec ebx + je vmware_done + dec cx + jne vmware_paste_char + jmp vmware_get_data + +vmware_clear_buffer: + sub ebx,ecx + jle vmware_done + shr ebx,2 +vmware_clear_loop: + mov eax,VMwareMagic + mov cx,00007h ; Get clipboard data + mov dx,VMwarePort + in eax,dx + dec ebx + jne vmware_clear_loop + +vmware_done: + ret + ; ; This is it! We have a name (and location on the disk)... let's load ; that sucker!! First we have to decide what kind of file this is; base -- 1.7.1
H. Peter Anvin
2011-Feb-18 18:33 UTC
[syslinux] [PATCH] core: Allow pasting from a VMware host by typing Ctrl-P
On 02/18/2011 05:34 AM, Jeffrey Hutzelman wrote:> When Syslinux is running in a VMWare virtual machine and Ctrl-P > is typed while editing the boot command line, insert the contents > of VMware's clipboard. This allows text to be copied from the > host (or wherever the console client is running) into Syslinux. > > Signed-off-by: Jeffrey Hutzelman <jhutz at cmu.edu>No way in hell, sorry. You're touching I/O ports without first verifying that touching those I/O ports is safe. And no, I don't consider VMware's idea that you can just do a random "in" to be a safe method of detection. The other thing is that this would have to do into a lot more places than this.> + mov eax,VMwareMagic > + mov ebx,0 > + mov cx,000ah ; Get VMware version > + mov dx,VMwarePort > + in eax,dx-hpa