Hi Everyone
I wonder if anyone can help me
First
Did I convert this right from C to ASM
typedef struct {
char *name;
char *val;
} entry;
entry struct
name DWORD ?
val DWORD ?
entry ends
And these one I wish I knew how to convert to ASM
char *makeword(char *line, char stop);
This FILE *f, seems extra troublesome
char *fmakeword(FILE *f, char stop, int *len);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
Just guesing would
void plustospace(char *str);
plustospace proto C : PTR BYTE
Anyway the goal of all this help is to
To Call some functions in C, to use for breaking form posts
into an Structure Array, I have the C functions a library that can be called from my ASM program.
Of course the battle is not over till this
cl = atoi(getenv("CONTENT_LENGTH"));
ForLoop is broken down
for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries.val = fmakeword(stdin,'&',&cl);
plustospace(entries.val);
unescape_url(entries.val);
entries.name = makeword(entries.val,'=');
}
If I suceed it'll be Cool, Then I can see if I can convert the C
functions into ASM functions and drop 50k off my program
Thanks Andy!
I wonder if anyone can help me
First
Did I convert this right from C to ASM
typedef struct {
char *name;
char *val;
} entry;
entry struct
name DWORD ?
val DWORD ?
entry ends
And these one I wish I knew how to convert to ASM
char *makeword(char *line, char stop);
This FILE *f, seems extra troublesome
char *fmakeword(FILE *f, char stop, int *len);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
Just guesing would
void plustospace(char *str);
plustospace proto C : PTR BYTE
Anyway the goal of all this help is to
To Call some functions in C, to use for breaking form posts
into an Structure Array, I have the C functions a library that can be called from my ASM program.
Of course the battle is not over till this
cl = atoi(getenv("CONTENT_LENGTH"));
ForLoop is broken down
for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries.val = fmakeword(stdin,'&',&cl);
plustospace(entries.val);
unescape_url(entries.val);
entries.name = makeword(entries.val,'=');
}
If I suceed it'll be Cool, Then I can see if I can convert the C
functions into ASM functions and drop 50k off my program
Thanks Andy!
I like these posts, its the only way im able to "maintain" any memory of C :)
entry struct
name DWORD ?
val DWORD ?
entry ends
... This is correct!
char *makeword(char *line, char stop);
...I could be wrong, but this is a FUNCTION that returns a pointer to a character string (the "word"), that is extracted from another pointer to a line of text (char *line), and using the "stop" char as the character to separate with.
If im right with my assumptions here, then you would do this as:
This FILE *f, seems extra troublesome ; this is C jibberish!
Why i dont like using it anymore!
You can more or less forget this crap in MASM...
char *fmakeword(FILE *f, char stop, int *len);
This is now pretty much like the one above, except that you ALSO pass a pointer to an open file that contains the text to "make a word" from, as well as a length.
In MASM, you need to open a file handle via, CreateFile. Check out Iczelion's tutorials (in this section at the top) numbers 12, and 13 on file access. Once you have this done, the FILE HANDLE can be thought of as the "*f" in the C statement "FILE *f". Remember that handles are just DWORD's so your proto for this would be:
fmakeword PROTO :DWORD, :CHAR, :DWORD
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
Theses look like you dont quite like Pointers :) All of these statements require a pointer in their function parameters. In MASM, any TYPE of pointer is always considered a DWORD! Its up to you to treat the 32bit info AS a pointer!! So your proto/proc's would like wise have a :DWORD in their place. The preceeding "char" and "void"'s are also up to you to place in EAX before leaving (as all returns is "practiced" to be in EAX, or AX, or AL)
Just guesing would
void plustospace(char *str);
plustospace proto C : PTR BYTE
Yup, this "should" work. I dont practice the PTR BYTE stuff, i would just place a :DWORD (for reasons said earlier). But in all fairness, this would be the better practice.
Anyway the goal of all this help is to
To Call some functions in C, to use for breaking form posts
into an Structure Array, I have the C functions a library that can be called from my ASM program.
Of course the battle is not over till this
cl = atoi(getenv("CONTENT_LENGTH"));
.. umm ok, good luck! There is often some real issues between C and MASM (mainly the type of C compiler/linker). But i dont know more than this
ForLoop is broken down
for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries.val = fmakeword(stdin,'&',&cl);
plustospace(entries.val);
unescape_url(entries.val);
entries.name = makeword(entries.val,'=');
}
If I suceed it'll be Cool, Then I can see if I can convert the C
functions into ASM functions and drop 50k off my program
.. heh, more fun to come! (( I really dont miss reading that ))
-------------
Well theres my help... Enjoy, and good luck.
NaN
entry struct
name DWORD ?
val DWORD ?
entry ends
... This is correct!
char *makeword(char *line, char stop);
...I could be wrong, but this is a FUNCTION that returns a pointer to a character string (the "word"), that is extracted from another pointer to a line of text (char *line), and using the "stop" char as the character to separate with.
If im right with my assumptions here, then you would do this as:
makeword PROTO :DWORD, :BYTE
makeword PROC lpLine:DWORD, stop:BYTE
....
[ code ]
....
mov eax, lpMadeWord
ret
makeword ENDP
This FILE *f, seems extra troublesome ; this is C jibberish!
Why i dont like using it anymore!
You can more or less forget this crap in MASM...
char *fmakeword(FILE *f, char stop, int *len);
This is now pretty much like the one above, except that you ALSO pass a pointer to an open file that contains the text to "make a word" from, as well as a length.
In MASM, you need to open a file handle via, CreateFile. Check out Iczelion's tutorials (in this section at the top) numbers 12, and 13 on file access. Once you have this done, the FILE HANDLE can be thought of as the "*f" in the C statement "FILE *f". Remember that handles are just DWORD's so your proto for this would be:
fmakeword PROTO :DWORD, :CHAR, :DWORD
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *str);
Theses look like you dont quite like Pointers :) All of these statements require a pointer in their function parameters. In MASM, any TYPE of pointer is always considered a DWORD! Its up to you to treat the 32bit info AS a pointer!! So your proto/proc's would like wise have a :DWORD in their place. The preceeding "char" and "void"'s are also up to you to place in EAX before leaving (as all returns is "practiced" to be in EAX, or AX, or AL)
Just guesing would
void plustospace(char *str);
plustospace proto C : PTR BYTE
Yup, this "should" work. I dont practice the PTR BYTE stuff, i would just place a :DWORD (for reasons said earlier). But in all fairness, this would be the better practice.
Anyway the goal of all this help is to
To Call some functions in C, to use for breaking form posts
into an Structure Array, I have the C functions a library that can be called from my ASM program.
Of course the battle is not over till this
cl = atoi(getenv("CONTENT_LENGTH"));
.. umm ok, good luck! There is often some real issues between C and MASM (mainly the type of C compiler/linker). But i dont know more than this
ForLoop is broken down
for(x=0;cl && (!feof(stdin));x++) {
m=x;
entries.val = fmakeword(stdin,'&',&cl);
plustospace(entries.val);
unescape_url(entries.val);
entries.name = makeword(entries.val,'=');
}
If I suceed it'll be Cool, Then I can see if I can convert the C
functions into ASM functions and drop 50k off my program
.. heh, more fun to come! (( I really dont miss reading that ))
-------------
Well theres my help... Enjoy, and good luck.
NaN
Your Great! NaN
I was just about to post this
not to waste it
Do they look properly converted
char *makeword(char *line, char stop);
char *fmakeword(FILE *f, char stop, int *len);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *sstr);
I figure that if * is in front of something even a char
it's a dword
makeword proto C, line:PTR DWORD, stop:BYTE
fmakeword proto C, f:PTR FILE,stop:BYTE,len:PTR DWORD
x2c proto C, what:PTR DWORD
unescape_url proto C,url:PTR DWORD
plustospace proto C, sstr:PTR DWORD
[
But I follow your advice,
The real hard part if I get there is that forloop to see if everything
does work!
I really Thank You for the Help!
Andy981!
:)
I was just about to post this
not to waste it
Do they look properly converted
char *makeword(char *line, char stop);
char *fmakeword(FILE *f, char stop, int *len);
char x2c(char *what);
void unescape_url(char *url);
void plustospace(char *sstr);
I figure that if * is in front of something even a char
it's a dword
makeword proto C, line:PTR DWORD, stop:BYTE
fmakeword proto C, f:PTR FILE,stop:BYTE,len:PTR DWORD
x2c proto C, what:PTR DWORD
unescape_url proto C,url:PTR DWORD
plustospace proto C, sstr:PTR DWORD
But I follow your advice,
The real hard part if I get there is that forloop to see if everything
does work!
I really Thank You for the Help!
Andy981!
:)
Just curious do you have a Visual C++ compliler?
Actually the functions of those protos are calling are written in C,
but I have them in library made by my VC compliler being called
in an ASM file assemble in Hutch's Masm32. And that lib
I threw in the folder lib of my Masm32 directory
The proto's are in an include file
Andy981!
Actually the functions of those protos are calling are written in C,
but I have them in library made by my VC compliler being called
in an ASM file assemble in Hutch's Masm32. And that lib
I threw in the folder lib of my Masm32 directory
The proto's are in an include file
Andy981!
Ya I have VC++ 5. But it might as well be a plant holder for me :)
If i remember correctly, you can link VC and MASM with out probs (as long as you keep STDCALL and C proto as your doing). But other "C" versions like Borland have a different Obj format. (If your currious trigger f0dder or Hutch's intersts on this issue, they are walking archieves of such info :P )
NaN
If i remember correctly, you can link VC and MASM with out probs (as long as you keep STDCALL and C proto as your doing). But other "C" versions like Borland have a different Obj format. (If your currious trigger f0dder or Hutch's intersts on this issue, they are walking archieves of such info :P )
NaN