Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
3b76a0be
Commit
3b76a0be
authored
Oct 05, 2010
by
Vincent Povirk
Committed by
Alexandre Julliard
Nov 12, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mscoree: Implement ClrCreateManagedInstance.
parent
d2d743ef
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
193 additions
and
2 deletions
+193
-2
corruntimehost.c
dlls/mscoree/corruntimehost.c
+132
-0
metahost.c
dlls/mscoree/metahost.c
+10
-0
mscoree_main.c
dlls/mscoree/mscoree_main.c
+31
-2
mscoree_private.h
dlls/mscoree/mscoree_private.h
+20
-0
No files found.
dlls/mscoree/corruntimehost.c
View file @
3b76a0be
...
@@ -496,6 +496,138 @@ static const struct ICLRRuntimeHostVtbl CLRHostVtbl =
...
@@ -496,6 +496,138 @@ static const struct ICLRRuntimeHostVtbl CLRHostVtbl =
CLRRuntimeHost_ExecuteInDefaultAppDomain
CLRRuntimeHost_ExecuteInDefaultAppDomain
};
};
/* Create an instance of a type given its name, by calling its constructor with
* no arguments. Note that result MUST be in the stack, or the garbage
* collector may free it prematurely. */
HRESULT
RuntimeHost_CreateManagedInstance
(
RuntimeHost
*
This
,
LPCWSTR
name
,
MonoDomain
*
domain
,
MonoObject
**
result
)
{
HRESULT
hr
=
S_OK
;
char
*
nameA
=
NULL
;
MonoType
*
type
;
MonoClass
*
klass
;
MonoObject
*
obj
;
if
(
!
domain
)
hr
=
RuntimeHost_GetDefaultDomain
(
This
,
&
domain
);
if
(
SUCCEEDED
(
hr
))
{
nameA
=
WtoA
(
name
);
if
(
!
nameA
)
hr
=
E_OUTOFMEMORY
;
}
if
(
SUCCEEDED
(
hr
))
{
type
=
This
->
mono
->
mono_reflection_type_from_name
(
nameA
,
NULL
);
if
(
!
type
)
{
ERR
(
"Cannot find type %s
\n
"
,
debugstr_w
(
name
));
hr
=
E_FAIL
;
}
}
if
(
SUCCEEDED
(
hr
))
{
klass
=
This
->
mono
->
mono_class_from_mono_type
(
type
);
if
(
!
klass
)
{
ERR
(
"Cannot convert type %s to a class
\n
"
,
debugstr_w
(
name
));
hr
=
E_FAIL
;
}
}
if
(
SUCCEEDED
(
hr
))
{
obj
=
This
->
mono
->
mono_object_new
(
domain
,
klass
);
if
(
!
obj
)
{
ERR
(
"Cannot allocate object of type %s
\n
"
,
debugstr_w
(
name
));
hr
=
E_FAIL
;
}
}
if
(
SUCCEEDED
(
hr
))
{
/* FIXME: Detect exceptions from the constructor? */
This
->
mono
->
mono_runtime_object_init
(
obj
);
*
result
=
obj
;
}
HeapFree
(
GetProcessHeap
(),
0
,
nameA
);
return
hr
;
}
/* Get an IUnknown pointer for a Mono object.
*
* This is just a "light" wrapper around
* System.Runtime.InteropServices.Marshal:GetIUnknownForObject
*
* NOTE: The IUnknown* is created with a reference to the object.
* Until they have a reference, objects must be in the stack to prevent the
* garbage collector from freeing them. */
HRESULT
RuntimeHost_GetIUnknownForObject
(
RuntimeHost
*
This
,
MonoObject
*
obj
,
IUnknown
**
ppUnk
)
{
MonoDomain
*
domain
;
MonoAssembly
*
assembly
;
MonoImage
*
image
;
MonoClass
*
klass
;
MonoMethod
*
method
;
MonoObject
*
result
;
void
*
args
[
2
];
domain
=
This
->
mono
->
mono_object_get_domain
(
obj
);
assembly
=
This
->
mono
->
mono_domain_assembly_open
(
domain
,
"mscorlib"
);
if
(
!
assembly
)
{
ERR
(
"Cannot load mscorlib
\n
"
);
return
E_FAIL
;
}
image
=
This
->
mono
->
mono_assembly_get_image
(
assembly
);
if
(
!
image
)
{
ERR
(
"Couldn't get assembly image
\n
"
);
return
E_FAIL
;
}
klass
=
This
->
mono
->
mono_class_from_name
(
image
,
"System.Runtime.InteropServices"
,
"Marshal"
);
if
(
!
klass
)
{
ERR
(
"Couldn't get class from image
\n
"
);
return
E_FAIL
;
}
method
=
This
->
mono
->
mono_class_get_method_from_name
(
klass
,
"GetIUnknownForObject"
,
1
);
if
(
!
method
)
{
ERR
(
"Couldn't get method from class
\n
"
);
return
E_FAIL
;
}
args
[
0
]
=
obj
;
args
[
1
]
=
NULL
;
result
=
This
->
mono
->
mono_runtime_invoke
(
method
,
NULL
,
args
,
NULL
);
if
(
!
result
)
{
ERR
(
"Couldn't get result pointer
\n
"
);
return
E_FAIL
;
}
*
ppUnk
=
*
(
IUnknown
**
)
This
->
mono
->
mono_object_unbox
(
result
);
if
(
!*
ppUnk
)
{
ERR
(
"GetIUnknownForObject returned 0
\n
"
);
return
E_FAIL
;
}
return
S_OK
;
}
static
void
get_utf8_args
(
int
*
argc
,
char
***
argv
)
static
void
get_utf8_args
(
int
*
argc
,
char
***
argv
)
{
{
WCHAR
**
argvw
;
WCHAR
**
argvw
;
...
...
dlls/mscoree/metahost.c
View file @
3b76a0be
...
@@ -138,14 +138,24 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result)
...
@@ -138,14 +138,24 @@ static HRESULT load_mono(CLRRuntimeInfo *This, loaded_mono **result)
} \
} \
} while (0);
} while (0);
LOAD_MONO_FUNCTION
(
mono_assembly_get_image
);
LOAD_MONO_FUNCTION
(
mono_assembly_open
);
LOAD_MONO_FUNCTION
(
mono_assembly_open
);
LOAD_MONO_FUNCTION
(
mono_config_parse
);
LOAD_MONO_FUNCTION
(
mono_config_parse
);
LOAD_MONO_FUNCTION
(
mono_class_from_mono_type
);
LOAD_MONO_FUNCTION
(
mono_class_from_name
);
LOAD_MONO_FUNCTION
(
mono_class_get_method_from_name
);
LOAD_MONO_FUNCTION
(
mono_domain_assembly_open
);
LOAD_MONO_FUNCTION
(
mono_domain_assembly_open
);
LOAD_MONO_FUNCTION
(
mono_install_assembly_preload_hook
);
LOAD_MONO_FUNCTION
(
mono_install_assembly_preload_hook
);
LOAD_MONO_FUNCTION
(
mono_jit_cleanup
);
LOAD_MONO_FUNCTION
(
mono_jit_cleanup
);
LOAD_MONO_FUNCTION
(
mono_jit_exec
);
LOAD_MONO_FUNCTION
(
mono_jit_exec
);
LOAD_MONO_FUNCTION
(
mono_jit_init
);
LOAD_MONO_FUNCTION
(
mono_jit_init
);
LOAD_MONO_FUNCTION
(
mono_jit_set_trace_options
);
LOAD_MONO_FUNCTION
(
mono_jit_set_trace_options
);
LOAD_MONO_FUNCTION
(
mono_object_get_domain
);
LOAD_MONO_FUNCTION
(
mono_object_new
);
LOAD_MONO_FUNCTION
(
mono_object_unbox
);
LOAD_MONO_FUNCTION
(
mono_reflection_type_from_name
);
LOAD_MONO_FUNCTION
(
mono_runtime_invoke
);
LOAD_MONO_FUNCTION
(
mono_runtime_object_init
);
LOAD_MONO_FUNCTION
(
mono_set_dirs
);
LOAD_MONO_FUNCTION
(
mono_set_dirs
);
LOAD_MONO_FUNCTION
(
mono_stringify_assembly_name
);
LOAD_MONO_FUNCTION
(
mono_stringify_assembly_name
);
...
...
dlls/mscoree/mscoree_main.c
View file @
3b76a0be
...
@@ -369,8 +369,37 @@ HRESULT WINAPI CorBindToCurrentRuntime(LPCWSTR filename, REFCLSID rclsid, REFIID
...
@@ -369,8 +369,37 @@ HRESULT WINAPI CorBindToCurrentRuntime(LPCWSTR filename, REFCLSID rclsid, REFIID
STDAPI
ClrCreateManagedInstance
(
LPCWSTR
pTypeName
,
REFIID
riid
,
void
**
ppObject
)
STDAPI
ClrCreateManagedInstance
(
LPCWSTR
pTypeName
,
REFIID
riid
,
void
**
ppObject
)
{
{
FIXME
(
"(%s,%s,%p)
\n
"
,
debugstr_w
(
pTypeName
),
debugstr_guid
(
riid
),
ppObject
);
HRESULT
ret
;
return
E_NOTIMPL
;
ICLRRuntimeInfo
*
info
;
RuntimeHost
*
host
;
MonoObject
*
obj
;
IUnknown
*
unk
;
TRACE
(
"(%s,%s,%p)
\n
"
,
debugstr_w
(
pTypeName
),
debugstr_guid
(
riid
),
ppObject
);
/* FIXME: How to determine which runtime version to use? */
ret
=
get_runtime_info
(
NULL
,
NULL
,
NULL
,
0
,
RUNTIME_INFO_UPGRADE_VERSION
,
TRUE
,
&
info
);
if
(
SUCCEEDED
(
ret
))
{
ret
=
ICLRRuntimeInfo_GetRuntimeHost
(
info
,
&
host
);
ICLRRuntimeInfo_Release
(
info
);
}
if
(
SUCCEEDED
(
ret
))
ret
=
RuntimeHost_CreateManagedInstance
(
host
,
pTypeName
,
NULL
,
&
obj
);
if
(
SUCCEEDED
(
ret
))
ret
=
RuntimeHost_GetIUnknownForObject
(
host
,
obj
,
&
unk
);
if
(
SUCCEEDED
(
ret
))
{
ret
=
IUnknown_QueryInterface
(
unk
,
riid
,
ppObject
);
IUnknown_Release
(
unk
);
}
return
ret
;
}
}
BOOL
WINAPI
StrongNameSignatureVerification
(
LPCWSTR
filename
,
DWORD
inFlags
,
DWORD
*
pOutFlags
)
BOOL
WINAPI
StrongNameSignatureVerification
(
LPCWSTR
filename
,
DWORD
inFlags
,
DWORD
*
pOutFlags
)
...
...
dlls/mscoree/mscoree_private.h
View file @
3b76a0be
...
@@ -77,6 +77,11 @@ extern void free_parsed_config_file(parsed_config_file *file);
...
@@ -77,6 +77,11 @@ extern void free_parsed_config_file(parsed_config_file *file);
typedef
struct
_MonoDomain
MonoDomain
;
typedef
struct
_MonoDomain
MonoDomain
;
typedef
struct
_MonoAssembly
MonoAssembly
;
typedef
struct
_MonoAssembly
MonoAssembly
;
typedef
struct
_MonoAssemblyName
MonoAssemblyName
;
typedef
struct
_MonoAssemblyName
MonoAssemblyName
;
typedef
struct
_MonoType
MonoType
;
typedef
struct
_MonoImage
MonoImage
;
typedef
struct
_MonoClass
MonoClass
;
typedef
struct
_MonoObject
MonoObject
;
typedef
struct
_MonoMethod
MonoMethod
;
typedef
enum
{
typedef
enum
{
MONO_IMAGE_OK
,
MONO_IMAGE_OK
,
...
@@ -92,7 +97,11 @@ typedef struct loaded_mono
...
@@ -92,7 +97,11 @@ typedef struct loaded_mono
HMODULE
mono_handle
;
HMODULE
mono_handle
;
HMODULE
glib_handle
;
HMODULE
glib_handle
;
MonoImage
*
(
*
mono_assembly_get_image
)(
MonoAssembly
*
assembly
);
MonoAssembly
*
(
*
mono_assembly_open
)(
const
char
*
filename
,
MonoImageOpenStatus
*
status
);
MonoAssembly
*
(
*
mono_assembly_open
)(
const
char
*
filename
,
MonoImageOpenStatus
*
status
);
MonoClass
*
(
*
mono_class_from_mono_type
)(
MonoType
*
type
);
MonoClass
*
(
*
mono_class_from_name
)(
MonoImage
*
image
,
const
char
*
name_space
,
const
char
*
name
);
MonoMethod
*
(
*
mono_class_get_method_from_name
)(
MonoClass
*
klass
,
const
char
*
name
,
int
param_count
);
void
(
*
mono_config_parse
)(
const
char
*
filename
);
void
(
*
mono_config_parse
)(
const
char
*
filename
);
MonoAssembly
*
(
*
mono_domain_assembly_open
)
(
MonoDomain
*
domain
,
const
char
*
name
);
MonoAssembly
*
(
*
mono_domain_assembly_open
)
(
MonoDomain
*
domain
,
const
char
*
name
);
void
(
*
mono_free
)(
void
*
);
void
(
*
mono_free
)(
void
*
);
...
@@ -101,6 +110,12 @@ typedef struct loaded_mono
...
@@ -101,6 +110,12 @@ typedef struct loaded_mono
int
(
*
mono_jit_exec
)(
MonoDomain
*
domain
,
MonoAssembly
*
assembly
,
int
argc
,
char
*
argv
[]);
int
(
*
mono_jit_exec
)(
MonoDomain
*
domain
,
MonoAssembly
*
assembly
,
int
argc
,
char
*
argv
[]);
MonoDomain
*
(
*
mono_jit_init
)(
const
char
*
file
);
MonoDomain
*
(
*
mono_jit_init
)(
const
char
*
file
);
int
(
*
mono_jit_set_trace_options
)(
const
char
*
options
);
int
(
*
mono_jit_set_trace_options
)(
const
char
*
options
);
MonoDomain
*
(
*
mono_object_get_domain
)(
MonoObject
*
obj
);
MonoObject
*
(
*
mono_object_new
)(
MonoDomain
*
domain
,
MonoClass
*
klass
);
void
*
(
*
mono_object_unbox
)(
MonoObject
*
obj
);
MonoType
*
(
*
mono_reflection_type_from_name
)(
char
*
name
,
MonoImage
*
image
);
MonoObject
*
(
*
mono_runtime_invoke
)(
MonoMethod
*
method
,
void
*
obj
,
void
**
params
,
MonoObject
**
exc
);
void
(
*
mono_runtime_object_init
)(
MonoObject
*
this_obj
);
void
(
*
mono_set_dirs
)(
const
char
*
assembly_dir
,
const
char
*
config_dir
);
void
(
*
mono_set_dirs
)(
const
char
*
assembly_dir
,
const
char
*
config_dir
);
char
*
(
*
mono_stringify_assembly_name
)(
MonoAssemblyName
*
aname
);
char
*
(
*
mono_stringify_assembly_name
)(
MonoAssemblyName
*
aname
);
}
loaded_mono
;
}
loaded_mono
;
...
@@ -113,6 +128,11 @@ extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
...
@@ -113,6 +128,11 @@ extern HRESULT RuntimeHost_Construct(const CLRRuntimeInfo *runtime_version,
extern
HRESULT
RuntimeHost_GetInterface
(
RuntimeHost
*
This
,
REFCLSID
clsid
,
REFIID
riid
,
void
**
ppv
);
extern
HRESULT
RuntimeHost_GetInterface
(
RuntimeHost
*
This
,
REFCLSID
clsid
,
REFIID
riid
,
void
**
ppv
);
extern
HRESULT
RuntimeHost_GetIUnknownForObject
(
RuntimeHost
*
This
,
MonoObject
*
obj
,
IUnknown
**
ppUnk
);
extern
HRESULT
RuntimeHost_CreateManagedInstance
(
RuntimeHost
*
This
,
LPCWSTR
name
,
MonoDomain
*
domain
,
MonoObject
**
result
);
extern
HRESULT
RuntimeHost_Destroy
(
RuntimeHost
*
This
);
extern
HRESULT
RuntimeHost_Destroy
(
RuntimeHost
*
This
);
#endif
/* __MSCOREE_PRIVATE__ */
#endif
/* __MSCOREE_PRIVATE__ */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment