如何读取内存中加载的模块的PE头?(How do I read the PE header of a module loaded in memory?)
我正在试验.NET中的内存访问。 目前,我有一个托管程序,用于启动非托管进程并检索其加载模块(DLL)的一个
BaseAddress
。 我想要做的是以某种方式读取已加载模块的PE标头,以便稍后可以检索其导出的地址。不幸的是,我找不到任何有关这方面的好消息。 有任何想法吗?
I'm experimenting with memory access in .NET. At the moment, I have a managed program that starts an unmanaged process and retrieves the
BaseAddress
of one of its loaded modules (a DLL). What I would like to do is somehow read the PE header of the loaded module so that I can later retrieve the addresses of its exports.Unfortunately, I can't find any good information about this. Any ideas?
原文:https://stackoverflow.com/questions/1563134
最满意答案
你有
if(flag==1) { ... return ... }
你需要添加一个带有return
或throw new ...
的else
语句throw new ...
public DataTable GetAlltheatredet()//I got error here// { DataTable myalltheat = GetAllmytheatdet(); foreach (DataRow drow1 in myalltheat.Rows) { usermsterid = drow1["UserMasterId"].ToString(); if (usrmid == usermsterid) { flag = 1; break; } if (flag == 1) { try { string connString = "Server=localhost;database=Mytable;uid=root;"; string query = "SELECT * FROM `Mytable`.`Mydata`"; MySqlDataAdapter ma = new MySqlDataAdapter(query, connString); DataSet DS = new DataSet(); ma.Fill(DS); return DS.Tables[0]; } catch (MySqlException e) { throw new Exception(e.Message); } } else { throw new Exception("Flag isn't 1 and I don't know what to do"); } } }
you have
if(flag==1) { ... return ... }
you need to add anelse
statement with either areturn
or athrow new ...
public DataTable GetAlltheatredet()//I got error here// { DataTable myalltheat = GetAllmytheatdet(); foreach (DataRow drow1 in myalltheat.Rows) { usermsterid = drow1["UserMasterId"].ToString(); if (usrmid == usermsterid) { flag = 1; break; } if (flag == 1) { try { string connString = "Server=localhost;database=Mytable;uid=root;"; string query = "SELECT * FROM `Mytable`.`Mydata`"; MySqlDataAdapter ma = new MySqlDataAdapter(query, connString); DataSet DS = new DataSet(); ma.Fill(DS); return DS.Tables[0]; } catch (MySqlException e) { throw new Exception(e.Message); } } else { throw new Exception("Flag isn't 1 and I don't know what to do"); } } }
相关问答
更多-
您的foreach需要在副本上,而不是原始集。 您无法从collection2中删除collection1中包含的对象。 foreach (DataRow dr in newData.Rows) 否则,您可以使用计数器在索引处删除。 像这样的东西: for(int i = 0; i < data.Rows.Count; i++) { if (_DataCopyLogMaintenance.ContainedInDataCopyLog(data.Rows[i])) { newData.Row ...
-
c#中的数据表错误(Datatable error in c#)[2023-06-25]
你有if(flag==1) { ... return ... }你需要添加一个带有return或throw new ...的else语句throw new ... public DataTable GetAlltheatredet()//I got error here// { DataTable myalltheat = GetAllmytheatdet(); foreach (DataRow drow1 in myalltheat.Rows) { usermste ... -
在asp.net c中将数据表转换为excel后出现错误信息#(error message after converting datatable to excel in asp.net c#)[2022-07-14]
您的内容类型有误。 您正在创建CSV输出,而不是Excel。 将内容类型更改为text / csv,将文件扩展名更改为.csv。 如何使用CSV MIME类型? 链接到OpenXML SDK,让您创建任何Office格式: http : //msdn.microsoft.com/en-us/library/office/bb448854%28v=office.15%29.aspx Your content type is wrong. You are creating a CSV output, not E ... -
它看起来像是在设计器中添加了列,并且DataGridView的AutoGenerateColumns设置为false。 由于您的列数与您的数据源不匹配,因此您收到此错误。 要解决这个问题,要么 在设计器中添加列以匹配数据源 或者,将dataGridView1.AutoGenerateColumns设置为True 请参阅参考: https : //msdn.microsoft.com/en-us/library/system.windows.forms.datagridview.autogeneratecol ...
-
我试过这个分隔符选项并解决了我的问题OleDbConnection cnnOleDB = new OleDbConnection(“Provider = Microsoft.Jet.OLEDB.4.0; Data Source = D:\ Test; Extended Properties ='text; HDR = Yes; FMT = Delimited(, ) ';'” 在这里完整版的代码, private DataTable ReadFileByDataTable(string sFileName) ...
-
yui数据表错误(yui datatable error)[2022-04-16]
我找到了解决我的问题的方法。 json是一个错误! 坏: {"geneItemList":"{"col":"symbol","qv":"cd4","limit":"-1","start":"0","geneid":"920","name":"CD4" ,"symbol":"CD4","lastupdated":"2009-05-20 10:01:52.0","lastmodified":"2009-05-20 11:12:37.0"} ,... 好: {"geneItemList":**[**{"col" ... -
所有零件必须返回一个值。参见这里 你只返回if部分,如果if部分不起作用会怎么样? 所以你还需要额外的变体,它可能在方法的最后。 public DataTable GetApprovedData(ref string tablename) { dtTbl = new DataTable(); try { if (cnn.State==System.Data.ConnectionState.Closed) { ...
-
在c#中的数据表中添加列?(Add columns to a datatable in c#?)[2021-11-26]
使用dt.Rows.Import或dt.ImportRows,我忘记了名字 或者从你的代码判断,为什么你需要dt.Rows.Add? 不应该省略吗? Use dt.Rows.Import, or dt.ImportRows, I forgot the name or judging from your code, why you need the dt.Rows.Add? shouldn't that be omitted? -
DataTable上的动态Linq错误:DataRow中没有字段或属性,c#(Dynamic Linq on DataTable error: no Field or Property in DataRow, c#)[2023-08-17]
首先,这条线有错误 orderby zz.Field("ID") 因为如你所说,你的ID列是int类型的。 其次,你需要学习LINQ查询语法。 忘记关于字符串的方式,您可以使用orderby , select在查询中使用相同的方式,还可以使用where和许多其他运算符。 你还需要学习用于SQL-ISH的等价LINQ结构,例如IN (...)映射到Enumerable.Contains等。 尽管如此,这是您的查询 var productFilter = new[] { "EWH", "HEC ... -
c#代码中的下拉列表错误(dropdownlist error in c# code)[2020-10-28]
DropDownList的text属性获取或设置SelectedValue 。 由于您的DataValueField设置为“id”,因此您需要将Text属性设置为“12”。 The text property of a DropDownList gets or sets the SelectedValue. Since your DataValueField is set to "id", you would need to set the Text property to "12".