Page 1 of 1

Application to Kernel Comm.

Posted: Wed Oct 16, 2002 11:00 pm
by VoidLogic
Application to Kernel Comm:

I was planing on using stucts and pointers to memory. ie:
(This is more of and advanced shell so DOS is present)

I.   Kernel Startup..etc etc etc
II.  The Kernel gets the command from user\script to load an app\driver
III. The Kernal calls the the .exe (ie PrntSrv.exe /0x1b2c0ffe *)

*Now here is where the problem comes in. How can I take that cstring (which is the pointer to the kernels process communication area) and and turn is back to a pointer? it can be made numeral value via stdlibs atol() funtion but how can i give that value to a pointer (dumb type checking makes it hard)?

Plz Help :) -VoidLogic

RE:Application to Kernel Comm.

Posted: Thu Oct 17, 2002 11:00 pm
by anton
int i=0x1b2c0ffe;
char* data=(char*)(void*)i;
Anton

RE:Application to Kernel Comm.

Posted: Thu Oct 17, 2002 11:00 pm
by Keith
All you need is one cast...either (void *) or (char *), not both.  As long as this is real C, pointers-to-void can be cast automatically to the type of the lvalue.

RE:Application to Kernel Comm.

Posted: Thu Oct 17, 2002 11:00 pm
by VoidLogic
I mean the opposte:
-I have a cstring = "0x1b2c0ffe"
-This cssring is converted to an long via atol
-Now I need too set the value in this long into a long ptr

srting Bob = "0x1b2c0ffe";
long BobVal = atol(Bob);
long *BobPtr = BobVal ?? ERR ?? I can't get this to cast, how?

Thanx for you help,
-VoidLogic

RE:Application to Kernel Comm.

Posted: Fri Oct 18, 2002 11:00 pm
by Keith
long *BobPtr = (long *)BobVal;

Standard casting here.

RE:Application to Kernel Comm.

Posted: Fri Oct 18, 2002 11:00 pm
by VoidLogic
Thank you, My Programming teacher tought us a different method of cast pointer that did not work for this, your godsend