working on it ...

Filters

Explore Public Snippets

Sort by

Found 1,586 snippets

    public by juntalis  834  0  3  0

    Not-quite-compatible implementation of NASM's __utf16__ keyword for YASM.

    Not-quite-compatible implementation of NASM's __utf16__ keyword for YASM.: utf16_for_yasm.asm
    BITS 32
    
    %macro __utf16__ 1
    	%assign idx 1
    	%xdefine wstring 
    	%xdefine cstring %1
    	%strlen cstrlen cstring
    	%rep cstrlen
    		%substr cchar cstring idx
    		%if idx = 1
    			%xdefine wstring cchar, 0x0
    		%elif idx = cstrlen
    			%xdefine wstring wstring cchar, 0x0
    		%else
    			%xdefine wstring wstring cchar, 0x0,
    		%endif
    		%assign idx idx+1
    	%endrep
    	db wstring
    %endmacro
    
    %define u(S) __utf16__ S
    
    main:
    	pushf
    	pusha
    	xor eax, eax
    	add eax, wsDllPath - $
    	ret
    wsDllPath:
    	u('injected_dll')
    	dw 0x0
    
    
    

    public by ramntry  594  0  3  0

    Debugger

    Debugger: dbg.asm
    		model	tiny
    		.code
    		.486
    		org	100h
    _:
    
    fm_aligned = (offset free_memory - _ + 100h + 15) / 16 * 16
    load_address = fm_aligned + 100h
    
    start:		call	get_fname
    		call	open_file
    		call	get_fsize
    		call	read_file
    		call	close_file
    		call	set_int
    		mov	al, int_mode
    		cmp	al, 1
    		jz	victim_enter
    		call	set_breakpoint
    		jmp	victim_enter
    
    int_raport:	push	bp
    		mov	bp, sp
    		mov	dx, offset line_msg
    		mov	bx, ax
    		mov	ah, 9
    		int	21h
    		mov	dx, offset ip_eq_msg
    		int	21h
    		mov	ax, bx
    		call	hex4
    		mov	dx, offset segment_msg
    		mov	ah, 9
    		int	21h
    		mov	ax, [bp + 4]
    		call	hex4
    		mov	dx, offset ax_eq_msg
    		mov	ah, 9
    		int	21h
    		mov	ax, [bp + 6]
    		call	hex4
    		mov	dx, offset bx_eq_msg
    		mov	ah, 9
    		int	21h
    		mov	ax, [bp + 8]
    		call	hex4
    		mov	dx, offset cx_eq_msg
    		mov	ah, 9
    		int	21h
    		mov	ax, [bp + 10]
    		call	hex4
    		mov	dx, offset dx_eq_msg
    		mov	ah, 9
    		int	21h
    		mov	ax, [bp + 12]
    		call	hex4
    		mov	dx, offset line_msg
    		mov	ah, 9
    		int	21h
    		xor	ax, ax
    		int	16h
    		cmp	al, 'q'
    		jz	victim_ret
    		pop	bp
    		ret
    
    int_handler:	push	bp
    		mov	bp, sp
    		push	dx
    		push	cx
    		push	bx
    		push	ax
    		push	ds
    		push	cs
    		pop	ds
    		xor	cx, cx
    		mov	cl, int_mode
    		shr	cx, 1
    		mov	ax, [bp + 2]
    		sub	ax, cx
    		mov	[bp + 2], ax
    		call	int_raport
    		or	cl, cl
    		mov	al, broken_byte
    		mov	bx, breakpoint
    		pop	ds
    		mov	byte ptr [bx], al
    		pop	ax
    		pop	bx
    		pop	cx
    		pop	dx
    		pop	bp
    		iret
    
    set_int:	mov	al, int_mode
    		mov	ah, 35h
    		int	21h
    		mov	cx, bx
    		mov	bx, offset int_old
    		mov	[bx], cx
    		mov	cx, es
    		mov	[bx + 2], cx
    		mov	dx, offset int_handler
    		mov	ah, 25h
    		int	21h
    		ret
    
    restore_int:	mov	bx, offset int_old
    		mov	dx, [bx]
    		mov	cx, [bx + 2]
    		mov	al, int_mode
    		push	ds
    		mov	ds, cx
    		mov	ah, 25h
    		int	21h
    		pop	ds
    		ret
    
    set_breakpoint:	mov	ax, breakpoint
    		mov	bx, offset fm_aligned
    		add	bx, ax
    		mov	al, byte ptr [bx]
    		mov	dx, bx
    		mov	bx, offset broken_byte
    		mov	byte ptr [bx], al
    		mov	bx, dx
    		mov	byte ptr [bx], 0CCh
    		ret	
    
    victim_enter:	pushf
    		push	cs
    		push	offset victim_ret
    		push	0
    		pushf
    		jnz	bp_mode
    		pop	ax
    		or	ax, 100h
    		push	ax
    bp_mode:	mov	ax, cs
    		xor	bx, bx
    		add	bx, offset fm_aligned
    		mov	byte ptr [bx], 0CFh
    		shr	bx, 4
    		add	ax, bx
    		mov	es, ax
    		push	ax
    		push	100h
    		push	0
    		push	0
    		push	0
    		push	0
    		push	ax
    		mov	ax, 100h
    		mov	cl, int_mode
    		cmp	cl, 1
    		jnz 	bp_mode2
    		call	int_raport
    bp_mode2:	pop	ds
    		add	sp, 8
    		xor	ax, ax
    		xor	bx, bx
    		xor	cx, cx
    		xor	dx, dx
    		iret
    
    victim_ret:	push	cs
    		pop	ax
    		mov	ds, ax
    		mov	es, ax
    		mov	dx, offset line_msg
    		mov	ah, 9
    		int	21h
    		mov	dx, offset debug_endmsg
    		int	21h
    		mov	dx, offset line_msg
    		int	21h
    		call	restore_int
    		int	20h
    
    print_cmd:	mov	bx, 80h		; PSP:80 - command line length
    		xor	cx, cx
    		mov	cl, [bx]
    		or	cx, cx
    		jz	print_cmd_ret
    		dec	cx
    		mov	dx, 82h		; PSP:81 - command line itself
    		mov	bx, 1		; stdout handle
    		mov	ah, 40h		; write to a file
    		int	21h
    print_cmd_ret:	ret
    
    get_fname:	mov	bx, 80h
    		xor	cx, cx
    		mov	cl, [bx]
    		mov	di, offset filename
    		or	cx, cx
    		jz	print_usage
    		dec	cx
    		mov	si, 82h
    		cld
    get_fname_loop:	mov	al, byte ptr [si]
    		cmp	al, ' '
    		jz	get_fname_addr
    		movsb
    		loop	get_fname_loop
    		xor	ax, ax
    		stosb
    		jmp	this_is_trapmode
    get_fname_addr:	xor	ax, ax
    		stosb
    		xor	bx, bx
    		dec	cx
    get_fname_lp2:	inc	si
    		mov	bl, byte ptr [si]
    		sub	bx, 30h
    		cmp	bx, 9h
    		jle	get_fname_sml
    		sub	bx, 7h
    get_fname_sml:	shl	ax, 4
    		or	ax, bx
    		loop	get_fname_lp2
    		mov	bx, offset breakpoint
    		mov	[bx], ax
    		ret
    this_is_trapmode:
    		mov	bx, offset int_mode
    		mov	byte ptr [bx], 1
    		ret
    
    open_file:	mov	dx, offset filename
    		mov	ax, 3D00h		; open file in read mode
    		int	21h
    		jc	open_file_err
    		ret
    open_file_err:	mov	dx, offset fopen_errmsg
    		mov	ah, 9
    		int	21h
    		int	20h
    
    close_file:	mov	bx, ax
    		mov	ah, 3Eh			; close file
    		int	21h
    		ret
    
    get_fsize:	mov	bx, ax
    		mov	ax, 4201h		; seek from current position
    		xor	cx, cx
    		xor	dx, dx
    		int	21h
    		mov	di, dx
    		mov	si, ax			; DI:SI <- original position
    		mov	ax, 4202h		; seek from end of file
    		xor	cx, cx
    		xor	dx, dx
    		int	21h
    		push	ax
    		mov	ax, 4200h		; seek from start of file
    		mov	cx, di
    		mov	dx, si
    		int	21h			; restore original position
    		pop	cx			; CX <- size of file
    		mov	ax, bx
    		ret
    
    read_file:	push	ax
    		mov	bx, ax
    		mov	ah, 3fh			; read file
    		mov	dx, load_address
    		int	21h
    		jc	read_file_err
    		pop	ax
    		ret
    read_file_err:	mov	dx, offset fread_errmsg
    		mov	ah, 9
    		int	21h
    		int	20h
    		
    hex4:		push	ax
    		mov	al, ah
    		call	hex2
    		pop	ax
    hex2:		push	ax
    		shr	al, 4
    		call	hex1
    		pop	ax
    hex1:		push	ax
    		and	al, 0Fh
    		cmp	al, 10
    		sbb	al, 69h
    		das
    		mov	dl, al
    		mov	ah, 2h
    		int	21h
    		pop	ax
    		ret
    
    print_usage:	mov	dx, offset usage_str
    		mov	ah, 9
    		int	21h
    		int	20h
    
    filename	db	13 dup (?)
    usage_str	db	"Usage: dbg <filename>[ <breakpoint>]"
    		db	13,10,"  If a breakpoint isn't specified,"
    		db	13,10,"  dbg will go to tracing mode. Use keys:"
    		db	13,10,"       [Enter] -> next point"
    		db	13,10,"       [q]     -> quit",13,10
    		db	"Written by Roman Tereshin (tereshin.roman@gmail.com)$"
    fopen_errmsg	db	"Can not open file$"
    alloc_errmsg	db	"Can not allocate memory$"
    fread_errmsg	db	"Can not read file$"
    line_msg	db	13,10,"---------",13,10,'$'
    ip_eq_msg	db	      "ip = $"
    segment_msg	db	13,10,"ds = $"
    ax_eq_msg	db	13,10,"ax = $"
    bx_eq_msg	db	13,10,"bx = $"
    cx_eq_msg	db	13,10,"cx = $"
    dx_eq_msg	db	13,10,"dx = $"
    debug_endmsg	db	"END$"
    int_old		dw	2 dup (?)
    breakpoint	dw	0
    broken_byte	db	0CFh
    int_mode	db	3
    
    free_memory:
    
    end start
    
    

    external by StackOverflow  1  0  2  0

    How can I use .NET 4.7 assembly in .NET 2 project?

    I want to reference an assembly which is written in .NET 4.7 in a .NET 2.0 project in Visual Studio. I'm aware of a former practical solution to my question (here) but honestly I didn't quite understand that (I even read the solution in CodeProject). I even exported the assembly as COM (using tlbexp.exe), whenever I want to import that (using tlbim
    /* 
    The only way I can see is you take the assembly compiled against .NET 4.7 and with COM-visible types and host it into a separate host .exe (thus making an out-of-process COM server).  You'll need to read-up on this on how to create an OoP COM Server in .NET.
    
    Your .NET 2 client .exe can then refer to the COM types registered by the host.  As far as .NET is concerned it is talking to COM.  The fact that it is .NET 4.7 under the hood is incidental.
    
    You will end up with two processes talking to each other over a COM "wire".  COM is a binary protocol and is language independent. 
    
    
      I even exported the assembly as COM (using tlbexp.exe), whenever I want to import that (using tlbimp.exe) or add a reference to, I got an error saying that I cannot use an assembly which is exported from a .NET assembly.
    
    
    You would not have been able to to this because you are mixing a .NET 2 process  with 4.7 types (in-process COM).  That's why we went out-of-process.
    
    Remember, your .NET client will have to add a COM-reference and not a .NET assembly reference.  Treat everything as COM and it could work.
    
    Note:
    
    
    As per TheGeneral's point below, you may need to ensure that the .NET 2 CLR is installed on the client machine as well as .NET 4.7
     */
    

    external by M. Ruiz  1  0  2  0

    The type or namespace name 'ToolkitScriptManager' does not exist in the namespace 'AjaxControlToolkit' (are you missing an assembly reference?)

    I am working on a project where the reference is having 'AjaxControlToolKit' assembly added correctly. Also in the aspx file I have added the below tag: &lt;%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %&gt; Further in the aspx.cs file I have added the namespace to include Ajaxtoolkit controls: using
    /* 
    You need to add
     */
    using AjaxControlToolkit;
    
    
    /* 
    in your aspx.cs
     */
    

    external by StackOverflow  1  0  2  0

    How do you manage dependencies with inversion of control?

    I am a small software developer who builds a plugin-based app. Each plugin is its own assembly and references the main assembly like so: Plugin 1 references nuget packages and Application Core.dll Plugin 2 references nuget packages and Application Core.dll At run time, the main assembly loads all the assemblies in its current folder and enumer
    /* 
    One solution, which you may not like, is to stop using dynamic loading. If your app uses Plugin 1 and Plugin 2, make them NuGet or project references and let the build system figure out minimum versions of all common packages for you. You will also no longer need to change all the build output paths to get an easy development experience. Just use feature-flags/configuration to allow customers to choose the features they want, rather than adding/deleting dlls.
    
    Another option is to keep each plugin in their own folders with all of their own dependencies and the main program loads plugins in different App Domains. this only works on .NET Framework, not .NET Core, but it does have the advantage that a plugin that crashes has less chance of crashing the whole app. the program may be able to detect a crashed plugin/app domain and unload it. But app domains are almost like using different processes and you have inter-domain communication issues (everything must be serialisable)
     */
    

    external by TnTinMn  1  0  3  0

    Cross language DataRow index in DebuggerDisplay

    I am trying to customize debugged objects tooltips. To achieve this I have a library including Assembly: DebuggerDisplay attributes (Can the DebuggerDisplay attribute be applied to types one doesn&#39;t own?) in Visualizers folder (How to: Install a Visualizer). I would like to see a DataRow index so I have in vb.net &lt;Assembly: DebuggerDispl
    /* 
    The source code of Rows.IndexOf
     */
        public Int32 IndexOf(DataRow row) {
            if ((null == row) || (row.Table != this.table) || ((0 == row.RBTreeNodeId) && (row.RowState == DataRowState.Detached))) //Webdata 102857
                return -1;
            return list.IndexOf(row.RBTreeNodeId, row);
        }
    
    
    /* 
    shows that it returns the result of list.IndexOf
     */
        public int IndexOf (int nodeId, K item)
        {
            int index = -1;
            // BIG ASSUMPTION: There is not satellite tree, this is INDEX_ONLY.
            if (nodeId != NIL)
            {
                if ( (Object) Key(nodeId) == (Object)item) {
                    return GetIndexByNode(nodeId);
                }
                if ( (index=IndexOf(Left(nodeId), item)) != -1) {
                    return index;
                }
                if ( (index=IndexOf(Right(nodeId), item)) != -1) {
                    return index;
                }
            }
    
            return index;
        }
    
    
    /* 
    If we assume that it is valid to call GetIndexByNode directly and pass the DataRow.RBTreeNodeId value directly, then the following should work.
     */
    [assembly: DebuggerDisplay(@"Index = {Table.Rows.list.GetIndexByNode(RBTreeNodeId)}", Target = typeof(System.Data.DataRow))]
    
    
    /* 
    
     */
    

    external by StackOverflow  1  0  2  0

    BizTalk 2016 Could not load file or assembly Microsoft.SharePoint.Client

    I'm running BizTalk 2016 Developer edition with Feature Pack 2 and CU3. I've configured a Receive location to pull from a SharePoint 2013 library but I'm seeing the following in the event log: The adapter "Windows SharePoint Services" raised an error message. Details "Could not load file or assembly 'Microsoft.SharePoint.Client, Version=15.0.0.0,
    /* 
    I was able to solve this by installing the SharePoint Client Components SDK from the following site: https://www.microsoft.com/en-us/download/confirmation.aspx?id=35585
    
    Be sure to restart the host instance of the receive location after installing.
     */
    

    external by Raghulan Gowthaman  1  0  2  0

    What 'additional configuration' is necessary to reference a .NET 2.0 mixed mode assembly in a .NET 4.0 project?

    I have a project in which I'd like to use some of the .NET 4.0 features but a core requirement is that I can use the System.Data.SQLite framework which is compiled against 2.X. I see mention of this being possible such as the accepted answer here but I don't see how to actually achieve this. When I just try and run my 4.0 project while referencing
    /* 
    Also i had this issue with the class library, If any one have the issue with the class library added to your main application. Just add
     */
    <startup useLegacyV2RuntimeActivationPolicy="true">
    
    
    /* 
    to you main application which would then be picked by the class library.
     */
    

    external by J.B. Langston  3  0  1  0

    Z80 APA102 LED control via AY2149 GPIO port

    Z80 APA102 LED control via AY2149 GPIO port: apa102.asm
    ; Control APA102 LEDs attached to the YM2149 sound chip's GPIO port
    ; by bit banging a shift register on pins 0 (data) and 1 (clock)
    
    ; I have quite possibly turned my RC2014 into
    ; the world's most Rube Goldbergesque Arduino
    
            org 100h
            
    ymaddr  equ 0d8h                                ; address port on YM2149
    ymdata  equ 0d0h                                ; data port on YM2149
    mixer   equ 7h                                  ; mixer/IO control register
    iodira  equ 40h                                 ; port A direction bit
    iodirb  equ 80h                                 ; port B direction bit
    porta   equ 0eh                                 ; GPIO port A data register
    portb   equ 0fh                                 ; GPIO port B data register
    numleds equ 2                                   ; number of LEDs attached
    
            ld      a,mixer                         ; make port A output
            out     (ymaddr),a
            ld      a,iodira
            out     (ymdata),a
            ld      a,porta                         ; select port A
            out     (ymaddr),a
            ld      a,0                             ; clear port A
            out     (ymdata),a
            
            ld      hl,colors                       ; output colors to 2 LEDs
            ld      a,numleds
            call    sendleds
            ret
    
    ; colors to send to LEDs (4 bytes each)
    ; 111 + 5 bit brightness, 8 bit blue, 8 bit green, 8 bit red
    colors  db      0e7h, 00h, 0fh, 0ffh
            db      0e7h, 0ffh, 0fh, 00h
            
    ; send color bytes at HL to number of LEDs in A
    sendleds push bc
            ld      c,0                             ; output header (32 0 bits)
            call shiftout
            call shiftout
            call shiftout
            call shiftout
    nextled ld      b,4                             ; output 4 contiguous bytes
    nextbyte ld      c,(hl)                         ; per LED starting at HL
            call    shiftout
            inc     hl
            djnz    nextbyte
            dec     a
            jr      nz,nextled
            ld      c,0ffh                          ; output trailer (32 1 bits)
            call shiftout
            call shiftout
            call shiftout
            call shiftout
            pop bc
            ret
    
    ; shift out the byte in C
    shiftout push   af 
            push   bc 
            ld      b,8                          ; rotate through every bit in byte
    nextbit xor     a                            ; clear a
            rlc     c                            ; get msb in carry
            adc     0                            ; add to a
            out     (ymdata),a
            or      a,2
            out     (ymdata),a
            djnz    nextbit
            pop     bc
            pop     af
            ret
    
    

    external by alastorid  3  0  1  0

    a win32 program that can get arguments and return exit status . Assemble with nasm and link with alink.

    a win32 program that can get arguments and return exit status . Assemble with nasm and link with alink.: easy_asm_with_import.asm
    USE32
    
    extern __getmainargs
    extern _exit
    extern atoi
    extern printf
    extern puts
    extern CommandLineToArgvW
    extern GetCommandLineA
    
    ;;symbol import table
    import __getmainargs       msvcrt.dll
    import _exit               msvcrt.dll
    import atoi                msvcrt.dll
    import printf              msvcrt.dll
    import puts                msvcrt.dll
    import CommandLineToArgvW shell32.dll
    import GetCommandLineA   kernel32.dll
    
    ;;global var
    section .bss
    argc resd 1
    argv resd 1
    envp resd 1
    
    ;; like main, but without standrad main c wrap under the hood
    section .text use32 
    ..start: ;; get main args
        pushad
        push 0
        push 0
        push envp
        push argv
        push argc
        call [__getmainargs]
        add esp, 20
        mov ecx, dword [argc]
        cmp ecx,3
        jg Lchallenge
        push aNode
        call [puts]
        add esp, 4    
        xor eax, eax 
        jmp Lend
    Lchallenge:
        mov eax, dword [argv]
        dec ecx    
        lea eax,[eax+ ecx*4] ;last argv
        push dword [eax]
        call [atoi]
        add esp, 4    
        lea ebx,[a1202+eax]
        push ebx
        call [puts]
        add esp, 4
        popad
        push dword 2 ;; exit with status 2
        call [_exit]
    Lend:    
        popad
        push dword 0 ;; exit with status 0
        call [_exit]
        ret
    
    section .data 
    a1202  db "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz", 0
    aNode  db "Argc <= 3", 0
    
    section .rodata
    fmt db "%d\n",0
    
    
    
    • Public Snippets
    • Channels Snippets