Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1507 lines
33 KiB

  1. /*++
  2. Copyright (c) 1995-1999 Microsoft Corporation. All rights reserved.
  3. Module Name:
  4. native.h
  5. Abstract:
  6. Public header for facilities provided by msjava.dll.
  7. --*/
  8. #ifndef _NATIVE_
  9. #define _NATIVE_
  10. #ifndef JAVAVMAPI
  11. #if !defined(_MSJAVA_)
  12. #define JAVAVMAPI DECLSPEC_IMPORT
  13. #else
  14. #define JAVAVMAPI
  15. #endif
  16. #endif
  17. #pragma warning(disable:4115)
  18. #pragma warning(disable:4510)
  19. #pragma warning(disable:4512)
  20. #pragma warning(disable:4610)
  21. #ifdef __cplusplus
  22. extern "C" {
  23. #endif
  24. //----------------------------------------------------------------------------
  25. // Since handles have gone away, this is no op. The unhands() in this file
  26. // a redundant but useful for clarity.
  27. // Note: You can not just unhand an array to get at it's data, you must now
  28. // use unhand(x)->body.
  29. //----------------------------------------------------------------------------
  30. #define unhand(phobj) (phobj)
  31. //----------------------------------------------------------------------------
  32. //----------------------------------------------------------------------------
  33. #define JAVAPKG "java/lang/"
  34. //----------------------------------------------------------------------------
  35. // Standard Java declarations for built in types.
  36. //----------------------------------------------------------------------------
  37. typedef unsigned short unicode;
  38. typedef long int32_t;
  39. typedef __int64 int64_t;
  40. typedef int BOOL;
  41. typedef void *PVOID;
  42. typedef unsigned long DWORD;
  43. #ifndef _SIZE_T_DEFINED
  44. #define _SIZE_T_DEFINED
  45. typedef unsigned int size_t;
  46. #endif
  47. #ifndef VOID
  48. #define VOID void
  49. #endif
  50. #ifndef _BOOL_T_DEFINED
  51. #define _BOOL_T_DEFINED
  52. typedef BOOL bool_t;
  53. #endif
  54. #ifndef _BASETSD_H_
  55. #ifdef _WIN64
  56. typedef unsigned __int64 UINT_PTR;
  57. typedef unsigned __int64 SIZE_T;
  58. #else
  59. typedef unsigned int UINT_PTR;
  60. typedef unsigned long SIZE_T;
  61. #endif
  62. #endif
  63. #if !defined(_MSJAVA_)
  64. typedef struct OBJECT {
  65. const PVOID MSReserved;
  66. } OBJECT;
  67. #endif
  68. typedef OBJECT Classjava_lang_Object;
  69. typedef OBJECT Hjava_lang_Object;
  70. typedef OBJECT ClassObject;
  71. typedef Hjava_lang_Object JHandle;
  72. typedef Hjava_lang_Object HObject;
  73. //
  74. // UTF8 type definitions.
  75. //
  76. // These types are used to document when a given string is to be
  77. // interpreted as containing UTF8 data (as opposed to Ansi data).
  78. //
  79. typedef CHAR UTF8;
  80. typedef CHAR *PUTF8;
  81. typedef CONST CHAR *PCUTF8;
  82. //----------------------------------------------------------------------------
  83. // All RNI DLLs should export the following function to let the VM determine
  84. // if the DLL is compatible with it.
  85. //----------------------------------------------------------------------------
  86. DWORD __declspec(dllexport) __cdecl RNIGetCompatibleVersion();
  87. #ifndef RNIVER
  88. #define RNIMAJORVER 2
  89. #define RNIMINORVER 0
  90. #define RNIVER ((((DWORD) RNIMAJORVER) << 16) + (DWORD) RNIMINORVER)
  91. #endif
  92. //----------------------------------------------------------------------------
  93. // Use to get the length of an array an HObject.
  94. //----------------------------------------------------------------------------
  95. #define obj_length(hobj) ((unsigned long)(((ArrayOfSomething*)unhand(hobj))->length))
  96. //----------------------------------------------------------------------------
  97. // Thread entry/exit functions.
  98. // These functions should wrap any calls into the virtual machine.
  99. //----------------------------------------------------------------------------
  100. typedef struct {
  101. DWORD reserved[6];
  102. } ThreadEntryFrame;
  103. JAVAVMAPI
  104. BOOL
  105. __cdecl
  106. PrepareThreadForJava(
  107. PVOID pThreadEntryFrame
  108. );
  109. JAVAVMAPI
  110. BOOL
  111. __cdecl
  112. PrepareThreadForJavaEx(
  113. PVOID pThreadEntryFrame,
  114. DWORD dwFlags
  115. );
  116. JAVAVMAPI
  117. VOID
  118. __cdecl
  119. UnprepareThreadForJava(
  120. PVOID pThreadEntryFrame
  121. );
  122. // Don't install the standard Microsoft SecurityManager. Useful if an
  123. // application wants the process not to have an active SecurityManager or if it
  124. // plans on installing its own SecurityManager. If this or another thread
  125. // has already called PrepareThreadForJava without specifying this flag, then
  126. // this flag will be ignored-- the current SecurityManager (possibly null) is
  127. // used.
  128. #define PTFJ_DONTINSTALLSTANDARDSECURITY 0x00000001
  129. //----------------------------------------------------------------------------
  130. // Garbage Collection.
  131. //----------------------------------------------------------------------------
  132. typedef struct {
  133. UINT_PTR reserved[6];
  134. } GCFrame;
  135. JAVAVMAPI
  136. void
  137. __cdecl
  138. GCFramePush(
  139. PVOID pGCFrame,
  140. PVOID pObjects,
  141. DWORD cbObjectStructSize
  142. );
  143. JAVAVMAPI
  144. void
  145. __cdecl
  146. GCFramePop(
  147. PVOID pGCFrame
  148. );
  149. // 'Weak' ptrs
  150. JAVAVMAPI
  151. HObject**
  152. __cdecl
  153. GCGetPtr(
  154. HObject *phObj
  155. );
  156. JAVAVMAPI
  157. void
  158. __cdecl
  159. GCFreePtr(
  160. HObject **pphObj
  161. );
  162. #define GCGetWeakPtr GCGetPtr
  163. #define GCFreeWeakPtr GCFreePtr
  164. // 'Strong' ptrs
  165. JAVAVMAPI
  166. HObject**
  167. __cdecl
  168. GCNewHandle(
  169. HObject *phObj
  170. );
  171. JAVAVMAPI
  172. void
  173. __cdecl
  174. GCFreeHandle(
  175. HObject **pphObj
  176. );
  177. // 'Internal reserved pinned ptrs
  178. JAVAVMAPI
  179. HObject**
  180. __cdecl
  181. GCNewPinnedHandle(
  182. HObject *phObj
  183. );
  184. JAVAVMAPI
  185. void
  186. __cdecl
  187. GCFreePinnedHandle(
  188. HObject **pphObj
  189. );
  190. // GC write barrier support
  191. JAVAVMAPI
  192. void
  193. __cdecl
  194. GCSetObjectReferenceForObject(
  195. HObject* const * location,
  196. HObject* phObj
  197. );
  198. JAVAVMAPI
  199. void
  200. __cdecl
  201. GCSetObjectReferenceForHandle(
  202. HObject** pphHandle,
  203. HObject* phObj
  204. );
  205. JAVAVMAPI
  206. int
  207. __cdecl
  208. GCEnable(
  209. VOID
  210. );
  211. JAVAVMAPI
  212. int
  213. __cdecl
  214. GCDisable(
  215. VOID
  216. );
  217. JAVAVMAPI
  218. int
  219. __cdecl
  220. GCDisableCount(
  221. VOID
  222. );
  223. JAVAVMAPI
  224. int
  225. __cdecl
  226. GCEnableCompletely(
  227. VOID
  228. );
  229. JAVAVMAPI
  230. void
  231. __cdecl
  232. GCDisableMultiple(
  233. int cDisable
  234. );
  235. //----------------------------------------------------------------------------
  236. // "Built-in" object structures...
  237. // These include helper macro's to get at array data.
  238. //----------------------------------------------------------------------------
  239. #ifndef _WIN64
  240. #include <pshpack4.h>
  241. #endif
  242. typedef struct Classjava_lang_String Classjava_lang_String;
  243. #define Hjava_lang_String Classjava_lang_String
  244. typedef Hjava_lang_String HString;
  245. typedef struct ClassArrayOfByte
  246. {
  247. const PVOID MSReserved;
  248. const UINT_PTR length;
  249. char body[1];
  250. } ClassArrayOfByte;
  251. #define HArrayOfByte ClassArrayOfByte
  252. #define ArrayOfByte ClassArrayOfByte
  253. typedef struct ClassArrayOfBoolean
  254. {
  255. const PVOID MSReserved;
  256. const UINT_PTR length;
  257. char body[1]; // all entries must be 0 (FALSE) or 1 (TRUE)
  258. } ClassArrayOfBoolean;
  259. #define HArrayOfBoolean ClassArrayOfBoolean
  260. #define ArrayOfBoolean ClassArrayOfBoolean
  261. typedef struct ClassArrayOfChar
  262. {
  263. const PVOID MSReserved;
  264. const UINT_PTR length;
  265. unsigned short body[1];
  266. } ClassArrayOfChar;
  267. #define HArrayOfChar ClassArrayOfChar
  268. #define ArrayOfChar ClassArrayOfChar
  269. typedef struct ClassArrayOfShort
  270. {
  271. const PVOID MSReserved;
  272. const UINT_PTR length;
  273. short body[1];
  274. } ClassArrayOfShort;
  275. #define HArrayOfShort ClassArrayOfShort
  276. #define ArrayOfShort ClassArrayOfShort
  277. typedef struct ClassArrayOfInt
  278. {
  279. const PVOID MSReserved;
  280. const UINT_PTR length;
  281. long body[1];
  282. } ClassArrayOfInt;
  283. #define HArrayOfInt ClassArrayOfInt
  284. #define ArrayOfInt ClassArrayOfInt
  285. typedef struct ClassArrayOfLong
  286. {
  287. const PVOID MSReserved;
  288. const UINT_PTR length;
  289. __int64 body[1];
  290. } ClassArrayOfLong;
  291. #define HArrayOfLong ClassArrayOfLong
  292. #define ArrayOfLong ClassArrayOfLong
  293. typedef struct ClassArrayOfFloat
  294. {
  295. const PVOID MSReserved;
  296. const UINT_PTR length;
  297. float body[1];
  298. } ClassArrayOfFloat;
  299. #define HArrayOfFloat ClassArrayOfFloat
  300. #define ArrayOfFloat ClassArrayOfFloat
  301. typedef struct ClassArrayOfDouble
  302. {
  303. const PVOID MSReserved;
  304. const UINT_PTR length;
  305. double body[1];
  306. } ClassArrayOfDouble;
  307. #define HArrayOfDouble ClassArrayOfDouble
  308. #define ArrayOfDouble ClassArrayOfDouble
  309. typedef struct ClassArrayOfObject
  310. {
  311. const PVOID MSReserved;
  312. const UINT_PTR length;
  313. HObject * const body[1];
  314. } ClassArrayOfObject;
  315. #define HArrayOfObject ClassArrayOfObject
  316. #define ArrayOfObject ClassArrayOfObject
  317. typedef struct ClassArrayOfString
  318. {
  319. const PVOID MSReserved;
  320. const UINT_PTR length;
  321. HString * const (body[1]);
  322. } ClassArrayOfString;
  323. #define HArrayOfString ClassArrayOfString
  324. #define ArrayOfString ClassArrayOfString
  325. typedef struct ClassArrayOfArray
  326. {
  327. const PVOID MSReserved;
  328. const UINT_PTR length;
  329. JHandle * const (body[1]);
  330. } ClassArrayOfArray;
  331. #define HArrayOfArray ClassArrayOfArray
  332. #define ArrayOfArray ClassArrayOfArray
  333. typedef struct
  334. {
  335. const PVOID MSReserved;
  336. const UINT_PTR length;
  337. } ArrayOfSomething;
  338. #ifndef _WIN64
  339. #include <poppack.h>
  340. #endif
  341. //----------------------------------------------------------------------------
  342. // We automatically track the execution environment so there's no EE() call
  343. // needed anymore, just pass NULL if an API needs one.
  344. //----------------------------------------------------------------------------
  345. #define EE() ((struct execenv *)NULL)
  346. typedef void ExecEnv;
  347. typedef struct execenv execenv;
  348. //----------------------------------------------------------------------------
  349. // Exception handling stuff...
  350. //----------------------------------------------------------------------------
  351. JAVAVMAPI
  352. void
  353. __cdecl
  354. SignalError(
  355. ExecEnv *Unused,
  356. PCUTF8 putfClassName,
  357. LPCSTR pszDetailMessage
  358. );
  359. JAVAVMAPI
  360. void
  361. __cdecl
  362. SignalErrorPrintf(
  363. PCUTF8 putfClassName,
  364. LPCSTR pszFormat,
  365. ...
  366. );
  367. JAVAVMAPI
  368. bool_t
  369. __cdecl
  370. exceptionOccurred(
  371. ExecEnv *Unused
  372. );
  373. JAVAVMAPI
  374. void
  375. __cdecl
  376. exceptionDescribe(
  377. ExecEnv *Unused
  378. );
  379. JAVAVMAPI
  380. void
  381. __cdecl
  382. exceptionClear(
  383. ExecEnv *Unused
  384. );
  385. JAVAVMAPI
  386. void
  387. __cdecl
  388. exceptionSet(
  389. ExecEnv *Unused,
  390. HObject *phThrowable
  391. );
  392. JAVAVMAPI
  393. HObject *
  394. __cdecl
  395. getPendingException(
  396. ExecEnv *Unused
  397. );
  398. //----------------------------------------------------------------------------
  399. // Standard exec functions...
  400. //----------------------------------------------------------------------------
  401. #if !defined(_MSJAVA_)
  402. typedef PVOID ClassClass;
  403. #endif
  404. JAVAVMAPI
  405. HObject*
  406. __cdecl
  407. execute_java_constructor(
  408. ExecEnv *Unused,
  409. PCUTF8 putfClassName,
  410. ClassClass *pClass,
  411. PCUTF8 putfSignature,
  412. ...
  413. );
  414. JAVAVMAPI
  415. HObject*
  416. __cdecl
  417. execute_java_constructorV(
  418. ExecEnv *Unused,
  419. PCUTF8 putfClassName,
  420. ClassClass *pClass,
  421. PCUTF8 putfSignature,
  422. va_list args
  423. );
  424. JAVAVMAPI
  425. HObject*
  426. __cdecl
  427. execute_java_constructor_method(
  428. struct methodblock *mb,
  429. ...
  430. );
  431. JAVAVMAPI
  432. HObject*
  433. __cdecl
  434. execute_java_constructor_methodV(
  435. struct methodblock *mb,
  436. va_list args
  437. );
  438. //------------------------------------------------------------------------
  439. #ifndef execute_java_dynamic_method
  440. JAVAVMAPI
  441. long
  442. __cdecl
  443. execute_java_dynamic_method(
  444. ExecEnv *Unused,
  445. HObject *phObj,
  446. PCUTF8 putfMethod,
  447. PCUTF8 putfSignature,
  448. ...
  449. );
  450. #endif
  451. JAVAVMAPI
  452. int64_t
  453. __cdecl
  454. execute_java_dynamic_method64(
  455. ExecEnv *Unused,
  456. HObject *phObj,
  457. PCUTF8 putfMethod,
  458. PCUTF8 putfSignature,
  459. ...
  460. );
  461. JAVAVMAPI
  462. int64_t
  463. __cdecl
  464. execute_java_dynamic_methodV(
  465. ExecEnv *Unused,
  466. HObject *phObj,
  467. PCUTF8 putfMethod,
  468. PCUTF8 putfSignature,
  469. va_list args
  470. );
  471. //------------------------------------------------------------------------
  472. #ifndef execute_java_interface_method
  473. JAVAVMAPI
  474. long
  475. __cdecl
  476. execute_java_interface_method(
  477. ExecEnv *Unused,
  478. HObject *phObj,
  479. ClassClass *pClass,
  480. PCUTF8 putfMethod,
  481. PCUTF8 putfSignature,
  482. ...
  483. );
  484. #endif
  485. JAVAVMAPI
  486. int64_t
  487. __cdecl
  488. execute_java_interface_method64(
  489. ExecEnv *Unused,
  490. HObject *phObj,
  491. ClassClass *pClass,
  492. PCUTF8 putfMethod,
  493. PCUTF8 putfSignature,
  494. ...
  495. );
  496. JAVAVMAPI
  497. int64_t
  498. __cdecl
  499. execute_java_interface_methodV(
  500. ExecEnv *Unused,
  501. HObject *phObj,
  502. ClassClass *pClass,
  503. PCUTF8 putfMethod,
  504. PCUTF8 putfSignature,
  505. va_list args
  506. );
  507. //------------------------------------------------------------------------
  508. #ifndef execute_java_static_method
  509. JAVAVMAPI
  510. long
  511. __cdecl
  512. execute_java_static_method(
  513. ExecEnv *Unused,
  514. ClassClass *pClass,
  515. PCUTF8 putfMethod,
  516. PCUTF8 putfSignature,
  517. ...
  518. );
  519. #endif
  520. JAVAVMAPI
  521. int64_t
  522. __cdecl
  523. execute_java_static_method64(
  524. ExecEnv *Unused,
  525. ClassClass *pClass,
  526. PCUTF8 putfMethod,
  527. PCUTF8 putfSignature,
  528. ...
  529. );
  530. JAVAVMAPI
  531. int64_t
  532. __cdecl
  533. execute_java_static_methodV(
  534. ExecEnv *Unused,
  535. ClassClass *pClass,
  536. PCUTF8 putfMethod,
  537. PCUTF8 putfSignature,
  538. va_list args
  539. );
  540. //----------------------------------------------------------------------------
  541. // NB The resolve flag is ignored, classes found with this api will always
  542. // be resolved.
  543. //----------------------------------------------------------------------------
  544. JAVAVMAPI
  545. ClassClass*
  546. __cdecl
  547. FindClass(
  548. ExecEnv *Unused,
  549. PCUTF8 putfClassName,
  550. bool_t fResolve
  551. );
  552. //----------------------------------------------------------------------------
  553. // FindClassEx
  554. //
  555. // Similar to FindClass, but can take some flags that control how the class
  556. // load operation works.
  557. //
  558. // The valid flags are:
  559. //
  560. // FINDCLASSEX_NOINIT
  561. // If the class is a system class, will prevent the classes static
  562. // initializer from running.
  563. //
  564. // FINDCLASSEX_IGNORECASE
  565. // Will perform a case-insensitive validation of the class name, as
  566. // opposed to the case-sensitive validation that normally occurs.
  567. //
  568. // FINDCLASSEX_SYSTEMONLY
  569. // Will only look for the named class as a system class.
  570. //
  571. //----------------------------------------------------------------------------
  572. #define FINDCLASSEX_NOINIT 0x0001
  573. #define FINDCLASSEX_IGNORECASE 0x0002
  574. #define FINDCLASSEX_SYSTEMONLY 0x0004
  575. JAVAVMAPI
  576. ClassClass *
  577. __cdecl
  578. FindClassEx(
  579. PCUTF8 putfClassName,
  580. DWORD dwFlags
  581. );
  582. //----------------------------------------------------------------------------
  583. // FindClassFromClass
  584. //
  585. // Similar to FindClassEx, but takes a ClassClass that supplies the ClassLoader
  586. // context to use to
  587. //----------------------------------------------------------------------------
  588. JAVAVMAPI
  589. ClassClass *
  590. __cdecl
  591. FindClassFromClass(
  592. PCUTF8 putfClassName,
  593. DWORD dwFlags,
  594. ClassClass *pContextClass
  595. );
  596. //----------------------------------------------------------------------------
  597. // Helper function that returns a methodblock.
  598. //----------------------------------------------------------------------------
  599. JAVAVMAPI
  600. struct methodblock *
  601. __cdecl
  602. get_methodblock(
  603. HObject *phObj,
  604. PCUTF8 putfMethod,
  605. PCUTF8 putfSignature
  606. );
  607. //----------------------------------------------------------------------------
  608. // If you pass in a methodblock from get_methodblock the method name and
  609. // sig are ignored and so it's faster than a regular execute.
  610. //----------------------------------------------------------------------------
  611. #ifndef do_execute_java_method
  612. JAVAVMAPI
  613. long
  614. __cdecl
  615. do_execute_java_method(
  616. ExecEnv *Unused,
  617. void *phObj,
  618. PCUTF8 putfMethod,
  619. PCUTF8 putfSignature,
  620. struct methodblock *mb,
  621. bool_t isStaticCall,
  622. ...
  623. );
  624. #endif
  625. JAVAVMAPI
  626. int64_t
  627. __cdecl
  628. do_execute_java_method64(
  629. ExecEnv *Unused,
  630. void *phObj,
  631. PCUTF8 putfMethod,
  632. PCUTF8 putfSignature,
  633. struct methodblock *mb,
  634. bool_t isStaticCall,
  635. ...
  636. );
  637. JAVAVMAPI
  638. int64_t
  639. __cdecl
  640. do_execute_java_methodV(
  641. ExecEnv *Unused,
  642. void *phObj,
  643. PCUTF8 putfMethod,
  644. PCUTF8 putfSignature,
  645. struct methodblock *mb,
  646. bool_t isStaticCall,
  647. va_list args
  648. );
  649. //----------------------------------------------------------------------------
  650. // isInstanceOf
  651. //
  652. // Returns true if the specified object can be cast to the named class
  653. // type.
  654. //----------------------------------------------------------------------------
  655. JAVAVMAPI
  656. BOOL
  657. __cdecl
  658. isInstanceOf(
  659. HObject *phObj,
  660. PCUTF8 putfClassName
  661. );
  662. //----------------------------------------------------------------------------
  663. // is_instance_of
  664. //
  665. // Returns true if the specified object can be cast to the specified
  666. // class type.
  667. //----------------------------------------------------------------------------
  668. JAVAVMAPI
  669. BOOL
  670. __cdecl
  671. is_instance_of(
  672. HObject *phObj,
  673. ClassClass *pClass,
  674. ExecEnv *Unused
  675. );
  676. //----------------------------------------------------------------------------
  677. // is_subclass_of
  678. //
  679. // Returns true if the class (pClass) is a subclass of the specified
  680. // class(pParentClass).
  681. //----------------------------------------------------------------------------
  682. JAVAVMAPI
  683. BOOL
  684. __cdecl
  685. is_subclass_of(
  686. ClassClass *pClass,
  687. ClassClass *pParentClass,
  688. ExecEnv *Unused
  689. );
  690. //----------------------------------------------------------------------------
  691. // ImplementsInterface
  692. //
  693. // Returns true if the class (cb) implements the specified
  694. // interface (pInterfaceClass).
  695. //----------------------------------------------------------------------------
  696. JAVAVMAPI
  697. BOOL
  698. __cdecl
  699. ImplementsInterface(
  700. ClassClass *pClass,
  701. ClassClass *pInterfaceClass,
  702. ExecEnv *Unused
  703. );
  704. //----------------------------------------------------------------------------
  705. #define T_TMASK 034
  706. #define T_LMASK 003
  707. #define T_MKTYPE( t, l ) ( ( (t)&T_TMASK ) | ( (l)&T_LMASK) )
  708. #define T_CLASS 2
  709. #define T_FLOATING 4
  710. #define T_CHAR 5
  711. #define T_INTEGER 010
  712. #define T_BOOLEAN 4
  713. #define T_FLOAT T_MKTYPE(T_FLOATING,2)
  714. #define T_DOUBLE T_MKTYPE(T_FLOATING,3)
  715. #define T_BYTE T_MKTYPE(T_INTEGER,0)
  716. #define T_SHORT T_MKTYPE(T_INTEGER,1)
  717. #define T_INT T_MKTYPE(T_INTEGER,2)
  718. #define T_LONG T_MKTYPE(T_INTEGER,3)
  719. //----------------------------------------------------------------------------
  720. // Create an array of primitive types only (int, long etc).
  721. //----------------------------------------------------------------------------
  722. JAVAVMAPI
  723. HObject *
  724. __cdecl
  725. ArrayAlloc(
  726. int type,
  727. int cItems
  728. );
  729. //----------------------------------------------------------------------------
  730. // Create an array of objects.
  731. //----------------------------------------------------------------------------
  732. JAVAVMAPI
  733. HObject *
  734. __cdecl
  735. ClassArrayAlloc(
  736. int type,
  737. int cItems,
  738. PCUTF8 putfSignature
  739. );
  740. //----------------------------------------------------------------------------
  741. // Create an array of objects.
  742. // If type is T_CLASS, pClass must be valid.
  743. //----------------------------------------------------------------------------
  744. JAVAVMAPI
  745. HObject*
  746. __cdecl
  747. ClassArrayAlloc2(
  748. int type,
  749. int cItems,
  750. ClassClass *pClass
  751. );
  752. //----------------------------------------------------------------------------
  753. // Copy an array ala System.arrayCopy()
  754. //----------------------------------------------------------------------------
  755. JAVAVMAPI
  756. void
  757. __cdecl
  758. ArrayCopy(
  759. HObject *srch,
  760. long src_pos,
  761. HObject *dsth,
  762. long dst_pos,
  763. long length
  764. );
  765. //----------------------------------------------------------------------------
  766. // Create and return a new array of bytes initialized from the C string.
  767. //----------------------------------------------------------------------------
  768. JAVAVMAPI
  769. HArrayOfByte *
  770. __cdecl
  771. MakeByteString(
  772. LPCSTR pszData,
  773. long cbData
  774. );
  775. //----------------------------------------------------------------------------
  776. // Create and return a new Java String object, initialized from the C string.
  777. //----------------------------------------------------------------------------
  778. JAVAVMAPI
  779. HString *
  780. __cdecl
  781. makeJavaString(
  782. LPCSTR pszData,
  783. int cbData
  784. );
  785. JAVAVMAPI
  786. HString *
  787. __cdecl
  788. makeJavaStringW(
  789. LPCWSTR pcwsz,
  790. int cch
  791. );
  792. //----------------------------------------------------------------------------
  793. // Create and return a new Java String object, initialized from a null
  794. // terminated, UTF8 formatted, C string.
  795. //----------------------------------------------------------------------------
  796. JAVAVMAPI
  797. HString *
  798. __cdecl
  799. makeJavaStringFromUtf8(
  800. PCUTF8 putf
  801. );
  802. //----------------------------------------------------------------------------
  803. // Get the characters of the String object into a C string buffer.
  804. // No allocation occurs. Assumes that len is the size of the buffer.
  805. // The C string's address is returned.
  806. //----------------------------------------------------------------------------
  807. JAVAVMAPI
  808. char *
  809. __cdecl
  810. javaString2CString(
  811. HString *phString,
  812. char *pszBuffer,
  813. int cbBufferLength
  814. );
  815. //----------------------------------------------------------------------------
  816. // Return the length of the String object.
  817. //----------------------------------------------------------------------------
  818. JAVAVMAPI
  819. int
  820. __cdecl
  821. javaStringLength(
  822. HString *phString
  823. );
  824. JAVAVMAPI
  825. int
  826. __cdecl
  827. javaStringLengthAsCString(
  828. HString *phString
  829. );
  830. //----------------------------------------------------------------------------
  831. // Return temporary ptr to first char of the String object.
  832. // May change when gc happens.
  833. //----------------------------------------------------------------------------
  834. JAVAVMAPI
  835. LPWSTR
  836. __cdecl
  837. javaStringStart(
  838. HString *phString
  839. );
  840. //----------------------------------------------------------------------------
  841. // Note: The int passed to these API's must be an object ptr.
  842. //----------------------------------------------------------------------------
  843. #define obj_monitor(handlep) ((int) handlep)
  844. JAVAVMAPI
  845. void
  846. __cdecl
  847. monitorEnter(
  848. UINT_PTR);
  849. JAVAVMAPI
  850. void
  851. __cdecl
  852. monitorExit(
  853. UINT_PTR);
  854. JAVAVMAPI
  855. void
  856. __cdecl
  857. monitorNotify(
  858. UINT_PTR);
  859. JAVAVMAPI
  860. void
  861. __cdecl
  862. monitorNotifyAll(
  863. UINT_PTR);
  864. JAVAVMAPI
  865. void
  866. __cdecl
  867. monitorWait(
  868. UINT_PTR,
  869. int64_t millis
  870. );
  871. #define ObjectMonitorEnter(obj) monitorEnter((int)obj)
  872. #define ObjectMonitorExit(obj) monitorExit((int)obj)
  873. #define ObjectMonitorNotify(obj) monitorNotify((int)obj)
  874. #define ObjectMonitorNotifyAll(obj) monitorNotifyAll((int)obj)
  875. #define ObjectMonitorWait(obj,millis) monitorWait((int)obj,millis)
  876. //----------------------------------------------------------------------------
  877. // String helpers...
  878. //----------------------------------------------------------------------------
  879. JAVAVMAPI
  880. int
  881. __cdecl
  882. jio_snprintf(
  883. char *str,
  884. SIZE_T count,
  885. const char *fmt,
  886. ...
  887. );
  888. JAVAVMAPI
  889. int
  890. __cdecl
  891. jio_vsnprintf(
  892. char *str,
  893. SIZE_T count,
  894. const char *fmt,
  895. va_list args
  896. );
  897. //----------------------------------------------------------------------------
  898. // Methods to get information about the caller of a native method.
  899. //----------------------------------------------------------------------------
  900. JAVAVMAPI
  901. ClassClass *
  902. __cdecl
  903. GetNativeMethodCallersClass(
  904. VOID
  905. );
  906. JAVAVMAPI
  907. struct methodblock*
  908. __cdecl
  909. GetNativeMethodCallersMethodInfo(
  910. VOID
  911. );
  912. //----------------------------------------------------------------------------
  913. // Methods to get information about the native method.
  914. //----------------------------------------------------------------------------
  915. JAVAVMAPI
  916. ClassClass *
  917. __cdecl
  918. GetNativeMethodsClass(
  919. VOID
  920. );
  921. JAVAVMAPI
  922. struct methodblock *
  923. __cdecl
  924. GetNativeMethodsMethodInfo(
  925. VOID
  926. );
  927. //----------------------------------------------------------------------------
  928. // Member attributes, as appear in Java class file.
  929. //----------------------------------------------------------------------------
  930. #define ACC_PUBLIC 0x0001
  931. #define ACC_PRIVATE 0x0002
  932. #define ACC_PROTECTED 0x0004
  933. #define ACC_STATIC 0x0008
  934. #define ACC_FINAL 0x0010
  935. #define ACC_SYNCH 0x0020
  936. #define ACC_SUPER 0x0020
  937. #define ACC_THREADSAFE 0x0040
  938. #define ACC_VOLATILE 0x0040
  939. #define ACC_TRANSIENT 0x0080
  940. #define ACC_NATIVE 0x0100
  941. #define ACC_INTERFACE 0x0200
  942. #define ACC_ABSTRACT 0x0400
  943. //----------------------------------------------------------------------------
  944. // Class information
  945. //----------------------------------------------------------------------------
  946. // Total number of fields in the class, including supers
  947. JAVAVMAPI
  948. unsigned
  949. __cdecl
  950. Class_GetFieldCount(
  951. ClassClass *pClass
  952. );
  953. JAVAVMAPI
  954. struct fieldblock *
  955. __cdecl
  956. Class_GetField(
  957. ClassClass *pClass,
  958. PCUTF8 putfFieldName
  959. );
  960. JAVAVMAPI
  961. struct fieldblock *
  962. __cdecl
  963. Class_GetFieldByIndex(
  964. ClassClass *pClass,
  965. unsigned index
  966. );
  967. // Total number of methods, including supers.
  968. JAVAVMAPI
  969. unsigned
  970. __cdecl
  971. Class_GetMethodCount(
  972. ClassClass *pClass
  973. );
  974. JAVAVMAPI
  975. struct methodblock*
  976. __cdecl
  977. Class_GetMethod(
  978. ClassClass *pClass,
  979. PCUTF8 putfMethodName,
  980. PCUTF8 putfSignature
  981. );
  982. JAVAVMAPI
  983. struct methodblock*
  984. __cdecl
  985. Class_GetMethodByIndex(
  986. ClassClass *pClass,
  987. unsigned index
  988. );
  989. JAVAVMAPI
  990. ClassClass *
  991. __cdecl
  992. Class_GetSuper(
  993. ClassClass *pClass
  994. );
  995. JAVAVMAPI
  996. PCUTF8
  997. __cdecl
  998. Class_GetName(
  999. ClassClass *pClass
  1000. );
  1001. JAVAVMAPI
  1002. unsigned
  1003. __cdecl
  1004. Class_GetInterfaceCount(
  1005. ClassClass *pClass
  1006. );
  1007. JAVAVMAPI
  1008. ClassClass *
  1009. __cdecl
  1010. Class_GetInterface(
  1011. ClassClass *pClass,
  1012. unsigned index
  1013. );
  1014. // Returns combination of ACC_* constants.
  1015. JAVAVMAPI
  1016. int
  1017. __cdecl
  1018. Class_GetAttributes(
  1019. ClassClass *pClass
  1020. );
  1021. JAVAVMAPI
  1022. unsigned
  1023. __cdecl
  1024. Class_GetConstantPoolCount(
  1025. ClassClass *pClass
  1026. );
  1027. // Copies a constant pool item. 'size' is the size of 'pbuf' in bytes.
  1028. // 'ptype' is filled in on output with the type of the item. pbuf may be NULL
  1029. // to obtain only the size/type. Returns the number of bytes copied/needed or
  1030. // -1 if failed. For utf8 items, the buffer size is *not* the number of
  1031. // characters, and the copied string will be null-terminated; size includes the
  1032. // null-terminator. For ClassRef, FieldRef, etc., the buffer is filled in with
  1033. // a struct ptr.
  1034. //
  1035. // CP type Buffer contents
  1036. // CP_Utf8 null-terminated string
  1037. // CP_Unicode (error)
  1038. // CP_Integer long
  1039. // CP_Float float
  1040. // CP_Long __int64
  1041. // CP_Double double
  1042. // CP_Class ClassClass*
  1043. // CP_String HObject*
  1044. // CP_FieldRef fieldblock*
  1045. // CP_MethodRef methodblock*
  1046. // CP_IntfMethod methodblock*
  1047. // CP_NameAndType (error)
  1048. //
  1049. // Values for 'flags' parameter:
  1050. // If the constant pool item has not yet been used, force its referent to be
  1051. // loaded/looked up. With this flag set, the method may cause GC.
  1052. #define COPYCPITEM_RESOLVE_REFERENCES 1
  1053. JAVAVMAPI
  1054. int
  1055. __cdecl
  1056. Class_CopyConstantPoolItem(
  1057. ClassClass *pClass,
  1058. unsigned index,
  1059. BYTE *pbuf,
  1060. int size,
  1061. DWORD flags,
  1062. BYTE *ptype
  1063. );
  1064. //----------------------------------------------------------------------------
  1065. // Field/method information
  1066. //----------------------------------------------------------------------------
  1067. JAVAVMAPI
  1068. PCUTF8
  1069. __cdecl
  1070. Member_GetName(
  1071. PVOID member
  1072. );
  1073. JAVAVMAPI
  1074. PCUTF8
  1075. __cdecl
  1076. Member_GetSignature(
  1077. PVOID member
  1078. );
  1079. // class of the field/method is implemented in.
  1080. JAVAVMAPI
  1081. ClassClass *
  1082. __cdecl
  1083. Member_GetClass(
  1084. PVOID member
  1085. );
  1086. // Returns combination of ACC_* constants.
  1087. JAVAVMAPI
  1088. int
  1089. __cdecl
  1090. Member_GetAttributes(
  1091. PVOID member
  1092. );
  1093. // For non-static fields, Offset of field in object. See also Field_Get/SetValue.
  1094. JAVAVMAPI
  1095. unsigned
  1096. __cdecl
  1097. Field_GetOffset(
  1098. struct fieldblock * field
  1099. );
  1100. // Ptr to static value
  1101. JAVAVMAPI
  1102. PVOID
  1103. __cdecl
  1104. Field_GetStaticPtr(
  1105. struct fieldblock * field
  1106. );
  1107. //----------------------------------------------------------------------------
  1108. // Object accessors
  1109. //----------------------------------------------------------------------------
  1110. JAVAVMAPI
  1111. ClassClass *
  1112. __cdecl
  1113. Object_GetClass(
  1114. HObject *phObj
  1115. );
  1116. JAVAVMAPI
  1117. __int32
  1118. __cdecl
  1119. Field_GetValue(
  1120. HObject *phObj,
  1121. struct fieldblock * field
  1122. );
  1123. JAVAVMAPI
  1124. __int64
  1125. __cdecl
  1126. Field_GetValue64(
  1127. HObject *phObj,
  1128. struct fieldblock * field
  1129. );
  1130. JAVAVMAPI
  1131. float
  1132. __cdecl
  1133. Field_GetFloat(
  1134. HObject *phObj,
  1135. struct fieldblock * field
  1136. );
  1137. JAVAVMAPI
  1138. double
  1139. __cdecl
  1140. Field_GetDouble(
  1141. HObject *phObj,
  1142. struct fieldblock * field
  1143. );
  1144. #ifdef _WIN64
  1145. HObject *
  1146. __cdecl
  1147. Field_GetObject(
  1148. HObject *phObj,
  1149. struct fieldblock * field
  1150. );
  1151. #else
  1152. #define Field_GetObject(obj,field) ((HObject*) Field_GetValue(obj,field))
  1153. #endif
  1154. JAVAVMAPI
  1155. void
  1156. __cdecl
  1157. Field_SetValue(
  1158. HObject *phObj,
  1159. struct fieldblock * field,
  1160. __int32 value
  1161. );
  1162. JAVAVMAPI
  1163. void
  1164. __cdecl
  1165. Field_SetValue64(
  1166. HObject *phObj,
  1167. struct fieldblock * field,
  1168. __int64 value
  1169. );
  1170. JAVAVMAPI
  1171. void
  1172. __cdecl
  1173. Field_SetFloat(
  1174. HObject *phObj,
  1175. struct fieldblock * field,
  1176. float value
  1177. );
  1178. JAVAVMAPI
  1179. void
  1180. __cdecl
  1181. Field_SetDouble(
  1182. HObject *phObj,
  1183. struct fieldblock * field,
  1184. double value
  1185. );
  1186. #ifdef _WIN64
  1187. JAVAVMAPI
  1188. void
  1189. __cdecl
  1190. Field_SetObject(
  1191. HObject *phObj,
  1192. struct fieldblock * field,
  1193. HObject *phValue
  1194. );
  1195. #else
  1196. #define Field_SetObject(obj,field,value) Field_SetValue(obj,field,(__int32)(value))
  1197. #endif
  1198. #define Field_GetBoolean(obj,field) ((bool_t) Field_GetValue(obj,field))
  1199. #define Field_GetByte(obj,field) ((signed char) Field_GetValue(obj,field))
  1200. #define Field_GetChar(obj,field) ((unicode) Field_GetValue(obj,field))
  1201. #define Field_GetShort(obj,field) ((short) Field_GetValue(obj,field))
  1202. #define Field_GetInt(obj,field) Field_GetValue(obj,field)
  1203. #define Field_GetLong(obj,field) Field_GetValue64(obj,field)
  1204. #define Field_GetFloat(obj,field) Field_GetFloat(obj,field)
  1205. #define Field_GetDouble(obj,field) Field_GetDouble(obj,field)
  1206. #define Field_SetBoolean(obj,field,value) Field_SetValue(obj,field,(bool_t)(value))
  1207. #define Field_SetByte(obj,field,value) Field_SetValue(obj,field,(signed char)(value))
  1208. #define Field_SetChar(obj,field,value) Field_SetValue(obj,field,(unicode)(value))
  1209. #define Field_SetShort(obj,field,value) Field_SetValue(obj,field,(short)(value))
  1210. #define Field_SetInt(obj,field,value) Field_SetValue(obj,field,value)
  1211. #define Field_SetLong(obj,field,value) Field_SetValue64(obj,field,value)
  1212. #define Field_SetFloat(obj,field,value) Field_SetFloat(obj,field,value)
  1213. #define Field_SetDouble(obj,field,value) Field_SetDouble(obj,field,value)
  1214. //----------------------------------------------------------------------------
  1215. // java.lang.Class<->ClassClass conversions
  1216. //----------------------------------------------------------------------------
  1217. JAVAVMAPI
  1218. ClassClass*
  1219. __cdecl
  1220. ClassObjectToClassClass(
  1221. HObject *phObj
  1222. );
  1223. JAVAVMAPI
  1224. HObject*
  1225. __cdecl
  1226. ClassClassToClassObject(
  1227. ClassClass *pClass
  1228. );
  1229. //----------------------------------------------------------------------------
  1230. // Thread information
  1231. //----------------------------------------------------------------------------
  1232. JAVAVMAPI
  1233. BOOL
  1234. __cdecl
  1235. Thread_IsInterrupted(
  1236. BOOL fResetInterruptFlag
  1237. );
  1238. //----------------------------------------------------------------------------
  1239. // class path modification
  1240. //----------------------------------------------------------------------------
  1241. // add path to the VM's internal class path.
  1242. // if fAppend is true, path is appended to the class path, else it is prepended.
  1243. JAVAVMAPI
  1244. BOOL
  1245. __cdecl
  1246. AddPathClassSource(
  1247. const char *path,
  1248. BOOL fAppend
  1249. );
  1250. // notify the VM of a WIN32 resource containing class files. this resource must
  1251. // be in the format created by JExeGen.
  1252. // when classes are being loaded, the resource will be searched for classes
  1253. // as if it were a directory on the classpath.
  1254. JAVAVMAPI
  1255. BOOL
  1256. __cdecl
  1257. AddModuleResourceClassSource(
  1258. HMODULE hMod,
  1259. DWORD dwResID
  1260. );
  1261. //----------------------------------------------------------------------------
  1262. // Miscellaneous APIs
  1263. //----------------------------------------------------------------------------
  1264. // Returns the same result as defined by java/lang/System.currentTimeMillis().
  1265. JAVAVMAPI
  1266. __int64
  1267. __cdecl
  1268. GetCurrentJavaTimeMillis(
  1269. VOID
  1270. );
  1271. #ifdef __cplusplus
  1272. }
  1273. #endif
  1274. #pragma warning(default:4115)
  1275. #pragma warning(default:4510)
  1276. #pragma warning(default:4512)
  1277. #pragma warning(default:4610)
  1278. #endif