|
-
Dec 14th, 2002, 02:26 PM
#1
Thread Starter
Hyperactive Member
Embedding binary (machine) code block into VB
Hi,
I have an old GW-Basic program that I'd like to resurrect part of it for VB. It used "POKE" to place a small 128 byte binary code block into Basic's address segment.
I'm wondering if there is any way to do something similar in VB. I'm thinking of perhaps a Byte array.
Has anyone ever persued doing this?
Below is the GW-Basic code that did this.
Thanks,
Al.
Code:
2640 ' Put API interface assembler code into memory.
2642 '
2644 CF$ = "WSFSBPAI.BIN" 'Input file name.
2645 AO% = 0 'Memory address offset.
2646 OPEN CF$ AS #2 LEN=128 'Open input file.
2648 FIELD #2, 128 AS B$ 'Define input buffer.
2649 CFL% = LOF(2) 'Get length of file.
2650 WR% = (CFL%\128)+1 'Calculate number of whole records.
2651 ' Read API interface code and poke into memory.
2652 FOR L1% = 1 TO WR%: GET #2
2653 FOR L2% = 1 TO 128: POKE AO%,ASC(MID$(B$,L2%,1)): AO% = AO%+1: NEXT L2%
2654 NEXT L1%
2658 APII% = 0 'Save address of API interface CALL handling code.
2660 DEF USR0 = 3 'Save address of API interface USR handling code.
2662 RC%=0: FUNCCODE%=0: FUNCNO%=0: APIREL$=" ": APIVER$=" "
2664 CALL APII%(RC%,FUNCCODE%,APIREL$,APIVER$,FUNCNO%) 'Retrieve API version information.
2666 IF FUNCCODE%<>&H0012 OR RC%<>0 THEN 2686 'API version not retrieved?
2668 PRINT "WSF API version ";APIVER$;", release ";APIREL$;" is running."
2670 SYSAV=2: ROWA=3 :'Define equates for WSF data items.
2682 RETURN
A computer is a tool, not a toy.
-
Dec 14th, 2002, 04:02 PM
#2
I wonder how many charact
Ah... good old Peek and Poke...
Anyhow... if you want to store 128 bytes of data in your application's address space....
well, how bout a 128-byte array?
Then there's this thing called the CopyMemory API... which writes in the parameter source data, for x amount of bytes, to a certain destination....
-
Dec 14th, 2002, 07:45 PM
#3
Thread Starter
Hyperactive Member
Thanks for the reply.
I had thought about using a byte array but I don't know how I'd call a routine/offset in the machine code. (varptr maybe?)
I'll also have a look at CopyMemory.
Thanks,
Al.
A computer is a tool, not a toy.
-
Dec 15th, 2002, 06:37 AM
#4
Fanatic Member
You can use cross-process memory reference, however in ur case,
ur own process. U can modify the stuffs in your own process
memory space, however, I highly recommend u should just modify
data and not execution code.
But why GW-BASIC and QBASIC can? Coz' u put those codes in
a memory address and u simply just jump to it, those codes has
no interference with BASIC's own executable codes or methods.
But I doubt you can't do it, it's possible, but no one has done it
b4. Remember: U can't modify but add extra codes unless you
know how VB handles those execution codes in low-level.
ASM,C,C++,BASIC,VB,JAVA,VBS,HTML,ASP,PHP,mySQL,VB.NET,MATLAB
Programming is fun, but only if you're not on a tight deadline 
So I consider all those working engineers sad people
VB FTP class
3 page PHP crash course
Crash Course on DX9 Managed with VB.NET covering basics till terrain creation
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|