I used polib.exe to create .lib file from a .dll that I want to use with my program.
Then I used dll2inc to create the .inc file.

;;Here is the result of DLL2INC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
_Generate  PROTO SYSCALL               
_GetCountGenerate PROTO  :DWORD 
_GetFirstSolDepth PROTO SYSCALL
_GetFirstSolNodes PROTO SYSCALL
_GetFirstSolution PROTO SYSCALL
_GetNodesSearched PROTO SYSCALL
_GetProcessingTime PROTO SYSCALL
_HintX PROTO SYSCALL
_SetLevels PROTO SYSCALL
_Solve PROTO SYSCALL
_TestAlg PROTO SYSCALL

#define NOTECHS 9
NOTECHS EQU  9  ;;;;;in masm

C structure:
struct penCellType {
  int penMarks[9];
  int length;
};

masm translation:    ?????
penCellType STRUCT
  penMarks BYTE 9 dup(?)
  PenLength  DWORD  ?
penCellType ends

C structure :
struct hintInfoType {
  int hintCol;
  int hintRow;
  char hintText1[128];
  char hintText2[128];
};

masm translation:    ?????
hintInfoType STRUCT
  hintCol      DWORD  ?
  hintRow      DWORD  ?
  hintText1    DWORD  ?
  cchText1Max  DWORD  ?
  hintText2    DWORD  ?
  cchText2Max  DWORD  ?
hintInfoType  ENDS

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

This is the C command to the .dll file.

extern "C" __declspec(dllimport) int __stdcall Solve(int guessOnly,
  int guessExcluded, int diagonalVers, int diff, int v[9][9]);

extern "C" __declspec(dllimport) int __stdcall Generate(int partGrid[9][9],
  int diff, int diffMin, int diffMax, int diagonalVers, int symmetric);

extern "C" __declspec(dllimport) int __stdcall GetNodesSearched(void);

extern "C" __declspec(dllimport) int __stdcall GetFirstSolution(int column, int row);

extern "C" __declspec(dllimport) int __stdcall GetFirstSolDepth(void);

extern "C" __declspec(dllimport) int __stdcall GetFirstSolNodes(void);

extern "C" __declspec(dllimport) int __stdcall GetCountGenerate(void);

extern "C" __declspec(dllimport) int __stdcall GetProcessingTime(void);

extern "C" __declspec(dllimport) int __stdcall HintX(struct penCellType
  pen[9][9], struct hintInfoType * hintp, int v[9][9], int diff, int diagonalVers);


extern "C" __declspec(dllexport) int __stdcall SetLevels (int levels[NOTECHS);

NOTECHS levels:
Index=0
Index=1
Index=2
Index=3
Index=4
Index=5
Index=6
Index=7
Index=8

I would like to know if i'm right in trying to do it this way and can someone will be kind enough
to translate these C commands to masm for me. I have tryed to do it but my C understanding is
very poor.


Thanks

Guy

Posted on 2006-02-17 20:05:54 by Guy
masm translation:    ?????
penCellType STRUCT
  penMarks BYTE 9 dup(?)  ;this should be    penMarks dword 9 dup(?)
  PenLength  DWORD  ?
penCellType ends

i am not quite sure about the hintInfoType structure
Posted on 2006-02-17 20:11:51 by JinYang

NOTECHS EQU  9

penCellType struct
penMarsk dd 9 dup (?)
length1 dd ?
penCellType ends

hintInfoType struct
hintCol dd ?
hintRow dd ?
hintText1 db 128 dup (?)
hintText2 db 128 dup (?)
hintInfoType ends



Solve proto guessOnly:DWORD,guessExcluded:DWORD,diagonalVers:DWORD,diff:DWORD,vv:ptr DWORD
Generate proto partGrid:ptr DWORD,diff:DWORD,diffMin:DWORD,diffMax:DWORD,diagonalVers:DWORD,symmetric:DWORD
GetNodesSearched proto
GetFirstSolution proto column:DWORD,row:DWORD
GetFirstSolDepth proto
GetFirstSolNodes proto
GetCountGenerate proto
GetProcessingTime proto
HintX proto pen:ptr penCellType,hintp:ptr hintInfoType,vv:ptr DWORD,diff:DWORD,diagonalVers:DWORD
SetLevels proto levels:ptr DWORD


I wrote descriptive protos. Otherwise, actually every parameter is a dword.
Posted on 2006-02-17 23:55:18 by Ultrano
Thanks for your answer.

I have to change proto to proto C in order to get it work, otherwise I got an unresolved external message from the linker.

ex: Generate proto C :ptr DWORD,:DWORD,:DWORD,:DWORD,:DWORD,:DWORD

Is this right?

And now, how do I get the answer from the .dll?


Guy



Posted on 2006-02-18 09:25:24 by Guy
The asm procs must be stdcall, not C-call. Thus, if you leave your procs as "c-call", you'll get incorrect ESP. A workaround to these linker probs will be

GetProcessingTime@0:: ; <--- this label will fix it up
asmGetProcessingTime proc
    ret
asmGetProcessingTime endp


If the label doesn't get recognized again, make it recognizable.

>>>And now, how do I get the answer from the .dll?
What do you mean as answer? The return value is in EAX, as usual :)
Posted on 2006-02-18 10:44:26 by Ultrano

What I mean by answer is, when I call Generate like this:
invoke Generate, 9,3,0,0,FALSE,FALSE

I get a 0 in eax and that should be ok according to the info i got with this .dll .

This call to Generate should give me random numbers to fill in my prog.
That's where I can't find a way to get these random numbers.

I have another prog where I call an .exe file and call CreatePipe and CreateProcess from stdoutput and stdinput and get the answer in a buffer. This must be different with a .dll file
or I'm wrong in the way I understand .dll.


Guy



Posted on 2006-02-18 13:08:31 by Guy
since you already have the .lib, you can link your asm object with the dll.
"includelib thisdlls.lib"
then, the procedures from the DLL are directly usable for you, as if they were in a .obj or .lib file that you linked.

So, to use these procs, you just use "invoke" or "call" :)

Posted on 2006-02-19 06:12:01 by Ultrano